Repository navigation
feat(index): maintain tagged fragment reuse histories - #9161
Conversation
|
Adjudicated both rounds against the code; the pruning concerns were real and are fixed, the trim concerns were already structural. Pruning validated nothing before removing: fixed in 5db67d4. Removals were derived through the lenient reader path, which only logs on unsupported records, so an old client could prune a segment whose coverage flows through a transition it cannot interpret, and commit that removal before trim's refusal fired. The strict ledger check now sits inside Pruning race on rebase: confirmed and fixed in 867ae45. The removal-only shape fell through every re-derivation branch in Trim from a stale view: already handled. The trim is re-derived against the manifest actually being committed onto during every rebase ( |
867ae45 to
841ccf0
Compare
841ccf0 to
819d2c3
Compare
819d2c3 to
001f1d6
Compare
36e8791 to
b73c691
Compare
b73c691 to
3ed9d13
Compare
…9107) ## What this adds This PR connects scalar and vector index loading to the common version-1 FRI reader. It applies the coverage and translation plan produced for each index segment while keeping version-0 FRI on its existing synchronous path. ```text stored index segment │ ▼ snapshot FRI plan ├── Identity → use the existing plugin load path ├── Translate → load through asynchronous batch remapping └── No coverage → omit the segment and scan ``` An unaffected segment receives no remapper, so existing and external plugins continue using their normal loader. A segment that requires translation is retained only when its consumer supports batch row-ID remapping; otherwise its destination coverage falls back to scanning. ## Index consumers The shared batch-remapping path is used by: - B-tree, bitmap, zone map, Bloom filter, RTree, label-list, NGram, and inverted/FTS scalar indices. - Vector partition storage, including PQ-backed storage. Consumers translate physical row IDs in batches, preserve result order and deletion handling, and avoid building a partition-sized per-row lookup table. Vector loading preserves its existing partition and quantization layouts. Version-0 FRI continues to use the original synchronous remapper and plugin APIs. A separate version-1 identity state ensures an unaffected segment never receives a synthetic legacy remapper merely because the dataset contains version-1 history. ## Query planning and caching The version-1 plan is built once per dataset snapshot and cached by manifest identity. It records each segment’s derived coverage and the fragments owned by newer selected segments. Warm segment opens reuse this plan instead of recalculating whole-dataset coverage. Direct destination segments take precedence over older translated segments. When a logical index needs multiple source segments to cover a destination, all required contributors are selected; omitting one forces scan fallback for that destination. Fragment-restricted vector queries also scan when their selected segments do not provide complete coverage. Cached objects are keyed by what they depend on. Content decoded without translation (identity segments, version-0 histories, no history, the IVF state entry) lives in the plain per-index namespace and stays warm across commits. Content that embeds translated addresses (pages, postings, partitions loaded through a translating remapper) lives under a namespace named by the segment's translation identity: a hash of its live coverage, its sibling exclusions on its path's destinations, the fingerprints of the transitions on its path, and whether the ledger dropped unsupported records. Such an entry goes cold exactly when that state changes (a transition on the path trimmed or replaced, a fragment on the path dropped, a sibling taking direct ownership of a path destination) and survives appends and rewrites of fragments the segment never covered. The FRI entry's UUID is not part of the key: every rewrite and trim mints a new one. Staged segments. A segment built but not yet committed (the distributed build flow: `execute_uncommitted` per fragment, then merge, then commit) is unknown to the snapshot plan. `open_row_id_remapping_with_plan` / `open_scalar_index_with_plan` open one segment through a caller-supplied plan; the existing entry points are the `None` case. The cache namespace still follows the resolved remapping. The planner that builds such plans for a staged group, and the staged merge itself, land in #9161. Two boundaries. A legacy-layout full-text (inverted) segment, whose per-document lengths cannot be translated, is excluded from coverage on a tagged table and its fragments are scanned; a full-text query must then name its column, since a column-less query discovers columns from the usable segments. Segment-only selection (`with_index_segments` without a fragment list) answers from the selected segments only, by contract, where the pre-FRI path fell back to a flat search; pass the fragment list to get the coverage guard and the flat fallback. ## Validation End-to-end tests cover all supported scalar and vector consumers, multi-segment source coverage, two-source/two-destination rewrites, deleted rows, partial and filtered queries, direct destination precedence, reconverging lineage, unsupported plugins and index versions, scan fallback, cache reuse, prewarm, append/delete/checkout, and eager/deferred compaction. A version-0 lifecycle suite covers scans, filtered queries, writes, compaction, optimization, historical checkout, remapping, and cleanup while asserting that version-0 datasets never enter the new asynchronous path. Validated with workspace Clippy and `cargo fmt --all`. The python and java lockfiles carry the new `blake3` dependency (CI runs `--locked`); the staged-group planner that an earlier revision of this PR carried moved to #9161 with its consumers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The rebased maintenance patch preserves the reviewed tagged-history behavior. The new heap-pinned IVF remap path reduces compaction caller-stack use without changing index data or coverage; focused compaction/remap and legacy lifecycle cases pass. The synchronized tagged write-path prerequisite still needs to land first, and its corrected ANN-withdrawal regression remains green.
|
The |
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The tagged write-path prerequisite #9139 has merged into this base, satisfying the prior sequencing condition. The maintenance patch is unchanged from the reviewed revision; focused tagged-merge, staged-index, and remap/trim tests pass on this head.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The rebase preserves tagged coverage through the Bitmap segment merger introduced by #9290 and keeps staged vector contract validation separate from query visibility. Focused staged-build, vector-contract, Bitmap-merge, and remap/trim regressions pass on this head; no blocking issue remains.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The rebase preserves tagged maintenance alongside the stable-row-ID deferred-compaction contract introduced by #9514. Focused lifecycle, concurrency, and tagged regressions pass, including retaining needed mappings and retiring them after index catch-up. No blocking issue remains.
Maintenance for tagged fragment reuse histories (FRI index_version 1) on top of the commit path: trimming the entry to what retained versions and index segments still derive through, pruning superseded segments, collecting unreferenced row maps, and remapping under the legacy v0 rules where a segment has caught up. Merging segments on a tagged table keeps translated coverage: the merge opens the sources through the translating loader, the merged segment claims the union of its sources' stored provenance plus the newly indexed fragments, and retired provenance stays on the lineage when a segment commits. Staged segments (built uncommitted, merged later) are planned as one group with the reader's own steps and replayed across every commit since their build, so a recorded transition keeps the provenance while an in-place column rewrite withdraws that transition's coverage; a bare compaction of a covered fragment or a version that can no longer be read refuses the merge with a rebuild error. Withdrawn coverage is rebuilt by optimize_indices from the live fragments, and the snapshot plan records why a segment derives no coverage so maintenance can act on it. After a v0 deferred-remap upgrade, the optimize merge translates the old file into live addresses but keeps the min source stamp and the provenance union, so the legacy version stays pinned until a remap advances the stamp. Windows Python CI crashed with a stack overflow in the eager compact_files tests once this PR sat on the commit-preparation layer below: at opt-level 0 every arm of the eleven-arm remap_index_file_v3 dispatch materializes its builder future as a stack temporary. Each arm now moves its builder into a heap-pinned future and IvfIndexBuilder::remap boxes merge_partitions (remap_index future 13264 to 2560 bytes, eager compaction minimum stack 872 to 632 KiB on macOS at opt-level 0). Test futures that CI clippy reports as large are boxed. Claude-Session: https://claude.ai/code/session_01DgAshYD7wVzPVdjXRuWPPs Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The unchanged maintenance patch integrates with #9620: cleanup and remapping honor the new pre-rewrite watermark, while commit retries preserve the latest required mappings. Focused staged-build, cleanup-race, retry, and v0-to-tagged upgrade regressions pass on this head. No blocking issue remains.
Summary
Makes index maintenance work after FRI-backed row movement: merge or rebuild indexes, retire unused mapping history, and reclaim unreferenced files.
Builds on #9139. Stable-partition remapping follows in #9187.
What changes and why
optimize_indices.Limits and validation
Unknown history prevents destructive maintenance. Staged NGram segments crossing stable partition require rebuilding. Replay cost grows with the commits crossed; replacing overlapping committed siblings can reduce coverage elsewhere to scan fallback.
Tests cover merge/rebuild correctness, staged-build races, incomplete history, concurrent cleanup, retained snapshots, and legacy upgrades. Windows and CI-profile Clippy are checked at this PR's own head.