Repository navigation
feat(index): commit stable-partition rewrites on the tagged fragment reuse history - #9139
Conversation
|
On the remaining item: that ordering is structural to this stack, not an open question. #9136 is the first PR of the stack and is currently under the format vote; nothing above it merges before it lands on main, and this branch will be synchronized onto the landed spec before acceptance. The tagged contract and the 1024 capability flag implemented here are exactly what #9136's current revision defines, and the spec PR stays frozen while the vote runs so the voted text and this implementation cannot drift. Confirming the resolved items for the record: ambiguous-commit ownership now compares durable transaction forms only (6e76f58, with unit plus two end-to-end ambiguity tests; the defect predated this PR, since the in-memory field has participated in equality since #3847), folded destination deletion counts are bound to their validated bitmaps (same commit), and system metadata (FRI and MemWAL) bypasses tagged coverage filtering (433d8c4). |
433d8c4 to
12182e0
Compare
12182e0 to
b1ec265
Compare
17593cc to
4f25dc8
Compare
4f25dc8 to
0ae8e5f
Compare
21e723b to
dea6345
Compare
…reuse history The write path of tagged fragment reuse histories (FRI index_version 1). A fragment rewrite commits its transitions atomically through the entry `Operation::Rewrite::frag_reuse_index` has always carried: the complete entry the caller wants installed, built from the snapshot at the transaction's read version (`frag_reuse_entry_appending`). The commit path diffs it against the entry at that version, refuses an entry that drops or changes recorded history (add-only; trim retires records), and at every attempt merges the additions onto the entry current at commit, revalidates and CASes, so concurrent disjoint rewrites merge and a distributed compaction planned at V commits from a later driver handle. The first tagged commit lifts a v0 entry byte-verbatim and sets the sticky FLAG_FRAGMENT_REUSE_INDEX fence; version-0 tables keep their behavior byte-identically. Each commit attempt prepares before it builds: `Transaction::prepare_indices` reads the index list current at the attempt, keeps it as the original list, runs the tagged-table gate and derives a prepared list on which an in-place column rewrite has withdrawn (along the history) or pruned (by fragment id) the coverage it invalidates; `Transaction::build_manifest_prepared` applies the operation and publishes only the final list, comparing MemWAL coverage against the original one. `ManifestBuildConfig` keeps main's fields; what the commit path settled about the entry travels as `FragReuseUpdate`. One withdrawal implementation serves the preparation and the conflict resolver's CreateIndex rebase; a remainder the reader would load as it is after retired sources were withdrawn goes with them and is rebuilt. Normal mutations (deletes, row-rewriting updates, config and schema changes, overwrite, restore) are admitted on a tagged table; overlaid sources, stable-row-id tables and unknown mappings are refused. Deletions that land after a rewrite's scan can be folded into destination deletion vectors with exact accounting. Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The prepared fragment-reuse update is now explicitly non-exhaustive, and the comments describe its per-attempt assembly accurately. The tagged rewrite, index-coverage, and distributed-compaction paths are otherwise unchanged from the previously verified revision; the affected Rust crates compile on this head. No blocker remains.
|
The |
Summary
Adds the write/commit path for FRI-backed stable-partition rewrites. Rewritten data and its row-address mapping become visible together, allowing existing indexes to keep serving rows after reclustering without rebuilding those indexes in the same job.
Query-time address translation is provided by #9107. This PR makes the corresponding writes safe; index maintenance and history cleanup follow in #9161.
Why this is needed
An index stores row addresses, not just values. If reclustering moves a row from
F1:20toF3:10, the index still points toF1:20. FRI records how to reach the new address.The commit path must preserve three things:
What this PR implements
1. Publish the rewrite and mapping atomically
The caller writes destination fragments and the row-map file, then submits a
Rewritecarrying the complete FRI entry it built from its read snapshot.Before committing, Lance validates that the mapping records match the rewrite's sources and destinations, including row counts and deletion state. Both the fragment replacement and the FRI entry are published in the same manifest commit.
A job can also fold newly observed source deletions into destination deletion vectors. The commit path validates that accounting; it does not silently accept a mapping computed against stale deletion state.
2. Merge concurrent additions instead of replacing history blindly
Two jobs can start from the same history and rewrite different fragments. Installing either job's complete snapshot unchanged would lose the other job's additions.
On every commit attempt, Lance extracts only the records the caller added relative to its read version, then merges those additions into the latest history. This allows disjoint rewrites to commit and avoids resurrecting history removed by cleanup. Conflicting rewrites are rejected.
Distributed compaction uses the task's original read snapshot even when submitted through a newer dataset handle. Rewrite submissions are add-only: removing history remains cleanup's responsibility.
3. Keep column updates safe without forbidding them
Moving a row preserves its indexed value; rewriting an indexed column does not. For example, an index entry for
price = 10becomes stale if that row's price changes to 20, even when FRI can still find the row.The commit withdraws affected index coverage, so queries scan those rows until maintenance rebuilds it. For a translating segment, this can withdraw an entire transition's contribution, not just the edited fragment.
Index preparation runs again against the latest state on retries. The final manifest uses the prepared list; MemWAL bookkeeping retains the original list as its comparison baseline.
Compatibility and boundaries
Operation::RewriteandManifestBuildConfigfields remain unchanged.defer_index_remap = true.prepare_indiceswhen needed for coverage withdrawal.Validation
Tests cover concurrent rewrites, retry idempotence, cleanup races, distributed compaction, deletion folding, and column updates racing index creation. Coverage-withdrawal queries are compared with index-disabled scans, including nested fields and partial withdrawal.