Hi Shawn, Chris,

Thanks for the proposal. +1 to doing it in phases, and to Amogh's idea of
trying re-plan and retry first.

It may help to list the three kinds of DV conflicts people are working on:
1. Two DELETEs on the same data file: #17754
<https://github.com/apache/iceberg/pull/17754> merges the two DVs instead
of failing.
2. UPDATE/MERGE against other row changes: EJ's #18603
<https://github.com/apache/iceberg/pull/18603> limits the conflict check to
the data files the UPDATE changes, and #18020
<https://github.com/apache/iceberg/issues/18020> plans to narrow it further
to the rows.
3. Compaction against DELETE/UPDATE: this proposal. Phase 1 lets compaction
survive concurrent deletes. Phase 2 (the persisted map) would also let a
delete or update survive a concurrent compaction.

They don't depend on each other, so #17754
<https://github.com/apache/iceberg/pull/17754> and #18603
<https://github.com/apache/iceberg/pull/18603> can move forward without
waiting for this proposal. They all change the same commit checks, though,
so it would be good to keep them consistent. #17754 is almost ready and
could use another committer review.

Thanks,
Huaxin


On Tue, Nov 24, 2026 at 9:03 AM Amogh Jahagirdar <[email protected]> wrote:

> +1 to not adding a persisted compaction map to the spec until we know it's
> actually needed. We can always add an optional field later, so this doesn't
> have to block anything. My stance is for this case we should push the
> implementations as much as possible before we add spec complexity.
>
> Even before in-memory compaction maps, there are concrete gaps in
> maintenance procedures like Spark's RewriteDataFiles that make the problem
> referenced above worse than it needs to be. The whole action plans from one
> starting snapshot, and every file group validates against it. So each group
> is exposed to conflicting deletes from any point since the action started.
> On a long running compaction job, groups that start late are very likely to
> hit a delete that landed well before they started, which they could have
> just read up front. And when a group fails validation we throw its work
> away instead of re-planning it against a newer snapshot and retrying.
> Spark's position delete rewrite and Flink's rewrite maintenance have the
> same pattern, with one baseline for all groups in a run and no retry on
> validation failure.
>
> If each group re-planned against the latest snapshot before rewriting,
> validated from that same snapshot, and retried on conflict, the conflict
> window would shrink to that group's own rewrite time. This keeps the same
> isolation we have today, since each group is validated against exactly what
> it read.
>
> To be clear about the limits, this doesn't help when a file's DV gets
> updated so often that it almost always changes while its group is rewriting
> it, like the hot key CDC case. A group can still lose if a delete lands
> during its own rewrite, and a retry costs a full rewrite of that group.
> That's where the in-memory map may be beneficial. But fixing the baseline
> should cut a lot of the conflicts people see today, and it tells us how
> much is actually left for a map to solve.
>
> For experiments, I think the useful measurements are commit success rate,
> wasted rewrite work, and how much of the table is compacted over time as
> the delete rate goes up, comparing today's behavior, re-plan plus retry,
> and the in-memory map.
>
> Thanks,
> Amogh
>
> On Tue, Nov 24, 2026 at 11:01 AM Pachu Shrinivas <
> [email protected]> wrote:
>
>> +1 on the phased approach - solving even half the problem is better than
>> not solving it at all :). I'm also happy to help in any way I can (help
>> with implementation and/or code review)
>>
>> Thanks,
>> Pachu
>>
>> On Mon, Nov 23, 2026 at 7:09 PM Kevin Liu via dev <[email protected]>
>> wrote:
>>
>> Since we're all sharing content from Chris, here's another one from the
>> Virtual Meetup session on Commutative Compaction :)
>> https://www.youtube.com/watch?v=9DPaCES0p0c
>>
>> On Mon, Nov 23, 2026 at 3:35 PM Mukund Madhav Thakur via dev <
>> [email protected]> wrote:
>>
>> +1. Thanks Shawn for starting the discussion. I have been looking at this
>> paper and the reference implementation provided by Chris
>> https://github.com/cdouglas/iceberg/tree/cmpmap
>> Here are my thoughts based on my work so far and reviewing your shared
>> design doc.
>>
>>
>>    - I think we should add a section on compatibility with readers and
>>    writers who don't understand compaction maps.
>>    - I think it would be good to calculate how helpful this feature will
>>    be by determining how frequently we see compaction conflicts in a real
>>    world workload and how much time/resources are wasted by having to retry
>>    the entire process, whether it be retrying a commit or compaction process.
>>    - In memory compaction maps only solve conflicts occurring on the
>>    compaction side. Persisting them will help remap write conflicts as well
>>    but yes implementation can come in phases.
>>
>>
>> I would be glad to work on this with you all if you'd like.
>>
>>
>> On Mon, Nov 23, 2026 at 2:18 PM Shawn Chang <[email protected]>
>> wrote:
>>
>> Hi all,
>>
>> Thanks for the discussion so far! The feedback here and in the doc has
>> been very helpful, and I'm working through it now.
>>
>> On the larger question of persisting the compaction map, I'd like to
>> split this into two phases:
>> 1) in-memory map, no spec changes. The compaction rebases onto concurrent
>> DVs onto its output(Case A in the doc). This is what the doc primarily
>> covers
>> 2) Spec-changing persisted map that we also allow later coming DML to
>> also commute (Case B in the doc)
>> Although phase 2 work would be very impactful as mentioned, I'd like to
>> focus the current discussion on phase 1 first so we can move faster.
>>
>> I'll post when the revised doc is up. looking forward to more inputs!
>>
>> Best,
>> Shawn
>>
>> On Sun, Nov 22, 2026 at 7:30 PM Pachu Shrinivas <
>> [email protected]> wrote:
>>
>> Hi EJ, Anurag,
>> I'm really happy to hear folks have been thinking about this problem and
>> potential solutions! Regarding the spec change only coming in v5 - forgive
>> my ignorance, but has V4 already been finalized? Is there any possibility
>> of adding the breadcrumb to the manifest entry? I agree that in-memory
>> compaction maps will allow long-running compaction rewrites to rebase
>> against concurrent DML and succeed. However, if the DML transaction fails,
>> retrying it without the compaction map may not be cheap. For example, if
>> the DML came from the Flink eq-delete-to-DV rewriter, it relies on an index
>> to find row positions. If a concurrent compaction has just rewritten some
>> data files, the index won't be up-to-date for the rewriter to quickly
>> recompute positions and retry.
>>
>> Thanks,
>> Pachu
>>
>> On Sat, Nov 21, 2026 at 4:16 PM Anurag Mantripragada via dev <
>> [email protected]> wrote:
>>
>> Hi Shawn, Chris,
>>
>> Thanks for writing this up, and thanks Grant, Pachu and EJ for the
>> context so far. I did a first round of review on the doc. The direction
>> makes sense to me, and fixing compaction commit failures without a spec
>> change is a good first step. Below are the main gaps I see at the design
>> level. I'll leave more detailed comments inline in the doc.
>>
>>    1.
>>
>>    The doc doesn't say which public APIs, action options or properties
>>    this introduces, or whether they live in core or in the engine. Other
>>    engines and users will build on these, so I think they belong in the doc
>>    before the PR.
>>    2.
>>
>>    The doc refers to Spark's TaskCommit in passing but doesn't state the
>>    scope of the first version. It would help to say it targets Spark first,
>>    which parts are engine-agnostic in core, and what another engine such as
>>    Flink would need to provide.
>>    3.
>>
>>    Since this works on deletion vectors, I assume it is v3+ only. Could
>>    the doc say so explicitly and describe what happens on v2 tables with
>>    position delete files?
>>    4.
>>
>>    The flowchart mentions a "conservative failure or fallback" but
>>    doesn't define it. When the rewrite can't use the map, does it fail as it
>>    does today, or skip tracking and commit the old way? Examples are a sort 
>> or
>>    z-order rewrite, a v2 table, too many concurrent deletes, or exhausted
>>    retries. And should it fail fast when a user explicitly turns the feature
>>    on?
>>    5.
>>
>>    This problem has a long history. #2308
>>    <https://github.com/apache/iceberg/issues/2308> was the original
>>    report, #2865 <https://github.com/apache/iceberg/pull/2865> added
>>    today's validation, #3480
>>    <https://github.com/apache/iceberg/pull/3480> added
>>    use-starting-sequence-number, and #5888
>>    <https://github.com/apache/iceberg/pull/5888> tried rolling back the
>>    compaction. There is also active DV work touching the same validation 
>> code,
>>    in #17754 <https://github.com/apache/iceberg/pull/17754>, #18603
>>    <https://github.com/apache/iceberg/pull/18603>, #18224
>>    <https://github.com/apache/iceberg/pull/18224> and EJ's #18020
>>    <https://github.com/apache/iceberg/issues/18020>. A short section
>>    comparing these approaches would show why remapping is the right choice 
>> and
>>    how it fits with the in-flight changes.
>>
>> Persistence of the map requires a spec change and most likely can only
>> come in V5. One option is to keep this doc focused on the in-memory phase and
>> add persistence in V5?
>>
>> As I said, I've been thinking about the same problem, so I'd be glad to
>> write the design sections and test plan for this doc with you all too if
>> you'd like.
>>
>> ~ Anurag
>>
>> On Fri, Nov 20, 2026 at 3:18 PM EJ Song <[email protected]> wrote:
>>
>> Hi Shawn, Chris,
>>
>> +1 on the direction. Some background on how Delta handles the same
>> problem, which may help with the persisted version Grant and Pachu are
>> asking for. I've been working on row-level concurrency for OSS Delta [1],
>> including compaction-vs-DML remapping in both directions (fork PRs, not yet
>> upstream) [2]. That work writes the same tags Databricks does, and I tested
>> it with Databricks Runtime 16.4 committing to the same table concurrently.
>> The Databricks behavior below is from my own tests on DBR 16.4 and 18.2.
>>
>> 1. Delta resolves both directions. Databricks documents that on
>> deletion-vector tables, UPDATE/DELETE/MERGE and OPTIMIZE "cannot conflict
>> ... unless ZORDER BY is used" [3]. A DML that loses to a compaction is
>> remapped too, not only the compaction. That's Case B: the one an in-memory
>> map can't cover, and the common shape when a streaming writer deletes while
>> another engine compacts.
>> 2. The persisted map is small. For compaction, each source file's remove
>> action carries compactedInto (the output file) and compactionInfo (the row
>> offset in the output and the source's physical row count). The losing side
>> replays a DV onto the output by offset, skipping the positions in the
>> source's own DV, which the same commit removes. That's a few numbers per
>> source, independent of how many rows are deleted, and resolution took about
>> 150 ms. The Iceberg equivalent would be (source file, source start, row
>> count, output file, output start), with one entry per output-file boundary.
>> Explicit gaps are only needed for rows dropped by equality deletes during
>> the scan.
>> 3. Where it lives: Delta keeps it on the tombstone, not in a side file.
>> The Iceberg equivalent is the source file's DELETED entry in the compaction
>> snapshot's manifest. RowDelta already reads that entry when it fails with
>> "Cannot commit, missing data files"
>> (MergingSnapshotProducer.validateDataFilesExist). So Case B finds the map
>> with no extra reads, the map commits atomically with the rewrite, and it
>> expires with the snapshot. It needs a manifest-entry field, which may fit
>> the v4 entry design.
>> 4. On Pachu's point about sort and z-order: equality deletes commute with
>> those rewrites too, while a position map grows toward one run per row under
>> a sort. Databricks doesn't use a bigger map there; it uses row tracking.
>> With row tracking on, liquid clustering OPTIMIZE (including real
>> reclustering and OPTIMIZE FULL) reconciled with concurrent
>> DELETE/UPDATE/MERGE in both directions. With it off, every such race
>> aborted. That path is slower: about 2-3 s versus ~150 ms. Iceberg v3
>> already requires row lineage, and a rewrite must copy each moved row's
>> _row_id into the new file (spec, Row Lineage), so the same approach needs
>> no opt-in. A position map for order-preserving rewrites plus a _row_id
>> lookup for sort/z-order would let DVs cover what equality deletes commute
>> with today.
>>
>> I'd be glad to work on the DML side: translating a RowDelta's DVs through
>> the persisted map during validation. It builds on #17754 and #18603, and
>> it's on the #18020 roadmap [4].
>>
>> Thanks,
>> EJ
>>
>> [1] https://github.com/delta-io/delta/issues/7360
>> [2] https://github.com/sezruby/delta/pull/9 (compaction loses),
>> https://github.com/sezruby/delta/pull/11 (DML loses),
>> https://github.com/sezruby/delta/pull/12 (persisting the source
>> composition)
>> [3]
>> https://docs.databricks.com/aws/en/optimizations/isolation/row-level-concurrency
>> [4] https://github.com/apache/iceberg/issues/18020
>>
>> On Fri, Nov 20, 2026 at 2:21 PM Pachu Shrinivas <
>> [email protected]> wrote:
>>
>> +1 - we have customers that rely on the commutative property of equality
>> deletes for their CDC ingest & compaction workflows - the compaction maps
>> idea is quite neat and I fully support adding it (something equivalent) to
>> the iceberg spec. I'm concerned that if v4 deprecates equality deletes with
>> such a solution it will prevent several customers from being to upgrade. We
>> don't want a python2 vs python3 situation on our hands!
>>
>> Thanks,
>> Pachu
>>
>> On Fri, Nov 20, 2026 at 3:41 PM Grant Nicholas <
>> [email protected]> wrote:
>>
>> Your doc mentions how equality deletes commute with compaction while
>> deletion vectors do not. I'm highlighting that with v4 deprecating equality
>> deletes, Iceberg loses the ability to issue deletes with minimal contention
>> against compaction. This especially affects low latency DELETE/UPSERT
>> workloads in Iceberg.
>>
>> I support persisted compaction maps before fully deprecating equality
>> deletes.
>>
>> On Fri, Nov 20, 2026 at 1:16 PM Anurag Mantripragada via dev <
>> [email protected]> wrote:
>>
>> Hi Shawn,
>>
>> This is great. I have been working on a similar proposal based on Chris's 
>> compaction
>> maps <https://cdouglas.github.io/posts/2026/08/compaction-maps> idea.
>> Compaction conflicts have been a major pain point for our large customers,
>> so I am glad we are addressing this.
>>
>> I will share my feedback on the design doc soon.
>>
>> ~ Anurag
>>
>>
>> On Fri, Nov 20, 2026 at 11:03 AM Shawn Chang <[email protected]>
>> wrote:
>>
>> Hi all,
>>
>> Today a compaction fails to commit if any other transaction added a
>> position delete to one of the files it rewrote while it was running. The
>> rewrite is a logical no-op, but RewriteFiles validation can't tell a layout
>> change from a row change, so minutes or hours of work are discarded and
>> retried due to conflicts. Under steady write + delete traffic on hot
>> partitions this happens repeatedly.
>>
>> I'd like to propose an improvement: the rewrite records how row positions
>> moved from source to output files, and at commit time translates any
>> concurrently committed deletion vectors onto the output files instead of
>> failing.
>>
>> The idea comes from Commutative Compaction (Douglas & Hellerstein,
>> FORMATS '26)[1]; Chris and I have been working through the design together.
>> I have a working Spark implementation with tests and benchmarks and would
>> like to open a PR once there is agreement on the direction.
>>
>> More details in the doc:
>> https://docs.google.com/document/d/1-8T316SMGNWIGzgid5hn0K6xj7hDDMRquleyuQrj3m8
>>
>> Would appreciate any feedback on the approach!
>>
>> Thanks,
>> Shawn
>>
>> [1] https://dl.acm.org/doi/10.1145/3802514.3809174
>>
>>
>>
>> --
>> Thanks,
>> Pachu
>>
>>
>>
>> --
>> Thanks,
>> Pachu
>>
>

Reply via email to