Skip to content

fix: let started commits finish after the retry timeout - #11378

Closed
lance-gatefixer[bot] wants to merge 2 commits into
mainfrom
gatekeeper/fix-11374-1
Closed

lance-gatefixer[bot] wants to merge 2 commits into
mainfrom
gatekeeper/fix-11374-1

Conversation

@lance-gatefixer

@lance-gatefixer lance-gatefixer Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

After a non-rebasable conflict, execute_with_retry wrapped the commit future in maybe_timeout. Expiring the retry deadline could drop that future after its manifest was published and report TooMuchWriteContention, causing callers to retry a successful write.

Check the retry budget before starting a retry's commit, then await its actual outcome. Execution and backoff retain their timeouts. Started commits may finish after retry_timeout; the update, delete, and merge-insert builder docs now explain this behavior.

The regression injects one conflict, commits a deletion across two fragments, and delays the response beyond the deadline. It reproduces the false failure on the original code and passes with the fix. A companion case checks that slow execution still times out before committing.

Validation:

  • cargo test -p lance --lib dataset::write::retry::tests — 2 passed.
  • cargo test -p lance --lib -- test_update_concurrency test_update_same_row_concurrency test_delete_concurrency test_concurrent_delete_with_retries test_merge_insert_concurrency test_commit_retry_timeout_interrupts_conflict_backoff — 14 passed.
  • cargo fmt --all
  • cargo clippy --all --tests --benches -- -D warnings

Fixes #11374

Change walkthrough

flowchart TD
    A["Execute retry with timeout"] --> B{"Retry deadline expired?"}
    B -->|Yes| C["Return timeout"]
    B -->|No| D["Await commit outcome"]
    D -->|Success| E["Return success"]
    D -->|Retryable conflict| F["Check budget and backoff"]
    F --> A
Loading

The shared runtime lets a started commit finish after the retry budget expires.

Read: Retry deadline and commit boundary → Delayed commit regression.

Snapshot: 37f6299

@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 bug Something isn't working label Nov 23, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 23, 2026
Preserve the commit timeout fix in the shared table runtime and adapt the dataset regression tests to the generic retry executor.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 24, 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.

Awaiting a started commit's outcome fixes the false contention result described in #11374 while preserving the retry budget for execution and backoff. The shared-runtime port preserves this behavior for update, delete, and merge-insert.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 24, 2026
vaibhavdabas16 added a commit to vaibhavdabas16/lance that referenced this pull request Nov 24, 2026
execute_with_retry wrapped each retried commit in the retry deadline.
If the deadline fired after the manifest was written, the commit was
dropped and the caller got TooMuchWriteContention for a write that had
landed, so retrying a non-idempotent update applied it twice.

Check the deadline before starting a commit instead, and let a started
commit finish. Execution and backoff keep the deadline.

The regression test is adapted from lance-format#11378's paused-clock test.

Fixes lance-format#11374
Xuanwo pushed a commit that referenced this pull request Nov 24, 2026
Fixes #11374.

`execute_with_retry` wrapped every commit after the first in the
remaining `retry_timeout` (`maybe_timeout`). If the deadline fired after
the new manifest had been stored but before the commit returned, the
future was dropped. The caller then got `TooMuchWriteContention` for a
write that had already landed. Retrying a non-idempotent update (`n = n
+ 1`) applied it twice.

This takes the first fix suggested in the issue, in
`lance-table-runtime/src/commit/retry.rs`, where #11449 moved the
function:

- The deadline is checked before an attempt's commit starts, never
around it. A started commit runs to completion and its real result is
returned.
- The commit stays bounded by its own retry limits in
`commit_transaction`, which already verify an ambiguous outcome.
- `execute_impl` and the backoff sleep keep their deadline, since
cancelling them has no committed side effects.
- The `retry_timeout` docs on `UpdateBuilder`, `DeleteBuilder` and
`MergeInsertBuilder` now say a started commit finishes.

**Test:** `test_retry_timeout_respects_commit_boundary` is adapted from
#11378's paused-clock test. It uses real manifest publication and covers
two cases:
- `after_commit`: the retry publishes a delete, then returns after the
deadline. It is reported as a success and the version is visible.
- `during_execution`: the retry stalls in execution past the deadline,
gets `TooMuchWriteContention`, and nothing is committed.

**Checks run locally:**
- `cargo test -p lance-table-runtime --lib -- retry`: 11 passed.
- `cargo test -p lance --lib -- write::retry
merge_insert::tests::concurrency retry_timeout`: 34 passed.
- `cargo fmt` passes.
- I didn't run clippy for the `lance` crate locally because of build
resources on my machine.
@Xuanwo

Xuanwo commented Nov 24, 2026

Copy link
Copy Markdown
Member

Closing in favor of #11379, which merged the same fix and adapted the test from this PR. Thanks!

@Xuanwo Xuanwo closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: update / delete / merge_insert can raise TooMuchWriteContention after their commit has landed (retry_timeout cancels the commit future)

1 participant