Repository navigation
Conversation
Collaborator
Author
|
R: @ahmedabu98 |
Contributor
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
A CDC read reported a DELETE a second time when a snapshot added a position delete or a deletion vector for a row that an earlier snapshot had already deleted. On format v3 tables this happened on every later delete in the same data file, because a new deletion vector repeats the positions of the one it replaces. On format v2 tables it happened when a writer merged a data file's position deletes into a new file, as Spark does with file-granularity deletes. Next to a merge-on-read update, the repeated row came out as an extra DELETE. The changelog scan read a snapshot's added deletes against the deletes committed before it only when the snapshot added equality deletes. Do it for added deletes of any kind. Those earlier deletes come from the snapshot before the scanned range, and table maintenance may have expired it. The scan then failed with "Cannot find starting snapshot". That already happened for snapshots that add equality deletes or remove a data file, and would now have happened for every snapshot that adds deletes. Log a warning instead and read the snapshot without the earlier deletes, so it may report a row as deleted again. A scan over several snapshots, which the source does not use but the public scan class allows, kept the delete files that a snapshot in the range removed when it read later snapshots. A replaced deletion vector then sat next to its replacement and planning failed with "Can't index multiple DVs". Drop them, as the planning of removed data files already did, and match removed files as Iceberg does, by location, content offset and size, because deletion vectors can share a Puffin file. The tests cover a position delete after an equality delete or after another position delete of the same row, successive deletion vectors alone and in merge-on-read updates through both resolve paths, a v2 position delete file that replaces an earlier one, an identity- partitioned v3 table, a v2 table upgraded to v3, a deletion vector and a file deletion whose parent snapshot has expired, and a scan over several snapshots.
claudevdm
force-pushed
the
iceberg-fix-cdc-earlier-deletes
branch
from
December 5, 2026 16:15
aa19915 to
3ae4bf4
Compare
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.
A CDC read (
IcebergIO.readRows(...).withCdc()or ManagedICEBERG_CDC) reports a DELETE a second time when a snapshot adds a position delete or a deletion vector that covers a row an earlier snapshot already deleted. Nothing fails: the change stream just says the row was deleted again.The usual way to hit it is a second merge-on-read delete in the same data file:
Example (v3): a data file holds ids 1 and 2. An UPDATE of id 1 writes the deletion vector
{0}and the new row; an UPDATE of id 2 writes{0, 1}and its new row. The second snapshot should giveUPDATE_BEFORE (2, a)andUPDATE_AFTER (2, b). It also givesDELETE (1, a), so a consumer applying the stream by key would delete id 1, which is still in the table.Cause.
BeamBaseIncrementalChangelogScangives aDeletedRowsScanTaskthe deletes committed before its snapshot (existingDeletes) only when the snapshot adds equality deletes. The reader drops the rowsexistingDeletesremove before it reports the rows the added deletes remove, so for position deletes and deletion vectors nothing was dropped.Fix. Load the earlier deletes whenever a snapshot adds row-level deletes of any kind. The reader needs no change.