Repository navigation
Description
Apache Iceberg version
1.6.1
Query engine
Spark
Please describe the bug 🐞
Problem
When multiple processes commit to different branches(or writing to different waps) of the same Iceberg table concurrently through the REST catalog, some commits fail with a non-retryable ValidationException when building TableMetadata on the server side and calling addSnapshot:
Cannot add snapshot with sequence number X older than last sequence number X
Instead of CommitFailedException, this error is non-retryable , bypassing automatic retries and wasting compute resources.
Repro in unit test.
Root Cause
- All the snapshots share a global sequence number counter at the table level, but we don't add extra requirements for such addSnapshot to guarantee snapshotId>last sequence number.
- When a commit reaches TableMetadata.addSnapshot(), it fails validation because another concurrent commit to a different branch already incremented the global sequence number
- This validation failure occurs after the requirement checks (because there is no check) pass, so it's thrown as ValidationException rather than CommitFailedException
Relevant work
Previously in OSS there was similar issue with replace table, which was fixed/mitigated by checking if the snapshot has a parent. But in this case it's a normal table update, and we probably don't want to bypass the check because we want to maintain the order of all snapshots through the global sequence number.
Proposed Solution:
(Note that we need to update the Rest Spec for the requirement)
Added a new AssertLastSequenceNumber update requirement that validates sequence number conflicts before the commit is applied.
Proposed PR #15002
Behavior After Fix
- Sequence number conflicts are caught early by AssertLastSequenceNumber requirement
- Conflicts throw CommitFailedException which triggers automatic client-side retries
- Concurrent commits to different branches eventually succeed through the retry mechanism
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time
Activity
agnes-xinyi-lu commentedon Jan 8, 2026
cc @edgarRd @Parth-Brahmbhatt @rdblue
rdblue commentedon Jan 22, 2026
I think the error described here makes sense. A sequence number conflict should trigger a retry. The REST catalog service should be sending back a
CommitFailedExceptionrather than theValidationException. I think the question is how best to do that.We could add a validation that is triggered by adding a snapshot, but that would be more specific than the checks that are happening in
addSnapshot. Right now, a snapshot can use a future sequence number to avoid a retry like this and the last sequence number in metadata is increased to match it. Using an assertion would require a failure and retry even if metadata were still valid. In addition, we would have the same problem fornext-row-idthat is also validated for v3 tables and later, so we would also require an assertion forlast-row-idand anything similar.On the other hand,
MetadataUpdate#applyTois also called in the retryable block. So we could also wrap validation exceptions fromaddSnapshotinCommitFailedException. Or we could introduce aRetryableValidationExceptionto more narrowly target the validation exceptions that can be retried and wrapped byCommitFailedException. I think I'd prefer this exception wrapping solution. It's pretty narrow and doesn't require adding new requirements to the spec.agnes-xinyi-lu commentedon Jan 23, 2026
Thanks @rdblue , just sent a PR #15126 implementing one of your suggestions in the comment. Please help take a look! Thank you!
github-actions commentedon Jul 23, 2026
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
Retry the stale-sequence 400 of commits raced by another branch