Repository navigation
Assert every ref a transaction writes, not just the first - #4315
Merged
Merged
Conversation
Transaction._stage de-duplicated requirements by type, so a transaction writing two branches only sent AssertRefSnapshotId for the first one and a concurrent change to the second was overwritten. Key ref assertions by ref name so each ref keeps its base assertion, as Java does. Closes apache#4183
This was referenced Nov 9, 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 #4183
Rationale for this change
A transaction that writes two refs only guarded the first one against concurrent changes.
Transaction._stagede-duplicated requirements by type alone, so after the first write stagedAssertRefSnapshotId(ref="b"), the second write'sAssertRefSnapshotId(ref="main")was dropped andthe commit reached the catalog without an assertion on
main.The type-only de-duplication was correct when it was added (#569), because a transaction could only
ever assert
main. Writing to branches (#941) madeAssertRefSnapshotIdper-ref, but thede-duplication was never updated.
This changes the key to
(type, ref)forAssertRefSnapshotId. Each ref keeps its first (base)assertion, matching Java's
UpdateRequirements. Other requirement types are unchanged. Retries gothrough
_stagetoo, so they now keep every ref's assertion as well.Measured on a transaction that writes branch
band thenmain:main[1, 3][1, 2, 3, 4]ValueError(sequence number)[1, 2, 3, 4]Are these changes tested?
Yes. Two tests were added to
tests/table/test_commit_retry.py, and each runs against every catalogfixture:
test_transaction_writing_two_branches_detects_concurrent_change_to_eithercovers the issue'sscenario on format v1 and v2, with both a concurrent rollback and a concurrent append.
test_transaction_stages_one_ref_assertion_per_refchecks that writingband thenmaintwicestages exactly one assertion per ref, each holding the base snapshot id.
Both fail when the
_stagechange is reverted. Unit suite: 4524 → 4530 passed, no new failures.make lintis clean.make test-integrationpasses (1362 passed, 0 failed).Are there any user-facing changes?
Yes, as a bug fix. Multi-ref transactions now detect concurrent changes to every ref they write, and
retry or fail with
CommitFailedExceptioninstead of overwriting them. There is no API change.