There's another thread ([DISCUSS] Kafka Connect CDC writes without equality deletes) where Koodin ran some experiments to measure writer vs. compaction conflicts. Summarizing here (with some commentary)
Summary: 1. A compaction fails when the connector commits a DV to one of its files while it runs. For files updated on every commit, it succeeds with a chance of about 1 - rewrite time / commit interval, so Pachu's concern holds there. (if compaction rewrite time exceeds the writer commit interval, it basically never succeeds :/) 2. A compaction succeeds when the connector does not update its files in the meantime. When the updates stay in recent data, a compaction that skips those files, for example with a filter on the recent partitions, avoids the conflict on both sides. 3. When the updates are spread over the table, the connector cannot avoid it. That needs something like the compaction repair Pachu linked, a spec change separate from #18003. #18003 does not block it, because the connector commits ordinary DVs. (for context, #18003 is the Kafka Connect equivalent of Flink's eq-delete-to-DV-converter) 4. The connector also converts again when a compaction replaces a file during its conversion. This grows with the conversion time, so a retry should redo only what the compaction changed. (this would be phase 2 that Anurag proposed) I'll try to prototype the Phase 1 approach (in-memory map for bin-pack, row lineage for sort/z-order) in Trino so we have some sense of the performance. Thanks! Pachu On Thu, Dec 3, 2026 at 3:10 PM Anurag Mantripragada via dev < [email protected]> wrote: > Hi all, > > Thanks, Huaxin, for laying out the three kinds of DV conflicts. > > For Phase 2, concurrent compaction against DELETE/UPDATE, I explored a > way to do this without persisting a map. > > EJ mentioned that Delta resolves these conflicts in both directions > <https://github.com/delta-io/delta/issues/7360>, and uses row tracking > for rewrites that reorder rows. I tried the same approach on Iceberg using > v3 row lineage, and I think it can cover Phase 2 without a spec change. > > V3 already requires a rewrite to copy each row's _row_id into the new > file. So when a compaction replaces a file, a DELETE planned against the > old file can find its rows again by ID. It reads _row_id from the files the > compaction added, writes DVs for those files, and validates again from the > compaction's snapshot. I wrote a small Spark 4.2 test against main > <https://github.com/anuragmantri/iceberg/blob/row-lineage-translation-poc/spark/v4.2/spark/src/test/java/org/apache/iceberg/spark/actions/TestRowLineageDeleteTranslation.java> > to check this. It works after bin-pack, sort and z-order compactions. I > haven't measured performance yet, though. Translation would run before the > checks in #17754 <https://github.com/apache/iceberg/pull/17754> and #18603 > <https://github.com/apache/iceberg/pull/18603>, so those still apply to > the compaction's output files. > > On Amogh's suggestion, +1 to re-plan and retry each file group in Spark > first. It's an implementation change that can start right away. The > row-lineage work is independent of it, though. Re-plan and retry shrinks > the compaction's window, but it can't help when a delete lands during a > rewrite, and it doesn't help a DML that commits after a compaction. Both of > those still need translation, so the two can be done in parallel. > > For this proposal, here is what I suggest we proceed with: > > - For Phase 1, when the compaction commits second, we use an in-memory > map for bin-pack, and maybe row lineage for sort, z-order and sorted > tables, where a map doesn't stay small. > - For Phase 2, when the DML commits second, the DML translates its DVs > by _row_id during RowDelta validation, with no spec change. If that isn't > fast enough, we can look at persisting the maps and changing the spec. > - We measure both with the metrics Amogh listed, and add DML commit > success rate and wasted DML work. > > I connected with Shwan about this. If you all agree with this plan, we can > update the design doc. > > Thanks, > Anurag > >> -- Thanks, Pachu
