Skip to content

fix: check if previous commit attempt succeeded before retrying transaction - #3744

Open
hcrosse wants to merge 2 commits into
apache:mainfrom
hcrosse:fix-commit-check-status
Open

hcrosse wants to merge 2 commits into
apache:mainfrom
hcrosse:fix-commit-check-status

Conversation

@hcrosse

@hcrosse hcrosse commented Nov 21, 2026

Copy link
Copy Markdown

Which issue does this PR close?

What changes are included in this PR?

  • Track newly added (snapshot_id, manifest_list) witnesses submitted in prior commit attempts on Transaction, filtering out empty manifest lists, snapshots already present in the base metadata, and snapshots removed within the same transaction.
  • In Transaction::do_commit, right after catalog.load_table, return Ok(refreshed) if any recorded (snapshot_id, manifest_list) witness already exists in refreshed.metadata() with a matching manifest list path. Because each TableCommit is atomic on the catalog, any surviving witness confirms the attempt landed even if a concurrent writer committed on top or expired another snapshot from a multi snapshot commit, and retaining witnesses across attempts handles transient load_table errors and delayed earlier attempts.
  • Terminal and non retryable unknown state failures (such as REST 500/502/504 responses or exhausted retry budgets) keep their existing behavior and are left outside the scope of this PR.

Are these changes tested?

Yes. Added unit tests in crates/iceberg/src/transaction/mod.rs covering post commit retryable conflicts with duplicate checking enabled and disabled (verifying no orphan manifest list is written via FileIO::exists), concurrent commits landing on top of the committed snapshot, genuine pre commit conflicts, delayed first attempts landing after a second attempt, partial expiration of a multi snapshot commit, transient load_table failures between attempts, and a negative check ensuring a matching snapshot ID with a different manifest list is not treated as committed.

AI Disclosure

I used AI coding tools to help draft the code, tests, and this description. I reviewed the changes, ran the test and lint checks, and can explain the design.

@hcrosse
hcrosse marked this pull request as ready for review November 21, 2026 13:19
Copilot AI balanced review requested due to automatic review settings November 21, 2026 13:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the transaction retry changes.

No open issues 🎉

What changed in this PR

Addresses #3743 by letting transaction retries recognize a previously successful commit, avoiding repeated actions and unnecessary manifest writes after a lost response.

Changes:

  • Retains snapshot IDs and manifest-list paths from prior commit attempts.
  • Checks refreshed metadata for a matching snapshot before reapplying actions.
  • Adds regression tests for retry conflicts, concurrent writes, delayed commits, snapshot expiration, and transient refresh failures.

The PR description could be shortened by focusing on rationale and assumptions rather than implementation details.

File Description
crates/​iceberg/​src/​transaction/​mod.rs Adds prior-commit detection and regression tests for transaction retries.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

Transaction::do_commit fails on retry after a previous attempt already committed

2 participants