Repository navigation
Conversation
… compaction's own commit Three ways the coverage proof could reach the wrong answer: - Every followed fragment was held to the oldest segment's version. A newer segment's fragment that version does not have, or one rewritten before the newer segment was built, was refused coverage it had. Each fragment is now held to the segment that covers it. Where a compaction committed after a segment was built, conflict resolution moved the segment's coverage onto the compaction's output, which the segment's version does not have; the compaction's inputs are followed from that version instead. - A compaction's commit was found by searching the retained versions for the earliest one holding its output. A restore brings a retired fragment back, so that search could take the restore for the compaction and compare against the wrong state. The reuse index records each compaction at the version immediately before its commit, so the commit is the next version; it is accepted only when its own record is the rewrite that produced the fragments. That also removes the search's per-fragment cost. - Every failure to read a historical version was treated as cleanup, so a transient storage error could cost coverage the merged index would never get back. A version now counts as gone only when the dataset no longer lists it; any other read failure is an error. Each version read is opened once and indexes its fragments by id.
- The BTree folded-overlay test committed a data replacement after the compaction, duplicating the replacement test. It now stages, overlays a source, compacts, merges, commits and queries. - The cleanup test deleted every old version, so the merge gave up before it reached the compaction's commit. It now deletes only that commit's manifest, with a control showing the same merge keeps coverage before. - Segments built at different versions keep their coverage. - The four RTree overlay-timing tests are one test with four named cases, over a shared fixture.
The proof compared a fragment's state going forward only: files rewritten and overlays added since the segments were built. A restore moves it the other way without leaving anything newer behind. Restoring a snapshot from before an overlay takes the overlay's values away while the data files still match, and restoring one from before a delete brings back a row the segments never indexed; either way the merged index claimed a fragment it no longer describes. The overlays over the indexed fields must now be the same set on both sides, and every row deleted then must still be deleted now. The deletion vectors are read only when the two deletion files differ.
An RTree merge on a table with a tagged reuse history takes its coverage from the tagged plan. The merged segment claims the destinations a stable partition's sources cover completely, and holds every row of them. Also states the coverage guard's comparison by reference to the one function that makes it, and keeps test imports at the top of their modules.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use `overlay_affects_index` and `field_affects_index` so an overlay on a parent or child of an indexed field counts, as at query time. The staleness.rs change is identical to the one in lance-format#9808. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A fragment whose indexed data changed since the segments were built cost the merge every compacted fragment's coverage, clean ones included. The check now returns the stale current fragments: a compaction whose covered input changed, or whose manifests were cleaned up, makes the fragments its group produced stale, and that carries through later compactions. Only those are left out of the merged coverage; the rest still follow their rows. The merge-coverage tests move to their own module with shared helpers, and gain a seeded workload (two staging batches, writes, overlays and deferred compactions before, between and after the merge) checked against a scan, plus an explicit case for an overlaid fragment beside a compacted group. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Compare where each indexed field is stored (base, path, file version and its column) rather than the whole file's field list, so rewriting another column in the same file keeps the coverage; a packed struct holding an indexed child counts as that child's storage. - A segment whose build version was cleaned up leaves only its own fragments unverified instead of abandoning the check, so the merge is still stamped current and its commit goes through. RTree's second pass likewise drops such a segment's coverage instead of failing. - Keep only fragments shown fresh, rather than removing those shown stale. - Tests: a cleaned-up build version beside a clean group, an unrelated column rewrite, a packed child, the RTree cleaned-up case, two staging batches that really land at different versions, and stronger assertions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Committing staged segments compared each covered fragment's data files with the segment's build version, but not its overlays or deletions. A restore between build and commit can bring back an overlay whose commit version predates the segments, so query-time masking trusts their stale entry, or revive a row they never indexed. Either now leaves the fragment out of the committed coverage, and its rows are scanned. Co-Authored-By: Claude Opus 5.5 <[email protected]>
xuanyu-z
force-pushed
the
fix/staged-segment-restore
branch
from
October 9, 2026 05:12
2e959d1 to
e0e8a69
Compare
Xuanwo
pushed a commit
that referenced
this pull request
Nov 10, 2026
An index built after a deletion omits those rows. If Restore revives them before the index commits, claiming their fragment causes false-negative queries. Cleanup can hide the restore from regular commit conflict checks, and distributed commits on untagged tables previously checked files and overlays but not deletions. Reuse the existing row-revival comparison in both coverage guards and withdraw only affected fragments from the new index's coverage, so their rows are scanned. Unchanged deletion files and additional deletions retain coverage. System-index metadata is excluded from the commit guard. The regression suite covers both commit paths, cleanup submissions through original and refreshed dataset handles, restores with and without a remaining deletion file, and additional-deletion controls. Indexed queries are checked against index-disabled scans and fragment coverage. Validation on Rust 1.98.1: - `cargo test --profile ci -p lance --lib dataset::tests::merge_coverage` - 55 passed. - `cargo test --profile ci -p lance --lib index::provenance::tests` - 7 passed. - `cargo test --profile ci -p lance --lib io::commit::conflict_resolver::tests` - 204 passed. - `cargo fmt --all -- --check` passed. - Workflow-matching all-workspace-feature Clippy for all targets and the Arrow ordering fixture passed. Related draft: #9816 also addresses staged-segment restore validation. This repair covers row revival in both distributed commits and commits whose intervening restore history was cleaned up. Fixes #10913
This branch has not been deployed
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.
Depends on #9524. It reuses that PR's fragment comparison and test module. Until #9524 merges, this diff includes its commits; only the last commit is new.
Committing staged index segments (
commit_existing_index_segments) prunes the fragments whose data files changed since the segments were built. It does not compare overlays or deletions, and a restore between build and commit can change both:Example: the segments are staged after a restore removed an overlay setting
val = 999. A second restore brings the overlay back, then the segments commit.val = 0still finds the row, andval = 999does not.Fix. At commit, a covered fragment is also stale if its overlays on indexed fields from before the build version differ from the build version's, or if a row deleted then is live again. That fragment is left out of the coverage and its rows are scanned. Overlays newer than the build are still masked at query time, so they cost no coverage.
Tests:
Each part of the check was disabled in turn and its test failed.
cargo test -p lance --lib --features geopasses.