Skip to content

feat: deduplicate keyed append commits - #11411

Merged
Xuanwo merged 3 commits into
mainfrom
xuanwo/ent-4276-append-idempotency
Nov 24, 2026
Merged

Xuanwo merged 3 commits into
mainfrom
xuanwo/ent-4276-append-idempotency

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

An append retry can reach manifest publication after another writer has committed the same logical append. Both writers can otherwise rebase and commit, leaving duplicate rows.

The Lance Rust crate adds CommitBuilder::with_append_idempotency_property for individual appends to an existing branch. The caller supplies the property in the transaction and reuses its value and original read version on every submission. The first committed append wins. A duplicate returns the winning version through Error::append_already_committed_version() without publishing a new version. A history gap prevents a keyed append when the winner cannot be established.

The commit loop checks transactions directly from the published manifests so that a session reused after table recreation sees the current table's keys. It also checks a winning manifest after a commit collision, including when no retries remain. Keyed attempts use separate transaction files so a replay can submit the same transaction without sharing the winner's file.

@claude claude Bot 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 23, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 23, 2026

@lance-gatekeeper lance-gatekeeper Bot 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.

✅ Gate recommendation: approve.

The first-writer-wins append contract is supported, including concurrent replays, ambiguous commit outcomes, and session reuse after recreating a table at the same URI.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 23, 2026
@Xuanwo
Xuanwo merged commit fe4c0c4 into main Nov 24, 2026
43 of 51 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/ent-4276-append-idempotency branch November 24, 2026 05:33
westonpace added a commit that referenced this pull request Dec 1, 2026
## Summary

Transaction files were named `<read_version>-<transaction.uuid>.txn`, so
submitting an already-committed transaction again (for example, a retry
after an ambiguous timeout) wrote to the committed version's transaction
file. If that attempt then failed, its cleanup deleted the file, and
reading that version's transaction or catching up past it failed with
`NotFound`. Keyed appends (#11411) already used a fresh per-attempt id;
this makes every transaction file use one. Readers find the file through
`manifest.transaction_file` and never parse the name.

## Evidence

Two regressions in `commit::tests`, both failing before this change and
passing after:

- `failed_resubmission_keeps_committed_transaction_file` commits an
append, resubmits it with a commit handler that conflicts, and asserts
the committed version's transaction file still exists on disk.
- `failed_resubmission_keeps_spilled_transaction` (attached and
detached) does the same against a transaction too large to inline, so
the committed version is readable only through its transaction file. It
asserts the recorded transaction still reads back and that a stale
attached writer can catch up past the committed version. Both cases fail
with `NotFound` without the fix.

## Merge Risk

**Door:** two-way. The name still matches the documented
`{read_version}-{uuid}.txn` pattern; only the UUID's source changes.
**Blast Radius:** commit path.

## Validation

- `cargo test --profile ci -p lance-table-runtime --lib --features
tokio/test-util`: 575 passed.
- `cargo fmt --all --check`.
- `cargo clippy -p lance-table-runtime --all-targets`: no warnings in
this crate. (`-D warnings` trips on two pre-existing dead-code items in
`lance-io`, untouched here.)

Fixes #11656

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Weston Pace <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants