Validate replaced data files during commit retries - #3811
Open
kevinjqliu wants to merge 6 commits into
Open
Conversation
kevinjqliu
marked this pull request as ready for review
August 19, 2026 06:32
kevinjqliu
requested review from
Fokko and
geruh
and
a lite review from Copilot
August 19, 2026 06:32
Contributor
There was a problem hiding this comment.
Pull request overview
Adds commit-retry validation to prevent an overwrite that explicitly replaces a data file from succeeding if the replaced (target) file was concurrently deleted by another transaction, avoiding resurrecting data from a removed file.
Changes:
- Add
_validate_data_files_existto detect concurrent deletions of explicitly targeted/replaced data files during the retry validation window. - Wire the new validation into snapshot concurrency validation when a commit has specific deleted/replaced data files tracked.
- Add a regression test covering conflicting and non-conflicting concurrent deletions (same file, different file same partition, different partition) across all catalog fixtures.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pyiceberg/table/update/validate.py |
Adds validation to detect concurrent deletion of specific required/replaced data files. |
pyiceberg/table/update/snapshot.py |
Invokes the new validation during concurrency checks when explicit deleted/replaced files are present. |
tests/table/test_commit_retry.py |
Adds regression coverage for overwrite retries with concurrent data-file deletions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
Follow-up to #3780.
Why this validation is needed
Suppose transaction A is replacing data file
Fwith a newly written fileF2. Before A commits, transaction B deletesFand commits. A then refreshes the table and retries its commit.The retry must fail. If A commits
F2, it puts data derived fromFback into the table and can undo B's deletion.The existing checks do not catch this case:
delete_data_file(F)records a specific file, not a row predicate, so predicate-based deleted-file validation has nothing to match._validate_no_new_deletes_for_data_fileschecks newly added position or equality delete files. Transaction B removed a data file instead._validate_data_files_existprovides the missing check: before retrying, verify that every file being replaced is still present. The scan is narrowed by spec and partition, but only an exact file match causes a conflict.Scenarios tested
All three cases are covered by
test_file_overwrite_validates_concurrent_file_deleteand run against all three catalog fixtures.Java alignment
Iceberg Java handles the same concerns separately:
failMissingDeletePathsrequires an overwrite's target files to still exist.validateDataFilesExistchecks exact required file paths against concurrent data-file removals.validateNoNewDeletesForDataFilesseparately checks newly added row-level delete files.Java also tests unrelated concurrent deletion succeeding and target-file deletion failing.
Tests