Skip to content

fix(commit): answer a snapshot built on outdated table metadata with 409 - #2218

Merged
c-thiel merged 2 commits into
mainfrom
ct/commit-stale-snapshot-409
Nov 2, 2026
Merged

c-thiel merged 2 commits into
mainfrom
ct/commit-stale-snapshot-409

Conversation

@c-thiel

@c-thiel c-thiel commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

A commit whose snapshot uses a sequence number or first row ID that another commit has already used now answers 409 CommitFailedException instead of 400. This happens when writers commit to different branches of one table, or when a staged (WAP) write and another commit to the same table run at the same time. Spark, Flink, Kafka Connect, PyIceberg 0.12 and iceberg-rust then reload the table and retry; before, the write failed.

This is the behaviour of Iceberg Java's reference server since 1.11 (apache/iceberg#15126) and of Polaris. The iceberg-rust fork marks exactly these two builder errors as retryable conflicts (lakekeeper/iceberg-rust#17), and Lakekeeper answers a retryable builder error with 409.

Unchanged: a resend of a snapshot that already landed answers 400; every other refused update answers 400; errors from building the new metadata keep 409.

Release notes

  • Concurrent writes to branches and staged (WAP) writes. When writers commit to different branches of one table, or a staged (WAP) write and another commit to the same table run at the same time, the writer that loses the race gets a 409 error, which it retries. Before, it got a 400 error and the write failed. This matches Iceberg Java 1.11.

Downstream follow-up

Lakekeeper Plus pins iceberg directly and must move to the same iceberg-rust rev in the same step. A manifest rewrite planned on a format v1 table that was upgraded to v2 before the commit now gets a retryable conflict, re-plans on v2 and commits in the same run, as with Java 1.11; the Plus test that expects the run to fail must change at that bump.

Summary by CodeRabbit

  • Bug Fixes
    • Table commits with stale sequence numbers or overlapping snapshots now return a conflict response, making it clearer when a commit must be retried.
    • Invalid table updates continue to return an invalid-update response rather than being reported as retryable conflicts.
    • Improved conflict handling for commits involving snapshots on different branches, including parentless snapshots.

A snapshot whose sequence number or first-row-id another commit has already used, for example a commit to another branch or a staged (WAP) snapshot racing a writer, now answers 409 CommitFailedException. The client reloads the table and retries. Before, the commit answered 400 InvalidTableUpdate and the job failed. This matches Iceberg Java's reference server since 1.11. Every other refused update keeps 400, and build errors keep 409.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e89ce58f-5782-40b9-ac3d-9d87b1641b2e
Commits

Reviewing files that changed from the base of the PR and between f70a047 and 29699be.

Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 3
  • Cargo.toml
  • crates/lakekeeper-integration-tests/tests/server_tables_postgres.rs
  • crates/lakekeeper/src/server/commit_tables.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

Commit update errors now map to 409 CommitFailedException when retryable and 400 InvalidTableUpdate otherwise. Unit and integration tests cover stale snapshot values, resent snapshots, and successful retries. The workspace Iceberg dependency revision also changes.

Changes

Commit conflict responses

Layer / File(s) Summary
Commit update error mapping
Cargo.toml, crates/lakekeeper/src/server/commit_tables.rs
The workspace Iceberg revision changes. apply_commit maps retryable builder update errors to 409 CommitFailedException and non-retryable errors to 400 InvalidTableUpdate.
Commit conflict tests
crates/lakekeeper/src/server/commit_tables.rs, crates/lakekeeper-integration-tests/tests/server_tables_postgres.rs
Tests check conflicts for stale sequence numbers and v3 first-row IDs, invalid updates for resent snapshots, and successful retries with updated values. The integration tests also check the conflict response and sequence number after retry.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: jankaul

Merge Risk: Minimal · up to 29699

Stale snapshot conflicts are set to return a retryable response, while refused updates retain their existing response. No issue requiring a change before merge was identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: stale-snapshot commits now return 409 CommitFailedException instead of 400. The changeset matches this. The Cargo.toml bump, the integration tests, and commit_tables.r…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: stale-snapshot commits now return 409 CommitFailedException instead of 400. The changeset matches this. The Cargo.toml bump, the integration tests, and commit_tables.rs all implement the 409 response for snapshots built on outdated metadata. The title uses the conventional commit form and stays within one line. It does not list files or use vague terms.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the snapshot trail,
Stale numbers meet a conflict tale.
Fresh values pass the retry gate,
The current snapshot updates straight.
Then hops away, content and bright.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel
c-thiel merged commit 6ccb8b5 into main Nov 2, 2026
87 of 89 checks passed
@c-thiel
c-thiel deleted the ct/commit-stale-snapshot-409 branch November 2, 2026 23:15
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.

1 participant