Repository navigation
fix(index): carry merged segment coverage through compaction only while indexed data matches - #9524
Merged
Merged
Conversation
xuanyu-z
force-pushed
the
rtree-coverage-remap
branch
from
September 23, 2026 17:39
b45e954 to
94a4867
Compare
xuanyu-z
force-pushed
the
rtree-coverage-remap
branch
3 times, most recently
from
September 23, 2026 18:48
003a8b9 to
52e2bd0
Compare
xuanyu-z
marked this pull request as ready for review
September 23, 2026 18:49
xuanyu-z
force-pushed
the
rtree-coverage-remap
branch
from
September 23, 2026 18:52
52e2bd0 to
c19e168
Compare
xuanyu-z
force-pushed
the
rtree-coverage-remap
branch
from
September 23, 2026 19:17
c19e168 to
9b01820
Compare
xuanyu-z
force-pushed
the
rtree-coverage-remap
branch
from
September 23, 2026 19:39
9b01820 to
4112e46
Compare
xuanyu-z
marked this pull request as draft
September 23, 2026 19:50
xuanyu-z
force-pushed
the
rtree-coverage-remap
branch
from
September 23, 2026 20:19
4112e46 to
8fd4384
Compare
xuanyu-z
force-pushed
the
rtree-coverage-remap
branch
from
September 23, 2026 20:54
8fd4384 to
6518fff
Compare
xuanyu-z
marked this pull request as ready for review
September 24, 2026 01:39
xuanyu-z
force-pushed
the
rtree-coverage-remap
branch
from
September 24, 2026 03:45
f8cea38 to
a4bd34b
Compare
Contributor
There was a problem hiding this comment.
The merge now preserves coverage when an unrelated column in the same file is rewritten, and leaves fragments whose indexed data or history cannot be verified on the scan path.
Cleanup can still remove manifests needed to retain coverage, leaving affected rows on the scan path until the index is rebuilt. Retaining the required manifests until merging avoids that cost; #9543 tracks recording the necessary evidence in the reuse index.
jackye1995
approved these changes
Oct 9, 2026
… 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]>
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.
Extends the merged-segment coverage remap from #9421 to RTree, and only lets coverage follow rows through a compaction where the indexed data is unchanged.
Problem
merge_existing_index_segmentsexcluded RTree from the remap, so its staleness pass dropped every fragment a deferred compaction had retired. RTree segments staged before a compaction then merged into an index covering nothing, and their rows fell back to a flat scan.For every scalar family, the remap also carried coverage forward when something else had changed the indexed column along the way, for example an overlay that a compaction then folded in. The merge also stamped the index as current, so an overlay on a covered fragment that no compaction touched stopped masking the index's old value. In both cases the index answered stale values.
Example: BTree segments on
ageare staged, an overlay updates one row'sage, and a compaction folds that overlay into a new fragment. The merge claims the new fragment, and onmaina query for the newagereturns nothing.Fix
Rewriting another column, even in the same file, does not count.
Tagged tables keep their own replay path.
Tests
The merge tests are in
dataset/tests/merge_coverage.rs.Coverage is dropped for:
Coverage is kept for:
A seeded workload stages segments in two batches, with only non-compacting writes in between so the second batch lands at a later version. It runs appends, deletes, in-place updates, overlays, folding and plain deferred compactions, added columns and config commits before, between and after the merge. Point and range lookups are then compared against a scan.
mainreturns stale values on this workload. Each check in the staleness logic was disabled in turn, and each change made tests fail.cargo test -p lance --lib --features geopasses. clippy is clean with and withoutgeo.Follow-ups
These are left out to keep the change small: