Repository navigation
feat(transaction): implement the index management actions - #8645
Conversation
c6a7e75 to
361a1b4
Compare
361a1b4 to
1b1bf31
Compare
1b1bf31 to
c56f4ca
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c56f4ca to
1589925
Compare
1589925 to
e376707
Compare
6ecaa35 to
b90947c
Compare
1090ca2 to
d8b20e5
Compare
b071969 to
77c2d88
Compare
This comment has been minimized.
This comment has been minimized.
| )) | ||
| }) | ||
| }) | ||
| .collect() |
There was a problem hiding this comment.
I think there might be an issue with Local id handling but I think you're aiming to separate that out from this work? RN I tried it with actual index files and a concurrent append. The fragment gets a different ID on retry, but the index files still point to the old row addresses, so the query misses rows.
If you're aiming for later maybe reject local for now?
There was a problem hiding this comment.
You're right: on retry a Local fragment gets a new id, but nothing rewrites the row addresses baked into the index files, so they point at the old fragment. Yes, appending and indexing in one commit is being handled in follow-up PRs, not here.
Until then, the supported path is reservation first, as in the #7954 spec: commit ReserveFragmentIds, then add the fragments as Ref::Committed(reserved_id) and build the segment against those ids. A reserved id doesn't move under replay, so the addresses stay valid.
geruh
left a comment
There was a problem hiding this comment.
Overall looks good to me! Tested with staged transaction prototyping, and left a comment.
| fragment_id, | ||
| &fields, | ||
| &self.current_manifest.schema, | ||
| ) |
There was a problem hiding this comment.
While working on staged transactions, I noticed this check only uses the original schema. I think we need to check the working schema too.
If we add a child z under s, build an index segment on z, then rewrite s in the same operation, the original schema doesn't know about z, so the segment keeps coverage for the rewritten fragment.
The footprint uses both:
lance/rust/lance/src/io/commit/conflict_resolver/check.rs
Lines 130 to 139 in 4a5c7c0
There was a problem hiding this comment.
Good catch, fixed in c8b1f3e: rebinding now resolves field ancestry in both the base and the working schema, so a child added earlier in the operation is covered. Test: test_rewriting_a_struct_prunes_an_index_on_a_child_added_in_the_same_operation.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… added in the same operation Co-Authored-By: Claude Opus 5.5 <[email protected]>
A rewrite of a struct must prune an index on a child the same operation added, which only the schema being built knows about. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
The same-operation nested-field gap is fixed: rewriting a parent now prunes coverage for a child added and indexed earlier in that operation. No blocking findings remain.
Bytewise index-detail claims protect concurrent writers without mirroring vector protobufs, but compatible builds with different serialized details may conservatively conflict; concurrent writers need matching details.
Merged #10761 validates actual files for raw legacy commits and checks search contracts. Raw composite additions can still publish mixed-metric segments, but indexed search fails visibly rather than returning mixed rankings. This remains a recoverable index-availability risk. Use commit_existing_index_segments for compatibility validation; .use_index(false) keeps flat scanning available after an incompatible raw commit, and removing or replacing the incompatible segment restores indexed search. No additional repair is requested here.
For files embedding row addresses, the reservation-first contract still applies: reserve fragment IDs in an earlier commit, then use Ref::Committed IDs. Local coverage resolution does not relocate addresses inside index files.
BREAKING CHANGE:
lance_table::transaction::action::Actiongains theAddIndexSegment,RemoveIndexSegment,AdjustIndexCoverage, andDropIndexvariants, andCoordinategainsIndexSegment, so exhaustive matches on them must handle the new variants.Stacked on #8644. Implements the index actions, lowers the legacy
CreateIndexonto them, and lets two writers extend one index at once. No format change: the wire shapes are in #7954. Supersedes #8630 and #8641.A logical index is the set of segments sharing a name, so the actions operate on segments: creating and extending an index are the same action, and dropping one removes each segment.
Two writers can extend one index
Legacy
CreateIndexconflicts on index name alone. Since the query path unions segments, that rule is replaced with a claim on the index. Two claims conflict when they cover overlapping committed fragments, when either doesn't state its coverage (the system indices), or when they disagree on fields, carried fields, or index details. Details are compared byte for byte, sincelance-tabledoesn't decode them, so concurrent writers to one vector index need identical details (e.g. an explicittarget_partition_size). Fragments the operation mints itself are left out, since no concurrent writer can cover them.Apply is looser, since its errors are permanent: segments of one index must share fields and index type and not overlap, but their details may differ.
commit_existing_index_segmentsstill checks vector compatibility against the existing segments; raw action commits don't, as on main (#10728).RemoveIndexSegmentandAdjustIndexCoveragecarry the indexname, and apply rejects a segment that turns out to belong to a different index.Index builds and concurrent data changes
A segment requires the data it covers, so a concurrent data-changing write to an indexed field, or to a field containing or nested in it, conflicts with the build. Two changes don't:
data_change = false), which moves values without changing them;DropIndexremoves every segment under a name as they stand at apply, and conflicts with any concurrent segment added under that name.__lance_frag_reuseis rejected here; it gets its own actions in #8646.Example
Two writers index different fragments of
by_aconcurrently. Their coverage doesn't overlap, so both commit, and the index is the union of their segments:Under legacy
CreateIndex, the second to commit would conflict on the name.Stricter than legacy
The
CreateIndexlowering is checked by building the manifest both ways and comparing index metadata. These are rejected where legacy tolerates them:dataset_versionother than the read version;AdjustIndexCoverageon a segment that records no coverage.The remaining actions are in #8646 and are rejected on load until then.
🤖 Generated with Claude Code