Repository navigation
fix(index): preserve segment coverage across compaction - #9271
lance-gatefixer[bot] wants to merge 5 commits into
Conversation
|
|
Addressed in f92ad04: scalar segment merges now reject retired coverage when no applicable reuse mapping survives and reject partial rewrite-group coverage before it can be stamped current. The regression now spans two rewrite groups, asserts exact live coverage and row addresses, and exercises both failure modes. Vector and RTree remain intentionally outside this scalar remap path because their dispatch behavior is unchanged. |
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The revised coverage reconstruction now fails closed when retained fragment-reuse history cannot account for every retired source fragment. The two-compaction regression covers the previously incomplete merge path while retaining the group-level remap and FM rebuild needed to keep advertised coverage aligned with returned row addresses.
|
I believe this PR lacks some of the fixes, therefore I'm starting #9421 and fixing there |
…ndex (#9421) Supersedes #9271; merging this closes #9270. ## Merging segments across a compaction `merge_existing_index_segments` combines staged segments into one. When a compaction has retired the fragments those segments were built over, their coverage has to be resolved against the current manifest before the merge can mean anything. Resolving each segment on its own cannot do that. A segment covering one fragment of a three-fragment rewrite group is a straddle, and the remapper drops straddles rather than claim a fragment holding rows the segment never indexed — so every segment of the group resolves to nothing and the merge produces an empty index. This affected five of eight scalar families. The merge owns the whole group, so it remaps the *union* of its segments, which is complete where each segment alone is not. FM segments are rebuilt rather than passed through, because a passthrough returns coverage in the new fragment space with row addresses still in the old one. ## Coverage may only move with the row addresses `open_scalar_index` takes its remapper from the dataset's reuse index. Where that mapping is missing, the addresses stay in the old fragment space and the coverage must not advance to the new one. An index claiming coverage it cannot serve is worse than one covering less: a short claim falls back to a flat scan, a false claim suppresses that fallback and returns nothing. So coverage shrinks where no mapping applies, and the three ways that loses rows are reported: - **No applicable mapping over retired fragments.** They are intersected away and their rows leave the index. Partly retired counts, since the surviving half would otherwise make the coverage look healthy. - **A rewrite chain only partly mapped.** Fragments compacted more than once need every link; a trim that dropped an earlier one leaves the remap on an intermediate fragment the dataset no longer has. - **A straddling union.** The segments together cover only part of a rewrite group. The remapper reports the group it heals, but not that here it costs the entire merged index rather than the straddling rows. None is an error. A shrunk coverage is correct when the rows were deleted, and at that point nothing distinguishes that from a mapping that was trimmed. A merge whose coverage shrank rebuilds rather than fails, which `test_fmindex_merge_single_segment_rebuilds_when_coverage_shrinks` (#7569) holds. ## Index families the remap does not cover Vector cannot remap here: its merge hands the segments to the distributed file merger with an object store and a directory, reaching no dataset and so no reuse index. Vector indexes are remapped through `optimize_vector_indices_v2`, which passes the reuse index to the builder. RTree does load through the remapper, so it belongs under this rule, but the `all_rtree` branch writes the same coverage field from its own staleness pruning — which drops fragments whose indexed files changed, a different question from which fragments a rewrite replaced. Bringing RTree under the remap means settling how the two compose, and no test yet drives an RTree index through a deferred compaction. Both families shrink coverage rather than over-claim, so the uncovered case costs a flat scan rather than a wrong answer. An RTree merge without the `geo` feature is refused before the coverage work rather than after it. --------- Co-authored-by: Gatefixer <312823363+lance-gatefixer[bot]@users.noreply.github.com>
|
9421 was merged, which covers everything here, this should be closed |
Summary\n\n- remap aggregate caller-supplied scalar segment coverage through deferred-compaction fragment reuse metadata\n- rebuild FM sources after coverage remapping so their row addresses match the current fragment space\n- reject merges when required reuse history is missing, partially retained, or source coverage only partially spans a rewrite group\n- extend the eight-family regression across two rewrite groups with missing-history, mixed-history, partial-group, exact-coverage, and live-address checks\n\n## Root cause\n\nMost scalar merge helpers loaded row addresses through the fragment-reuse remapper, but several helpers first intersected each staged segment old fragment bitmap with the current manifest. Compaction had retired every old fragment, so that filter became empty. Coverage also cannot be remapped per segment because staged segments may jointly, rather than individually, cover a compaction rewrite group.\n\nFM loading is the exception: it does not apply the fragment-reuse row-address remapper. After group coverage was moved to current fragments, its single-segment passthrough could therefore advertise current coverage while retaining retired physical row addresses. Uncommitted segments also do not pin reuse history, so a delayed merge must fail explicitly if the required mapping has already been trimmed. A retained newer mapping can make the group appear applicable even when an older required mapping was trimmed, so the remapped union must also be checked for any remaining retired fragments. Likewise, partial rewrite-group coverage cannot be represented safely and must not be published as current.\n\n## Validation\n\n-
running 1 test
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_2_btree ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 3870 filtered out; finished in 0.10s\n-
running 8 tests
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_6_fm ... ok
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_3_zonemap ... ok
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_1_bitmap ... ok
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_8_label_list ... ok
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_4_bloomfilter ... ok
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_2_btree ... ok
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_7_inverted ... ok
test index::create::tests::test_merge_uncommitted_segments_across_deferred_compaction::case_5_ngram ... ok
test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 3863 filtered out; finished in 0.23s\n-
running 11 tests
test index::tests::test_merge_existing_index_segments_rejects_mismatched_covering_fields ... ok
test index::scalar_logical::tests::test_merge_existing_index_segments_rejects_mismatched_zonemap_params ... ok
test index::tests::test_merge_existing_index_segments_preserves_covering_scalar::case_2_explicit ... ok
test index::scalar_logical::tests::test_merge_existing_index_segments_supports_zonemap_segments ... ok
test index::tests::test_merge_existing_index_segments_preserves_covering_scalar::case_1_struct_update ... ok
test index::create::tests::test_label_list_merge_existing_index_segments_drops_retired_fragments ... ok
test index::tests::test_merge_existing_index_segments_preserves_covering_rtree ... ok
test index::tests::test_merge_existing_index_segments_preserves_covering_vector ... ok
test index::create::tests::test_btree_merge_existing_index_segments ... ok
test index::create::tests::test_label_list_merge_existing_index_segments ... ok
test index::create::tests::test_merge_existing_index_segments_supports_fts_segments ... ok
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 3860 filtered out; finished in 0.11s\n-
running 1 test
test index::scalar_logical::tests::test_ngram_segment_merge_rebuilds_after_deferred_compaction ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 3870 filtered out; finished in 0.28s\n- \n- \n\nFixes #9270\n\n