Skip to content

Validate snapshot sequence numbers on v3 tables - #4125

Merged
kevinjqliu merged 2 commits into
apache:mainfrom
porkedchop:fix/v3-snapshot-sequence-number-check
Oct 24, 2026
Merged

kevinjqliu merged 2 commits into
apache:mainfrom
porkedchop:fix/v3-snapshot-sequence-number-check

Conversation

@porkedchop

Copy link
Copy Markdown
Contributor

Rationale for this change

The AddSnapshotUpdate handler only rejects a snapshot whose sequence number is not newer than the table's last_sequence_number when the format version is exactly 2, so on v3 tables a snapshot with a stale sequence number is accepted. Java's TableMetadata.Builder.addSnapshot applies this check for every format version after 1, so this changes == 2 to >= 2.

Are these changes tested?

Yes, added test_add_snapshot_update_fails_with_stale_sequence_number, run against both the v2 and v3 table fixtures. The v3 case fails without the change.

Are there any user-facing changes?

Committing a snapshot with a stale sequence number to a v3 table now raises the same ValueError as on v2.

The check that rejects a snapshot whose sequence number is not greater
than the table's last sequence number only ran for format version 2.
Java applies it to every format version after 1.

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, great catch @porkedchop

@Fokko
Fokko added this pull request to the merge queue Oct 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 22, 2026
The stale sequence-number test built the snapshot from the fixture's
last_sequence_number but hardcoded 34 in the expected error message.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@kevinjqliu kevinjqliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great catch.

I pushed a nit change to parameterize the test error message just in case the test fixture changes in the future (e3cf96f)

@kevinjqliu
kevinjqliu enabled auto-merge October 24, 2026 22:29
@kevinjqliu
kevinjqliu added this pull request to the merge queue Oct 24, 2026
Merged via the queue into apache:main with commit 59b7c1c Oct 24, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants