Repository navigation
Fail a retried upsert instead of inserting a concurrently inserted key - #4392
Open
Anurag-S1ngh wants to merge 3 commits into
Open
Anurag-S1ngh wants to merge 3 commits into
Anurag-S1ngh wants to merge 3 commits into
Conversation
A commit retry replays the append that was planned before the concurrent commit, and the fast append producer skips concurrency validation, so a key another writer inserted after the upsert read ends up inserted twice. Record the filter for the rows an upsert inserts on the append producer and validate the files added since the starting snapshot against it when the commit is rebuilt for a retry. The upsert now fails with a CommitFailedException instead of leaving a duplicate key.
Fokko
reviewed
Nov 17, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Thanks for picking this up, the approach of validating the added data files against the inserted keys on retry looks right to me. A few comments inline.
Address the review feedback on the upsert retry check: - Gate the check on write.update.isolation-level, so both halves of an upsert follow the same isolation setting. - Let the ValidationException propagate instead of converting it to a CommitFailedException, matching the update half. - Drop the private Transaction.append arguments and let upsert configure the append producer through validate_no_conflicting_data. The filter's case sensitivity is stored on the producer instead of overwriting its inherited value.
Fokko
self-requested a review
November 17, 2026 20:46
Fokko
reviewed
Nov 17, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Thanks @Anurag-S1ngh, nice catch and a clean fix! The second commit addressing the isolation level gating and letting the ValidationException propagate reads well.
I pulled the branch and ran tests/table/test_upsert.py locally, all 29 pass, and CI is green.
A couple of small things, none blocking:
pyiceberg/table/update/snapshot.py:695:validate_no_conflicting_dataonly stores the filter, the actual check runs in_validate_concurrencyon retry. Maybe worth a docstring line saying the validation happens at commit/retry time, so callers don't expect an exception from the call itself.pyiceberg/table/update/snapshot.py:693: the class level defaults on_FastAppendFilesmean a producer that never callsvalidate_no_conflicting_datakeeps skipping validation, which is what plain appends want. Good.- The snapshot isolation test documenting that the duplicate can still land under
write.update.isolation-level=snapshotis a nice touch, that makes the semantics explicit.
LGTM once CI stays green!
Fokko
reviewed
Nov 19, 2026
This branch has not been deployed
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
A commit retry replays the append planned before the concurrent commit. The fast append producer skips concurrency validation, so a key another writer inserted after the upsert read was inserted a second time.
Changes
CommitFailedExceptioninstead of inserting a duplicate key.Testing
make testpasses (4697 passed, 5 skipped).Closes #4194