Skip to content

feat: clean up transaction files on failed commits#6319

Open
wjones127 wants to merge 2 commits intolance-format:mainfrom
wjones127:feat/cleanup-txn-files
Open

feat: clean up transaction files on failed commits#6319
wjones127 wants to merge 2 commits intolance-format:mainfrom
wjones127:feat/cleanup-txn-files

Conversation

@wjones127
Copy link
Copy Markdown
Contributor

Previously, when a manifest commit failed (conflict, error, or retry exhaustion), the .txn file written to _transactions/ was left orphaned. These files would accumulate until the GC cleanup interval (7+ days by default).

This PR adds cleanup_transaction_file() — a best-effort delete helper — and calls it from all three commit failure paths (do_commit_new_dataset, do_commit_detached_transaction, commit_transaction). Failures to delete are logged as warnings and do not surface to the caller.

In the retry loop of commit_transaction, the previous iteration's transaction file is cleaned up before each retry attempt, since a new transaction file is written on each iteration.

Fixes #6125

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

@github-actions github-actions bot added the enhancement New feature or request label Mar 27, 2026
Previously, if a commit failed (OtherError or unresolvable conflict),
the transaction file written to _transactions/ was left orphaned and
would not be removed until GC ran after 7+ days. This adds best-effort
cleanup: on any failure path in do_commit_new_dataset,
do_commit_detached_transaction, and commit_transaction, the transaction
file is deleted before the error is returned. Failures to delete are
logged as warnings so they don't mask the original error.

For commit_transaction, stale transaction files from previous retry
iterations (which get rebased and re-written each attempt) are also
cleaned up when we retry after a conflict.

Closes lance-format#6125

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wjones127 wjones127 force-pushed the feat/cleanup-txn-files branch from 6c39d29 to fd9fe41 Compare March 27, 2026 22:21
The cleanup_failed_commit_data_file test expected 2 txn files after a
failed append, but now the failed commit immediately cleans up its own
txn file, leaving only 1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 85.91549% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance/src/io/commit.rs 85.71% 8 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@wjones127 wjones127 marked this pull request as ready for review March 31, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic cleanup of transaction files on failure

1 participant