Skip to content

Core: Add AssertLastSequenceNumber in UpdateRequirements for addSnapshot - #15002

Closed
agnes-xinyi-lu wants to merge 3 commits into
apache:mainfrom
agnes-xinyi-lu:xinyilu/fix
Closed

agnes-xinyi-lu wants to merge 3 commits into
apache:mainfrom
agnes-xinyi-lu:xinyilu/fix

Conversation

@agnes-xinyi-lu

@agnes-xinyi-lu agnes-xinyi-lu commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

This PR aims to fix the concurrent commit race condition problem in Rest Catalog.
Details in issue #15001

Files Changed:

UpdateRequirement.java - Added new AssertLastSequenceNumber class:

  • Validates that the table's last sequence number hasn't changed since the snapshot was created
  • Throws CommitFailedException (retryable) on conflict instead of ValidationException
  • Only validates for format version 2+ tables with parent snapshots
    UpdateRequirementParser.java - Added serialization/deserialization support:
  • Registered assert-last-sequence-number requirement type
  • Added JSON read/write methods for the new requirement
    UpdateRequirements.java - Integrated the new requirement:
  • Automatically adds AssertLastSequenceNumber when processing AddSnapshot metadata updates
  • Only added for existing table updates (base != null), not for table creation
    TestRestCatalogConcurrentWrites.java - Added test to verify the fix:
  • Creates 5 branches with 10 concurrent commits each (50 total operations)
  • Asserts that validation failures are 0 (all conflicts are now CommitFailedException)

…tion tests

    The integration tests use the apache/iceberg-rest-fixture Docker image which
    is pre-built and published to Docker Hub. When changes are made to the REST
    API (e.g., adding new UpdateRequirement types), the tests fail because the
    Docker image doesn't have the updated code.

    This change builds the Docker image locally before running integration tests,
    ensuring the tests always use the latest code from the PR.
@RussellSpitzer

Copy link
Copy Markdown
Member

Can you link to the ML thread for the Spec Change?

@agnes-xinyi-lu

Copy link
Copy Markdown
Contributor Author

@RussellSpitzer Thanks for taking a look! I haven't started the thread for spec change yet, wanted to gather community experts' opinions on whether this is the right way to solve this problem #15001 before getting into the details of what this requirement looks like in the spec. I'll start a mail thread next week.

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants