Conversation
Assert, rather than infer, what the existing representation and the engine's
single deferred-remap capability predicate already decide, ahead of selecting
a compaction coverage-withdrawal policy.
`withdrawal_feasibility` covers `withdraw_rewritten_coverage`: the direct
S1={F1,F2} case keeps F2 and cannot trip the whole-remainder fallback (the
rewritten fragment is still live in the manifest the withdrawal is computed
against); the historical S1={P} case with P->F1+F2 withdraws P and gives up
F2 as well; removing F1 from a {P} bitmap is a no-op; and the fallback fires
only for a live remainder the history does not mention, retaining a retired
on-history remainder.
`capability_predicate_classifies_hnsw_as_deferrable` records the predicate's
answers for a real IVF_HNSW_SQ segment, a BTree segment and a segment whose
details are absent, so a later reclassification is visible as a test change.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…compaction commit A deferred compaction on a tagged fragment reuse history leaves every covering segment's retired provenance in its bitmap and records the row-level translation in the history. A segment whose type cannot be translated in batches was left pointing at provenance it can never translate: the reader derives no coverage for it (`load_indices` excludes it, scan fallback) but the manifest keeps claiming it, so nothing ever repairs the claim and a later reader change could serve those addresses. Such a segment's coverage of the rewritten sources is now withdrawn in the same Rewrite commit. The classification is the engine's own single predicate `segment_supports_batch_remapping`, not a type list: `Some(true)` keeps its provenance and translates as before, `Some(false)` is withdrawn, `None` (details absent or uninterpretable) is left exactly as it was, since the read path already refuses such a segment and guessing a withdrawal from unreadable metadata would delete coverage this build cannot prove unsound. Representation, within the existing operation fields and with no persisted format, field or flag added. `Operation::Rewrite` cannot carry the decision: `rewritten_indices` means "replace this segment with these new files" and the manifest build is synchronous, while the predicate must open index details. The decision therefore rides `TaggedRewriteAssembly`, the in-memory per-attempt value the commit path already assembles for a tagged rewrite and hands to the build as `FragReuseUpdate::Rewrite`, as a list of segment uuids. It is established in `finish_rewrite`, against the manifest the attempt builds on and re-established on every retry, for the same reason the entry is: a concurrent `CreateIndex` can add an undeferrable segment that the withdrawal has to cover. `prepare_indices` then applies the existing helper `withdraw_rewritten_coverage`'s algorithm to the prepared list, through a new `withdraw_undeferrable_rewrite_coverage` entry point that selects by segment instead of by rewritten column (a compaction rewrites no column) and shares one `withdraw_coverage` implementation with the in-place-rewrite and unverified-retired cases. The other commit order is handled where the mirror decision already lives: `finish_create_index` withdraws, from a segment being created over a committed rewrite, the retired coverage it cannot translate, beside the in-place-rewrite withdrawal already there. Conservative loss is unchanged from the helper's existing rules and bounded: an independent direct source keeps its coverage, while a retired ancestor reaching a rewritten fragment is withdrawn whole, giving up its other destinations too. The index definition always stays, so a later optimize can restore coverage. `defer_index_remap = false`, stable-row-id tables and untagged (v0) histories are untouched. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… end Seven tests in `dataset::optimize::tests::undeferrable_withdrawal` over one fixture: a table without stable row ids, made tagged by a stable-partition commit before any index exists, carrying a legacy pre-(0,3) IVF_PQ segment (the kind `segment_supports_batch_remapping` reports as undeferrable at this pin) and a BTree segment over the same fragments. - the whole contract on one commit: the legacy segment's stored bitmap no longer names the rewritten sources and claims none of the destinations, the BTree's stored provenance is untouched and its derived coverage translates to the destinations, both definitions remain, no other segment changed, the commit is the Rewrite itself; afterwards the KNN answer equals brute force with no ANN node in the plan (no retired row, no duplicate) and the BTree lookup is still served by `ScalarIndexQuery`; - no-op: a compaction holding every covered fragment out of the plan leaves every index's metadata equal to what it was; - partial: committing one task of a multi-task plan withdraws that task's sources only; the omitted (failed) task's sources stay covered; - both commit orders through the conflict resolver: a `CreateIndex` of the legacy kind committed first with the Rewrite rebased over it, and the Rewrite committed first with the index build rebased over it. Both land (a refusal would make the assertions vacuous, so it fails the test) and neither keeps coverage of sources it cannot translate; - the ordinary eager default: `defer_index_remap = false` on this table is still refused up front and withdraws nothing; - `None` from the predicate: a segment whose details are stripped keeps its coverage byte for byte, and the reader's own refusal (no derived coverage) is what pins the behaviour. Three unit tests in `withdrawal_feasibility` pin the new entry point itself: selection is by segment (a deferrable sibling over the same column and fragments is untouched), an empty selection or an empty rewrite set is a no-op, and the retired-ancestor closure gives up the ancestor's other destinations as the accepted loss, keeping the last segment as the definition to rebuild. Also drops a redundant clone in the neighbouring probe test, which `clippy -D warnings` rejects. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@claude review |
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🔴
rust/lance/src/index/frag_reuse.rs— A transient read error on an FTS index can now permanently remove that index's coverage of compacted fragments, which then get scanned until the index is rebuilt.inverted_supports_batch_remappingreturns.is_ok()from openingMETADATA_FILE, so any open failure counts as Some(false). This selector turns Some(false) into a withdrawal committed to the manifest. Fix: treat a failure other than a confirmed missing file as unknown (None, no withdrawal) or as an error. Do not report it as Some(false). Before this change the answer only chose a per-query scan fallback.Why this was flagged
A deferred compaction on a tagged table covers fragments indexed by a modern inverted index. During
finish_rewrite,undeferrable_segments_covering(frag_reuse.rs:651) callssegment_supports_batch_remapping, which callsinverted_supports_batch_remapping(frag_reuse_remapping.rs:73-78). An object store timeout or throttling error openingMETADATA_FILEturns intofalsethrough.is_ok(), and the result is cached underInvertedFormatKey. The segment is listed inundeferrable_segments, and manifest_build.rs:495 withdraws its coverage of the rewritten sources in the committedRewrite. On the base branch the same misclassification only made the reader fall back to a scan at query time, and nothing was persisted. Now the FTS index stops covering those fragments until someone runs optimize.Verification:
inverted_supports_batch_remappingreturnsIndexStore::open_index_file(&store, METADATA_FILE).await.is_ok()(frag_reuse_remapping.rs:73-78), so any open error becomesOk(false). New in this PR,frag_reuse.rs:648-654pushes the uuid onSome(false), andfinish_rewritecommits the withdrawal. On the base branch, the same misclassification only made a temporary scan fallback. -
🟡
rust/lance/src/index/frag_reuse.rs— Undeferrable segments that reach a rewritten fragment only through a retired ancestor keep that coverage, so the stated retired-ancestor withdrawal never runs in production. The prefilter at frag_reuse.rs:2063-2068 skips any segment whosefragment_bitmapis disjoint from the rewritten sources. A bitmap like {P}, where an earlier compaction split P into F1 and F2, is disjoint from a rewrite of F1. Fix: select a segment when its bitmap meets the rewritten set OR when one of its retired fragments hasdestinations_ofreaching it, matchingwithdraw_coverage. [also at: rust/lance/src/index/frag_reuse.rs:2066 - Undeferrable segments whose coverage reaches a rewritten fragment only through a retired ancestor are never selected, so compaction leaves their untranslatable provenance in place.]Why this was flagged
Take a legacy IVF_PQ segment (
segment_supports_batch_remapping== Some(false)) whose bitmap holds a retired P, for example from a deferred compaction committed before this change. A later deferred compaction rewrites F1, a destination of P.finish_rewrite(finish.rs:603) callsundeferrable_rewrite_segments. That callsundeferrable_segments_covering, which skips the segment at frag_reuse.rs:646 because {P} is disjoint from {F1}. Soundeferrable_segmentsis empty and manifest_build.rs:481 never withdraws anything. The segment keeps claiming provenance it can never translate, which is exactly what the PR says it fixes. The unit testundeferrable_withdrawal_follows_the_retired_ancestorpasses the uuid in by hand, so it never exercises this selector.Verification:
undeferrable_segments_covering(rust/lance/src/index/frag_reuse.rs:2062-2068) skips any segment where.is_none_or(|bitmap| bitmap.is_disjoint(fragments)). A bitmap {P} is disjoint from {F1}, so the segment is never listed. The outcome matches the base: the stale claim to P stays in the manifest. Query results stay correct.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
… file is missing The inverted capability probe collapsed every failure to open the segment's metadata file into "legacy layout": a transient object-store error was reported as `false`, cached under that segment's uuid for the rest of the handle's life, and turned by the rewrite commit into a persisted withdrawal of the segment's coverage. Only a confirmed-missing metadata file now answers `false`; any other error propagates out of the cache-filling closure, so nothing is cached and the commit attempt fails or retries under the existing error rules rather than writing a narrowed fragment bitmap on the strength of an unreadable file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…venance The selector skipped any segment whose fragment bitmap did not intersect the rewritten ids directly. A segment can reach a rewritten fragment through one more hop: when `P` was partitioned into `F1` and `F2` while the segment covered `P`, a later rewrite of `F1` alone never names `P`, so the segment was never classified and its coverage of `P` was left behind for a reader that cannot translate it. A segment is now also a candidate when it covers a retired fragment whose rows the history moved into one of the rewritten ids. The reach of a retired source mirrors the rule the withdrawal helper already applies, including its conservative answer for a history that cannot be walked, so selection and withdrawal agree on the same fragments. Only candidates pay the capability probe, and the direct fast path is unchanged. `undeferrable_rewrite_segments` therefore loads the tagged entry's lineage and the manifest's live fragments, and the `CreateIndex` rebase passes the lineage and liveness it already holds. Accepted loss: withdrawing `P` also ends the segment's acceleration of the sibling destination `F2`, since the rows it covered are only reachable through the withdrawn transition. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… undeferrable segment `P` was partitioned into `F1` and `F2` while an undeferrable segment covered `P`, so a later rewrite of `F1` alone never names `P`. The test pins that the selector still classifies that segment and the commit withdraws `P`, clearing the live-only remainder with it, while the deferrable control keeps translating to the untouched destination. A build before this change could leave that manifest behind: its Rewrite commits withdrew nothing. This build cannot produce the state any more, so the fixture writes the older manifest directly through the crate-internal manifest writer the fragment-reuse reader tests use. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Both findings are addressed on head
|
|
@claude review |
There was a problem hiding this comment.
Besides the inline finding, I checked whether a transient format-marker read error in frag_reuse_reader.rs (around line 108) could let a healthy sibling segment keep coverage it doesn't own, which would make queries drop rows. It can't. The unreadable segment is left out of supported before segment_coverage runs, so the sibling gets no destination coverage that would need the excluded segment's provenance, and those fragments are scanned instead.
Extended reasoning...
The check covered how the query-time listing in frag_reuse_reader.rs decides coverage when a segment's format-marker probe fails. Coverage is calculated only from the segments whose probe succeeded, so a sibling can't claim fragments that depend on the excluded segment.
Still open from earlier reviews (1):
- Unresolved: 1 minor or pre-existing.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🔴
rust/lance/src/dataset/optimize/remapping.rs— Explicitly remapping an index can publish a segment claiming fragments its sibling covers directly while that sibling's format marker is unreadable. Only the absent segment is refused.segment_coverage_reasonreturnsUnverifiableonly for segments missing from the listing, so a listed sibling X still getsTranslate. Theload_indicesnarrowing at remapping.rs:1008 is also derived without Y. Fix: refuseremap_index_taggedwhen the derived listing'sunverifiableset contains the segment's name, astagged_segment_coveragedoes. Run that check before committing any segment inremap_column_index.Why this was flagged
Trigger: a tagged table where a same-name sibling Y covers the compaction destinations directly and its marker read fails. The handle must be cold, e.g. a fresh process, or the new snapshot each earlier remap commit creates.
remap_column_index(remapping.rs:1215) callsremap_index_taggedfor X before Y.frag_reuse_reader::load_indicesdrops Y and records its name, so the plan gives XTranslate(frag_reuse.rs:374-389) and the name check at frag_reuse.rs:390 never runs.coverage &= servable(remapping.rs:1008-1016) uses a listing without Y's exclusions, so X' is committed with Y's destinations as direct coverage anddataset_version= current. Only then does Y fail withUnverifiable. With Y readable, X would be skipped asNoDerivedCoverage. Afterwards X' and Y both cover those fragments directly, and the newest-first prune drops Y. On base, a vector sibling's probe error (?) failed the remap and nothing was published. The PR says sibling decisions must be blocked, andtagged_segment_coveragedoes block them, but this path does not.Verification: In
frag_reuse_reader::load_indices(frag_reuse_reader.rs:93-106), a failedsegment_supports_batch_remappingis now swallowed.segment_coverage_reasonreturnsNonefor X, so the newUnverifiablerefusal at remapping.rs:938 never fires for X. Base usedsegment_supports_batch_remapping(dataset, index).await?, so the same transient read failed the remap visibly and nothing was published.
… segment `tagged_segment_coverage` and the plan's absent-segment arm already refuse a coverage decision for a logical index when one of its segments' format markers cannot be read. The explicit remap did not: `remap_index_tagged` classified each segment on its own, so when the unreadable segment was the newer directly covering delta, the older translating segment was visited first, classified from a listing missing the delta's direct coverage, and published as a translated replacement over destinations the delta already covered. After reads recovered the logical index answered every match twice. The remap now consults the derived listing's unverifiable set for the segment's logical index before classifying it and refuses, naming the index and segment, before anything is published. Covered by `an_explicit_remap_refuses_a_readable_segment_beside_an_unreadable_sibling`: the delta's marker is unreadable on a cold handle, the remap refuses and leaves the stored index list unchanged, and once reads recover it answers exactly on the same and on a reopened handle. The older-fault fixture keeps its prune/coverage controls; its remap assertion is the pre-existing per-segment refusal. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Pushed Fix ( Regression ( Evidence: with the test file against the previous 🤖 Generated with Claude Code |
|
@claude review |
The tagged remap verified a derived listing for unverifiable segments, then re-derived another listing to narrow the segment's coverage. A marker read outage between the two steps dropped the directly covering sibling from the second listing, so nothing ceded its destinations and the published replacement overlapped it, answering every indexed match twice. The narrowing now intersects against the listing the guard already verified. A regression faults the delta marker in an attempt window, with both caches disabled, and asserts exact counts and disjoint segment coverage. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Pushed 🤖 Generated with Claude Code |
|
@claude review |
There was a problem hiding this comment.
The reported repair closes the explicit-remap gap: coverage narrowing now uses the verified sibling listing, preserving disjoint ownership and exact indexed results through read recovery and retry. The staging and independent-index maintenance repairs remain intact. Selective atomic withdrawal remains appropriate, retaining logical definitions and shared FRI mappings.
Concurrent healthy cold opens on tagged snapshots can still duplicate derivation; warm opens remain cached. This remains a non-blocking performance risk.
| let met = attempts.swap(usize::MAX / 2, Ordering::SeqCst); | ||
| let exhausted = met >= start + PHASED_FAULT_READS; |
There was a problem hiding this comment.
🟡 nit (optional): The faulted remap regression test can pass without the injected outage ever firing, so it cannot show it exercised the race it guards. exhausted and met are only put into the context string and are never asserted. If marker reads change, the window at PHASED_FAULT_START goes unreached and the test passes silently. Fix: when start == PHASED_FAULT_START, assert that the remap reached the window (met > start), or that it refused, so the faulted case cannot silently turn into the healthy control.
Why this was flagged
an_explicit_remap_narrows_coverage_from_the_listing_it_verified calls assert_partial_coverage_remap_is_exact(PHASED_FAULT_START, true). The wrapper fails only marker reads numbered 2..6 (PHASED_FAULT_START = 2, PHASED_FAULT_READS = 4, undeferrable_withdrawal.rs:3830-3834). After the first remap, line 4053 swaps the counter and line 4054 computes exhausted. Both values are used only in the context message and never asserted. Suppose the remap makes two or fewer reads of the delta's metadata.lance, for example because the fix removed the second derivation or because probes are reordered or cached. Then no injected error fires, and the test reduces to the healthy control a_partially_covered_remap_is_exact_with_healthy_uncached_reads. It still passes, so a later change to read order could hide a reintroduced overlap. This is a test-strength issue only, with no production impact.
Verification: nit. Trigger: a later change alters how many times the remap reads the delta's FTS metadata marker, so the first remap makes 2 or fewer such reads. After the first remap, met and exhausted (undeferrable_withdrawal.rs:4053-4054) are used only inside the context string, and no assertion checks them. If no fault fires, the faulted test passes on the same healthy path as the PHASED_FAULT_NEVER controls.
Why this change?
Compaction rewrites data into new files, so rows move to new locations. Most indexes can keep working by following a map from the old locations to the new ones. Lance calls this deferred index remapping, and stores the map in the Fragment Reuse Index (FRI).
Some older index files cannot follow that map. Their metadata can still say “this index covers these rows,” even though the reader can no longer use it for those rows.
This PR makes that metadata match what the index can actually do.
Why not just remap inline and remove the FRI?
Correct row addresses do not imply correct fragment coverage. An index segment's coverage bitmap names whole fragments, not arbitrary subsets of their rows.
Consider a stable-partition rewrite from two fragments to two fragments. Segment S indexes all of A, but none of B:
An inline remap can correctly change S's stored addresses:
But what should S's coverage bitmap become?
{C, D}is wrong: S has never indexed b1 or b2. Claiming both fragments are fully covered can cause queries to skip those unindexed rows.{A}does not finish the job either: A is retired. Its coverage must still be interpreted through the FRI history to determine which current rows S covers.So rewriting the addresses alone does not produce an index segment whose coverage can stand on its own. This partially covered transition cannot simply be drained and its FRI removed; the segment needs a safe rebuild/replacement or must retain its translation history. If S covered both A and B, remapping its addresses and restamping coverage to
{C, D}together would be valid.This is why inline remapping is not a general fallback for an index that cannot use deferred remapping. This PR withdraws affected unusable coverage in the compaction commit, keeps the logical index definition, and preserves any FRI history other usable segments still need.
What happens after compaction?
For each affected index:
For example, a table may have an older vector index and a BTree index over the same data. After compaction, the older index can lose coverage while the BTree keeps working. Queries that allow scanning read the affected rows without that index until replacement coverage is built.
The index definition is kept, so later index maintenance can restore coverage. This coverage change does not delete table rows, directly delete index files, or remove the shared maps that other indexes still need.
Safety and scope
An unreadable index must not block maintenance of a separate, independent named index. Operations that inspect all indexes, such as table-wide cleanup, still refuse if they cannot verify the coverage they depend on.
Validation and remaining limits
Tests cover coverage bookkeeping, actual BTree and full-text query results, partial commits, concurrent index creation, interrupted full-text index finalization, and unreadable-index failure/recovery. Full-text tests also check that custom tokenizer behavior is preserved.
Current published head:
6766f42bf. The explicit-remap re-read issue is fixed, the focused 30-test suite and format/lint checks pass, and both Claude and Gatekeeper report no blocking issue. All applicable CI has completed successfully on this head. Technical validation is complete; formal review approval and merge are still pending.Existing full-text column-discovery limitations are unchanged. This PR does not redesign how a query chooses its text column.