Repository navigation
Conversation
A tag on an old version pulled the listing cutoff backwards, so newer deleted versions' data files were never scanned and became permanent orphans after their manifests were removed. Fixes lance-format#8705
Contributor
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The change fixes tagged sparse-retention cleanup at the correct listing boundary: it drops the timestamp cutoff only when a removed manifest is newer than the earliest retained manifest, while existing reachability and recent-write protections remain intact.
This was referenced Sep 2, 2026
ggozad
added a commit
to ggozad/haiku.rag
that referenced
this pull request
Oct 5, 2026
vacuum moved its cleanup cutoff back to before the oldest tag, because lancedb's optimize() hard-errors on a tagged version in the cleanup window. Every version written after a tag was kept, and each compaction added files that could not be removed: a tag, 8 single-document writes with auto-vacuum, then vacuum(0) left 191.6 MB and 38 versions of documents against 25.0 MB and 1 without the tag. Every table's maintenance now runs through lance, ending in cleanup_old_versions(error_if_tagged_old_versions=False), which keeps the tagged versions and removes the others with their files (lance-format/lance#8708, in pylance 11 and 12). The same case leaves 41.0 MB and 2 versions. optimize() is no longer called: its cleanup defaults to 7 days.
Xuanwo
added a commit
that referenced
this pull request
Oct 23, 2026
## Summary - `cleanup_old_versions` clamped its `data/` listing to `earliest_retained_manifest_time`. That floor is only sound for a file owned by a manifest being removed; a file owned by *no* manifest — abandoned `write_fragments()` output — has an mtime unrelated to it. - Such a file is documented to be removed on its age, but it was never listed, so its age was never consulted and `delete_unverified=true` had no effect on it. - When every aged version is retained (e.g. pinned by a tag) no manifest is deleted, so #8708's escape hatch cannot fire and the floor never advances: the orphan is collected by no run at all. - The `data/` listing now runs through the moving unverified threshold — `earliest_retained.max(verification_threshold)` — and drops the cutoff entirely under `delete_unverified`, where a file is a candidate at any age. `CleanupInspection::listing_unmodified_since` is unchanged, so #8708's sparse-retain case and the other listings behave exactly as before. - This restores an advancing cutoff, which is what the listing had before #4614 (the caller's `now - older_than`, per #8516). #8516 and #8705 reported the tagged facet of the same clamp and #8708 fixed it; this is the facet left over, reachable with no tag at all. - Documents the contract the change relies on, which the Rust API and the guide had drifted from: an unverifiable file is removed once it is at least 7 days old, that threshold is fixed and independent of `older_than`, and `delete_unverified` removes the age protection entirely and requires that no other process is operating on the dataset. The Python docstring already said this. - Adds `cleanup_deletes_aged_orphan_newer_than_retained_manifests`, covering both paths: an aged orphan under the default policy, and a fresh orphan under `delete_unverified`. Both are written after every manifest, under suffix-only retention with no tag anywhere. `_transactions/` and `_deletions/` are clamped the same way and can strand a file for the same reason. Left for a follow-up so each gets its own regression test rather than widening destructive discovery across four subtrees at once. Fixes #8942 ## Test plan - [x] `cargo fmt --all --check` — clean - [x] `cargo check -p lance --tests` — clean - [x] `cargo clippy -p lance --tests -- -D warnings` — clean - [x] `cargo test -p lance --lib dataset::cleanup` — 46 passed, 0 failed, including both new cases and #8708's `cleanup_deletes_data_files_newer_than_tagged_version` - [x] Mutation check: reverting the `data/` cutoff to `unmodified_since` fails `case_1_aged`; removing only the `delete_unverified` arm fails `case_2_delete_unverified`. Each case is gated on the branch it covers, and no other test changes outcome. --------- Co-authored-by: Jennifer Mell <[email protected]> Co-authored-by: Xuanwo <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cleanup_old_versionsused the earliest retained manifest time as theread_dir_allcutoff. A tag on an old version pulled that cutoff backwards, so data files from newer deleted versions were never listed._indices/and was fixed there; this applies the same rule to data / tx / deletions.Fixes #8705
flowchart TD A[cleanup_old_versions] --> B{Working set is a time suffix?} B -->|Yes: keep latest N versions| C[Scan files with last_modified <= earliest retained] C --> D[Delete unreferenced data / tx / deletions] B -->|No: tag keeps an older version| E[Deleted versions can be newer than the tag] E --> F[Old cutoff skips those newer data files] F --> G[Manifests are still removed] G --> H[Data files become permanent orphans] E --> I[New: drop unmodified_since cutoff] I --> DTest plan
cleanup_deletes_data_files_newer_than_tagged_version— overwrite replaces files, tag v1, cleanup deletes the intermediate version's data filedataset::cleanup::tests(43 tests)cargo fmt --allcargo check -p lance --testscargo clippy -p lance --tests --benches -- -D warnings