Repository navigation
fix(index): drop old fragment ids from stale indices on deferred overlay compaction - #10109
Merged
wjones127 merged 1 commit intoOct 17, 2026
Conversation
wjones127
approved these changes
Oct 17, 2026
Merged
5 tasks done
Xuanwo
added a commit
that referenced
this pull request
Nov 10, 2026
… segment predates (#10538) ## Summary With a v0 fragment reuse index (FRI), every index segment's cache entries are keyed by the whole FRI history, so any change to it (a deferred-remap compaction or a trim) cold-starts every segment of every index. This keys each segment only by the versions that can still change its decoded rows: those it was **not** built after. A segment built (or remapped) after a version's rewrite holds none of that version's source addresses, so decoding with or without the version gives the same rows. - **Built after the whole history:** the plain per-index key, as with no FRI. - **Otherwise:** a hash of the digests of the versions it predates, so trimming older versions leaves its key unchanged. - **No fragment bitmap:** the whole-history key, as before. A rewrite group split by the segment's coverage counts as a version it predates. Disjoint coverage alone is **not** treated as unaffected: deferred overlay compaction (#10109) withdraws coverage from a stale index while its data keeps the rows, which the remapper still translates. ## What it improves - **Compaction:** no change; every existing segment predates the new version. - **Trim:** segments built or remapped after the trimmed versions stay warm. Older segments still reload. ## Changes - `index/frag_reuse_v0_cache.rs`: `v0_segment_cache_id`, plus per-version digests (blake3 of the protobuf encoding) cached once per history. - `ResolvedRemapping::V0` carries the segment's `cache_id`; `fri_cache_id` returns it, so the scalar and IVF open paths use it. - `dataset/index/frag_reuse.rs`: `index_postdates_rewrite` split out of `is_index_remap_caught_up` (trim unchanged). - Unchanged: tagged (v1) histories, legacy vector file formats, the FRI's own cache key. ## Test plan - [x] `test_overlay_compaction_reconciles_stale_index` (deferred case): a fresh reader warms the latest snapshot, then an indexed query on the pre-compaction snapshot must still match. Fails if disjoint coverage is treated as unaffected, or if v0 segments use the plain key. - [x] `v0_history_keeps_remapped_segments_warm_through_trim`: segments reload once after the compaction and are then warm (the vector segment through the generic open); the remapped segment stays warm through the trim; scalar and nearest-neighbor queries stay correct. Fails if keys change on every open. - [x] `v0_segment_cache_id_tracks_versions_on_the_path`: one case per branch. - [x] `cargo nextest run -p lance --lib` filtered to `frag_reuse`, `v0_`, `overlay`, `prewarm`, `legacy`, `defer`, `remap_caught_up` (1,107 tests). - [x] `cargo clippy -p lance --tests -- -D warnings`, `RUSTDOCFLAGS="-D warnings" cargo doc -p lance --no-deps`. --------- 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.
Closes #10091.
On a table without stable row ids, a compaction with
defer_index_remap: truethat folds a data overlay on an indexed field left the index covering the compacted rows with their pre-overlay values.prune_overlay_stale_fields_from_indicesonly removed the group's new fragment ids from a stale index's bitmap, but on the deferred path the bitmap still holds the old ids (the fragment reuse index translates them at load time), so nothing was removed andval = <old value>kept matching.This removes both the old and the new fragment ids of the group from stale indices, which is the second option the issue gives (per #10090). On the eager path the old ids are already gone, so that path behaves as before. Tagged FRI tables still refuse this compaction, so they aren't affected.
Testing:
test_overlay_compaction_reconciles_stale_indexnow runs with both eager and deferred remap; the deferred case fails on main (the index still covers the compacted fragment) and passes here.test_prune_overlay_stale_fields_from_indicesgained a stale index that still covers the old fragment id.cargo test -p lance-table --libpasses, as do theoverlay,dataset::optimizeanddataset::index::frag_reusetests inlance.cargo fmt --allis clean andcargo clippy -p lance -p lance-table --lib --tests -- -D warningspasses; I didn't run the full-workspace clippy.This touches the same function as #10108 (which changes how stale fields are matched, not which fragment ids are removed), so whichever lands second needs a small rebase.
I used an AI coding assistant to help write this change and the tests; I reviewed the diff and ran the checks above.