feat(table): drop dangling equality deletes during RewriteDataFiles#947
Merged
zeroshade merged 2 commits intoApr 30, 2026
Merged
Conversation
Closes apache#946. Sustained CDC workloads (Postgres → Iceberg replication, ~one snapshot per few seconds with one eq-delete per UPDATE/DELETE) accumulate equality-delete files in every snapshot's manifests forever. After compaction, every preexisting eq-delete is provably dead — no surviving applicable data file has seq < eq-delete.seq — but the old RewriteDataFiles only removed position deletes, leaving eq-deletes in place. Manifest fanout grew linearly with the CDC duration. This change adds three pieces: 1. table/compaction.DecideDeadEqualityDeletes — a pure predicate that exactly matches the v2 reader (table/scanner.go matchEqualityDeletesToData): E applies to D iff E.seq > D.seq AND (either side has empty partition OR partition tuples match). SpecID is intentionally NOT in the predicate — using it would silently drop eq-deletes the reader still applies under partition-spec evolution. 2. table/compaction.CollectDeadEqualityDeletes — walks the snapshot's manifests via the existing public Snapshot.Manifests + FetchEntries APIs, builds a SurvivorSurvey, and returns the dead set. Two-pass design: skip the data-manifest walk if there are no eq-delete candidates. 3. table.RewriteDataFilesOptions.ExtraDeleteFilesToRemove — a new field on the options struct that the executor passes through to ReplaceFiles. The caller (cmd/iceberg/compact.go or any library user) computes dead eq-deletes via CollectDeadEqualityDeletes against the same snapshot and threads them in. The executor itself is policy-free. The CLI gains a --preserve-dead-equality-deletes flag (default off, i.e., cleanup is on by default — recommended for sustained CDC). The RewriteDataFiles signature collapses (partialProgress, snapshotProps, opts...) into a single RewriteDataFilesOptions struct. RewriteResult splits RemovedDeleteFiles into RemovedPositionDeleteFiles + RemovedEqualityDeleteFiles for observability. Tests: - table/compaction/eq_delete_decision_test.go pins the predicate against the scanner's rule across mixed-partition / cross-spec / boundary cases. - table/compaction/cdc_stress_test.go runs 80 CDC cycles (81 data files + 80 eq-deletes pre-compaction → 1 data file + 0 eq-deletes post). Skipped under -short. - table/rewrite_data_files_test.go covers full-rewrite drops, partial-rewrite preserves, partial-progress preserves (per-group cleanup is a follow-up), and the CLI opt-out path.
zeroshade
requested changes
Apr 29, 2026
- eq_delete_collect.go: drop manual EntryStatusDELETED filter, pass discardDeleted=true to FetchEntries - eq_delete_decision.go: use min builtin in AddSurvivor and applicableMinSeq; consolidate nil/empty guards - rewrite_data_files.go: bracket-link doc references so pkg.go.dev cross-links them
zeroshade
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #946.
Sustained CDC workloads (Postgres → Iceberg replication, ~one snapshot per few seconds with one eq-delete per UPDATE/DELETE) accumulate equality-delete files in every snapshot's manifests forever. After compaction, every preexisting eq-delete is provably dead — no surviving applicable data file has seq < eq-delete.seq — but the old RewriteDataFiles only removed position deletes, leaving eq-deletes in place. Manifest fanout grew linearly with the CDC duration.
This change adds three pieces:
table/compaction.DecideDeadEqualityDeletes — a pure predicate that exactly matches the v2 reader (table/scanner.go matchEqualityDeletesToData): E applies to D iff E.seq > D.seq AND (either side has empty partition OR partition tuples match). SpecID is intentionally NOT in the predicate — using it would silently drop eq-deletes the reader still applies under partition-spec evolution.
table/compaction.CollectDeadEqualityDeletes — walks the snapshot's manifests via the existing public Snapshot.Manifests + FetchEntries APIs, builds a SurvivorSurvey, and returns the dead set. Two-pass design: skip the data-manifest walk if there are no eq-delete candidates.
table.RewriteDataFilesOptions.ExtraDeleteFilesToRemove — a new field on the options struct that the executor passes through to ReplaceFiles. The caller (cmd/iceberg/compact.go or any library user) computes dead eq-deletes via CollectDeadEqualityDeletes against the same snapshot and threads them in. The executor itself is policy-free.
The CLI gains a --preserve-dead-equality-deletes flag (default off, i.e., cleanup is on by default — recommended for sustained CDC).
The RewriteDataFiles signature collapses (partialProgress, snapshotProps, opts...) into a single RewriteDataFilesOptions struct. RewriteResult splits RemovedDeleteFiles into RemovedPositionDeleteFiles + RemovedEqualityDeleteFiles for observability.
Tests: