Skip to content

feat(transaction): implement the index management actions - #8645

Merged
wjones127 merged 3 commits into
mainfrom
will/transaction-v2-index-actions
Nov 18, 2026
Merged

wjones127 merged 3 commits into
mainfrom
will/transaction-v2-index-actions

Conversation

@wjones127

@wjones127 wjones127 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

BREAKING CHANGE: lance_table::transaction::action::Action gains the AddIndexSegment, RemoveIndexSegment, AdjustIndexCoverage, and DropIndex variants, and Coordinate gains IndexSegment, so exhaustive matches on them must handle the new variants.

Stacked on #8644. Implements the index actions, lowers the legacy CreateIndex onto 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 CreateIndex conflicts 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, since lance-table doesn't decode them, so concurrent writers to one vector index need identical details (e.g. an explicit target_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_segments still checks vector compatibility against the existing segments; raw action commits don't, as on main (#10728).

RemoveIndexSegment and AdjustIndexCoverage carry the index name, 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:

  • a re-encode (data_change = false), which moves values without changing them;
  • removing a covered fragment, which a reader translates through the fragment reuse history or drops from coverage.

DropIndex removes every segment under a name as they stand at apply, and conflicts with any concurrent segment added under that name. __lance_frag_reuse is rejected here; it gets its own actions in #8646.

Example

Two writers index different fragments of by_a concurrently. Their coverage doesn't overlap, so both commit, and the index is the union of their segments:

// Writer A
Action::AddIndexSegment(AddIndexSegment {
    name: "by_a".into(),
    covered_fragments: Some(vec![Ref::Committed(0), Ref::Committed(1)]),
    ..
})
// Writer B, concurrently
Action::AddIndexSegment(AddIndexSegment {
    name: "by_a".into(),
    covered_fragments: Some(vec![Ref::Committed(2), Ref::Committed(3)]),
    ..
})

Under legacy CreateIndex, the second to commit would conflict on the name.

Stricter than legacy

The CreateIndex lowering is checked by building the manifest both ways and comparing index metadata. These are rejected where legacy tolerates them:

  • removing a segment the manifest doesn't have, or adding one whose uuid is taken;
  • an explicit dataset_version other than the read version;
  • after apply, segments of a touched index that disagree on fields or index type, or overlap in coverage;
  • AdjustIndexCoverage on a segment that records no coverage.

The remaining actions are in #8646 and are rejected on load until then.

🤖 Generated with Claude Code

@wjones127

This comment has been minimized.

@wjones127

This comment has been minimized.

@wjones127
wjones127 force-pushed the will/transaction-v2-index-actions branch from c56f4ca to 1589925 Compare September 21, 2026 17:12
@wjones127
wjones127 force-pushed the will/transaction-v2-index-actions branch from 1589925 to e376707 Compare September 21, 2026 17:43
@wjones127
wjones127 force-pushed the will/transaction-v2-index-actions branch 2 times, most recently from 6ecaa35 to b90947c Compare September 21, 2026 20:11
@wjones127
wjones127 force-pushed the will/transaction-v2-index-actions branch 2 times, most recently from 1090ca2 to d8b20e5 Compare September 21, 2026 22:13
@wjones127
wjones127 force-pushed the will/transaction-v2-index-actions branch 4 times, most recently from b071969 to 77c2d88 Compare September 22, 2026 23:46
@wjones127

This comment has been minimized.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

))
})
})
.collect()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

@geruh geruh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me! Tested with staged transaction prototyping, and left a comment.

fragment_id,
&fields,
&self.current_manifest.schema,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

let schemas = [self.read_schema.as_ref(), self.current_schema.as_ref()];
let footprint = |operation| {
schemas
.iter()
.flatten()
.fold(Footprint::from(operation), |footprint, schema| {
footprint.with_field_ancestry(schema)
})
};
if footprint(ours).conflicts_with(&footprint(theirs)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

wjones127 and others added 3 commits November 17, 2026 11:25
… 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]>

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Gate recommendation: approve with a non-blocking risk.

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.

@geruh geruh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants