Repository navigation
fix: do not lose index coverage on a partial index commit over a fragment reuse history - #11292
Conversation
|
@claude review |
424ca3b to
3576630
Compare
|
@claude review |
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Still open from earlier reviews (1):
- 🔴
rust/lance/src/index/lifecycle.rs—Partial vector-index commits now fail when a historical segment is Unsupported, Unverifiable or Corrupt; the base branc…
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
3576630 to
f2cfaaa
Compare
|
@claude review |
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Still open from earlier reviews (5):
- 🔴
rust/lance/src/index/lifecycle.rs—Partial vector-index commits now fail when a historical segment is Unsupported, Unverifiable or Corrupt; the base branc… - 🔴
rust/lance/src/index/lifecycle.rs:1482—On tables with steady ingestion, a coverage-dependent partial index commit can fail repeatedly, even when the concurren… - Also unresolved: 2 minor or pre-existing, 1 blocking on lines changed since (possibly already fixed).
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
fb33834 to
a8f0cf3
Compare
|
@claude review |
There was a problem hiding this comment.
Still open from earlier reviews (2):
- 🔴
rust/lance/src/index/lifecycle.rs—Partial vector-index commits now fail when a historical segment is Unsupported, Unverifiable or Corrupt; the base branc… - Also unresolved: 1 blocking on lines changed since (possibly already fixed).
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
a8f0cf3 to
deb5e3a
Compare
|
@claude review |
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.
|
@claude review |
deb5e3a to
8f00999
Compare
…e settled downstream (#11290) ## What this fixes After fragments are rewritten, existing index segments may still point to the old fragment IDs. Fragment reuse history (FRI) translates those old row addresses to the current fragments, allowing the index to keep working without rebuilding it immediately. Once an index directly covers the current fragments, those translation records may no longer be needed. Today, cleanup can retain them forever if the data was rewritten more than once. For example, all three segments below belong to the **same logical index**: ```text Index segments: A stores {1, 3}; B stores {2, 4} Rewrite history: {1, 2} → {10} → {30} New index segment: C stores {30} Current fragments: {3, 4, 30} ``` A can serve 3, B can serve 4, and C can serve 30 directly. Queries no longer need either translation. However, the old cleanup waits for direct index coverage of fragment 10, even though 10 no longer exists, and keeps both records. With this change, cleanup removes both translation records. **The index segments A, B and C are kept.** ## How the new check works Start with the fragments that exist **now**, separately for each logical index: 1. If an index segment directly covers a current fragment, no translation is needed to reach it. 2. Otherwise, follow its rewrite history backwards to find old fragments stored in the index's segments. Keep the translation records needed along those paths. 3. Also keep downstream records required by any retained record, so removing history cannot break a translation chain. Coverage from one logical index cannot stand in for another's. A segment this build cannot read does not count as direct coverage, but its stored fragment IDs still prevent required history from being discarded. Partially indexed rewrite inputs are retained so that a later segment can complete their coverage. Existing rules for legacy history remain in place, and cleanup refuses to trim history containing transitions this build does not understand. A related change: if a destination fragment was deleted entirely, with no remaining live descendant needing translation, it no longer keeps its history alive. If another destination still needs that translation, the record stays. ## When this runs and what it costs **This is a cleanup operation, not an extra check on every index-segment commit.** In the current Sophon integration, GC cleanup and the remap job's cleanup phase call `cleanup_frag_reuse_index`. Ordinary writes and ordinary index-segment commits do not automatically run this calculation. Lance also exposes an explicit `TrimFragReuse` transaction action; a caller must choose to include it. It is not automatically added to ordinary transactions. The walk remembers each record's result for the duration of this calculation, so a shared transition is evaluated at most once per logical index. This removes the previous repeated scanning of wide transitions. Building and traversing the history still costs work, and a cleanup rebased over a concurrent commit may need to calculate again. This PR does not promise a fixed maintenance latency. ## Compatibility **Rust API change:** `lance_table::system_index::frag_reuse::retention::compute_tagged_retention` now requires `live_fragments`. Callers must pass the current fragment bitmap from the **same manifest** as `indices`. ## Validation Tests cover multi-step rewrites, independent logical indices, partial coverage, unreadable segment types, legacy history, deep and wide histories, and concurrent commits. Resolution-count tests verify that shared transitions are evaluated once per logical index; 400 generated histories are compared with a separate reference calculation, which shares the existing legacy predicate. Dataset tests perform real rewrites and deletes, run cleanup twice, reopen the dataset in a fresh session, and compare indexed queries with scans. They verify both sides: obsolete history is removed, while history needed by a surviving fragment remains. Executed on head `2db639ed0`: - `lance-table` library tests: **1,676 passed**. - Focused Lance tests (`tagged_trim`, `retention`, `frag_reuse`, `deleted_destination`): **722 passed, 2 ignored**. - Formatting and package-scoped clippy: **passed**. These results validate the Lance change. The combined Sophon run with the final #11292 revision is separate and is not claimed here. Co-authored-by: Claude <[email protected]>
8f00999 to
ec96a5f
Compare
|
@claude review |
ec96a5f to
2392764
Compare
|
@claude review |
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The partial-commit check preserves historical coverage and stored provenance, including partially replaced destination sets and unrelated historical segments. Segments over fragments deleted outright are removed, and concurrent drops or rebuilds of the same index remain conflicts. No blocking issues found.
For landing on main, preserve the stack order: #11399 → #11426 → this PR.
…ment reuse history Committing segments for part of an index decided which same-name segments to remove from their stored fragments alone. On a table with a tagged fragment reuse history a stored bitmap is provenance: after rewrites retire the fragments it names, the reader still translates the segment to the live fragments those rewrites produced. Two things went wrong. A segment with no live stored fragment was always removed, so a commit over unrelated fragments dropped coverage it did not replace. And a segment that was partly live could be replaced by a commit over its live fragment while another live fragment still depended on its retired one, which silently lost that fragment's coverage. A partial commit on a tagged history is now decided against the composition it would publish, using the reader's own membership rule. Segments are kept or removed whole; a stored bitmap is never narrowed. A segment with no live stored fragment stays while the published composition still derives coverage for it. A commit that would leave a live fragment without the index coverage it has now is refused, and nothing is committed. When a segment's coverage cannot be established, nothing is removed on the strength of it: such segments stay, and a removal the incoming segments do not wholly supply again is refused, or fails with the read error when failed reads are all that prevented the check. Incoming segments supply a removed segment again when they take part in coverage and store all of its fragments; a segment of an index type without a batch remapper, which the reader already leaves out, can also be replaced by segments of that type storing all of its fragments. A live segment sharing an already rewritten source fragment with the incoming segments is refused instead of serving those rows twice. Fragments a removed segment stores that are neither live nor named by the history (deleted outright) are ignored when judging whether it is supplied again, unless the history cannot be fully interpreted. A decision that rests on derived coverage must land on the version it was made on. If another commit lands first, the whole decision is made again on the latest version from the caller's original segments, up to the commit retry budget and without waiting between attempts. Before deciding again, the losing transaction is checked against the intervening versions by the ordinary conflict rules, so a concurrent drop or rebuild of the same index stays a conflict; a failed manifest write or an unknown outcome is returned as is. On error the dataset is left at the version it was called with. A retained segment that cannot be opened for the compatibility check refuses the commit with the original error's classification. Commits that cover every live fragment, index type changes, definition-only segments and tables without a tagged history behave as before. Co-Authored-By: Claude <[email protected]>
2392764 to
1bbf62b
Compare
|
@claude review |
|
Problem
A partial index commit can remove old segments that still serve current data through fragment reuse history (FRI). The commit succeeds, but fragments outside the new build lose their index coverage.
With FRI, a segment's stored fragment bitmap records where its row addresses came from. It does not describe all the current fragments that the segment can serve after rewrites.
commit_existing_index_segmentscurrently uses that bitmap's overlap with live fragments to decide which old segments to remove.Case 1: an unrelated append removes useful historical segments
P, Q, and R are segments of the same logical index:
P and Q have no stored fragment that is still live, but their index data remains useful. Committing R must not remove them merely because 0 and 1 have been retired.
Case 2: replacing direct coverage also removes translated coverage
The old commit removes A because C covers A's remaining live fragment, 3. However, fragment 11 still needs both A and B through FRI. Removing A loses coverage that C did not replace.
The new commit rejects this request without publishing a manifest. The caller can instead build over
{10}and keep A, or build over{3, 10, 11}so that removing A loses no coverage.Change
For a partial commit on a table with tagged FRI, evaluate the set of segments the commit would publish, using the same coverage and segment-membership rules as the reader:
Segments are retained or removed whole. This does not shrink stored bitmaps over unchanged index files: the old row addresses remain in those files, and hiding their provenance can cause duplicate results after a later rewrite. Requests that would retain a live segment alongside incoming segments sharing its rewritten source addresses are also rejected.
A segment whose coverage cannot be established is not treated as useless. Historical segments are kept conservatively, and a removal requires proof that the incoming segments safely replace it. Every retained segment still has to pass declaration and compatibility checks; an unreadable retained segment can therefore prevent a partial commit.
Full replacements over all live fragments, existing index-type-change rules, definition-only segments, and tables without tagged FRI keep their existing selection behavior. There is no new persisted state, file format, or public API.
Concurrent commits
A decision that depends on derived coverage or reader classification must commit against the snapshot that justified it. If another writer commits first:
Attempts share the existing default retry budget, with no added waits. Only a positively identified version race triggers another decision; write failures and unknown commit outcomes are returned rather than retried by this loop. On error, the caller's Dataset object is restored to its entry snapshot. Commits that do not need this snapshot constraint continue to use ordinary rebasing.
Compatibility and failure-handling details
Validation
Regression tests cover both examples above, successful replacement once coverage is complete, combinations of old and incoming segments, duplicate-source rejection, deleted fragments, unreadable metadata and vector files, unsupported history, and types without batch remapping. They check unchanged manifests on refusal and indexed results without duplicate rows after successful commits.
Concurrency tests cover compatible appends and rewrites, same-index drop and rebuild conflicts, unrelated index drops, and failed conditional manifest writes. Read-failure tests verify that the identical request succeeds after recovery.
On head
1bbf62bfa(rebased ontomainatdda3823cd; the commit-window check now lives inlance-table-runtime, wheremainmoved the commit loop):cargo test -p lance --lib: 11,955 passed, 0 failed, 9 ignored. This includes two new regressions: one commits a segment for only part of a rewrite's destinations and checks that the historical segment stays unchanged for the rest until those are covered too; the other commits a segment for one rewrite's destinations while an unrelated historical segment serves another rewrite's destinations, and checks after reopening that the unrelated segment is unchanged and still answers indexed lookups.cargo test -p lance-table-runtime: all passed.cargo clippy -p lance-table-runtime -p lance --tests -- -D warnings: passed, with-A unreachable_codeadded for the pre-existing aarch64-only warnings inlance-encoding.Coverage limits: incoming segments with uninterpretable details and retired provenance, exhaustion of the full re-decision budget, and retained vector formats this build cannot open are covered at the decision/classification level, not by end-to-end tests.