fix(index): merge segments across a compaction without emptying the index #9421
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 423 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.362
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9421"
general
weight: 0.35
xuanyu-z
Supersedes #9271; merging this closes #9270.
Merging segments across a compaction
merge_existing_index_segmentscombines staged segments into one. When acompaction 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_indextakes its remapper from the dataset's reuse index. Where thatmapping 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:
their rows leave the index. Partly retired counts, since the surviving half
would otherwise make the coverage look healthy.
every link; a trim that dropped an earlier one leaves the remap on an
intermediate fragment the dataset no longer has.
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, whichpasses the reuse index to the builder.
RTree does load through the remapper, so it belongs under this rule, but the
all_rtreebranch 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
geofeature is refused before the coverage workrather than after it.