Skip to content

feat(transaction): implement the remaining drafted actions - #8646

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

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

Conversation

@wjones127

@wjones127 wjones127 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

BREAKING CHANGE: lance_table::transaction::action::Action gains the AddOverlays, RefreshRowVersionMetadata, UpdateCompactedSsTables, AssertUniqueKeys, AssertCellsUnchanged, AppendFragReuseTransition, and TrimFragReuse variants, and Coordinate gains FragmentRowVersions, so exhaustive matches on them must handle the new variants.

Stacked on #8645. Implements the rest of the Transaction V2 vocabulary and lowers DataOverlay, UpdateMemWalState, and the vertical form of Update onto it. With this every specified action is implemented. No format change: the wire shapes are in #7954. Supersedes #8632.

Example

Appending rows and asserting their keys are new, in one commit. A concurrent insert that doesn't say which keys it carries makes this conflict, since there is nothing to compare against:

CompositeOperation::new(vec![UserStep::new("insert new customers", vec![
    Action::AddFragment(AddFragment { id: Ref::Local(0), physical_rows: 500, .. }),
    Action::AddDataFile(AddDataFile { fragment: Ref::Local(0), file, .. }),
    Action::AssertUniqueKeys(AssertUniqueKeys {
        key_fields: vec![FieldRef::Committed(0)],
        filter: inserted_key_hashes,
    }),
])])

Conflict rules

Overlays are partial writes of a field in a fragment. Two overlays commute (the newer committed_version wins each cell), and so does an overlay with a re-encode, which keeps row offsets. A full rewrite of the column conflicts in either order, as does a row-moving update, which would re-create the rows without the overlay's values.

Key assertions are preconditions, not changes. Keys are user-supplied, so two writers can insert the same key into their own fragments with disjoint coordinates. The manifest doesn't record which keys exist, so AssertUniqueKeys carries the merge insert's key-hash filter. Two sets are compatible only when both state their inserted keys over the same columns and the filters provably don't intersect; anything unverifiable conflicts. Any data-changing AddFragment counts as inserting rows, which over-approximates: rows a merge insert updates also land in a new fragment.

Declared reads: AssertCellsUnchanged names the cells an operation read, and any concurrent write to them conflicts, a re-encode included. Without it, two updates that each set one column from the other's both commit, which no serial order produces.

Row versions

RefreshRowVersionMetadata takes a RowSelection per fragment (whole fragment or an offsets bitmap) and sets those rows' last_updated_at_version to the commit version. It's explicit because the rows a change restamps aren't implied by the file it writes: RewriteColumns and merge_insert's partial-fragment path write a whole column file but restamp only matched rows. On a stable-row-id table, a data-changing AddDataFile on an existing fragment requires a refresh covering it.

Fragment reuse history

AppendFragReuseTransition records which rows compaction moved, and TrimFragReuse drops entries no index segment still needs. Both apply to the history as it stands at commit, so concurrent compactions don't conflict over it. The commit path loads an external history before building the manifest and spills one that outgrows the inline limit; cleanup collects row maps from failed compactions. Tagged histories on stable-row-id tables are debug-build-only for now (#10446).

Rejected rather than tracked

These are refused rather than modeled, at the cost of a retry or an unsupported case:

  • Assertions on nested targets: lists, maps, fixed-size lists, unpacked structs, and struct children.
  • Data changes (overlays, data-changing files or tombstones) to a fragment the same operation added as a rearrangement (data_change = false). Fragment reuse destinations must be added that way.
  • A composite commit whose conflict window includes a cleaned-up version gets a retryable conflict, since replay can't recheck what it depended on.

Differences from legacy

  • Update translates only in its vertical form. RewriteRows and RewriteColumns, like Merge and Project, depend on what the read version holds and are rejected, falling back to always-retry.
  • Legacy UpdateMemWalState drops the read version's fragments from the manifest it builds; the action path keeps them. The parity test records both.
  • Key assertions are checked symmetrically, so a plain append concurrent with a merge insert conflicts in both orders. Legacy only checks from the retrying side and can let a duplicate key through.
  • An update and a column rewrite of the same fragment no longer conflict, since deletions and field data are separate coordinates.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the enhancement New feature or request label Aug 19, 2026
@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch from adc53c8 to 7955145 Compare September 3, 2026 00:12
@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch from 7955145 to 27528dd Compare September 8, 2026 19:52
@wjones127

This comment has been minimized.

@wjones127

This comment has been minimized.

@wjones127

This comment has been minimized.

@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch from 5f22f73 to 0f01a7c Compare September 21, 2026 17:13
@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch from 0f01a7c to 3d216aa Compare September 21, 2026 17:43
@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch 2 times, most recently from f565438 to 57bd279 Compare September 21, 2026 20:11
@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch from 57bd279 to 4e0e871 Compare September 21, 2026 21:23
@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch from 4e0e871 to a25511e Compare September 21, 2026 21:36
@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch from a25511e to f6b4c20 Compare September 21, 2026 22:13
@wjones127
wjones127 force-pushed the will/transaction-v2-remaining-actions branch from f6b4c20 to 3d7ac29 Compare September 21, 2026 22:33
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.

Mostly LGTM, I've been testing on top with the staged work and left a few comments on stuff i ran into.

I think these can be addressed here or in followups im fine either way

.sources
.iter()
.map(|&id| {
let fragment = self

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.

Should we use the source fragment as earlier actions left it, or reject a source that was already modified before removal?

this function reads from the current_manifest fragments while something like remove fragments can throw awat the working fragment If SetDeletionFile runs before compaction on that same fragment, we end up counting the old surviving rows. This rejects a compaction that drops the deleted row while allowing one that keeps it.

pub(super) fn remove_fragment(&mut self, fragment_id: u64, data_change: bool) -> bool {
let before = self.fragments.len();
self.fragments.retain(|fragment| fragment.id != fragment_id);
if self.fragments.len() == before {
return false;
}
self.removed_fragments.insert(fragment_id, data_change);
self.new_fragments.remove(&fragment_id);

An AddOverlays after compaction would also miss the overlay check because the original fragment had no overlays.

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 061ea57: remove_fragment now records whether the fragment still matches the committed one, and AppendFragReuseTransition rejects a source this operation modified before removing it (covers deletions, overlays, and in-place rewrites). Tests: the source_given_a_deletion_earlier_in_the_operation / source_given_an_overlay_earlier_in_the_operation cases of test_a_transition_apply_rejects, plus test_a_transition_beside_a_change_to_another_fragment for the untouched-source case. If a real use case appears, a more robust approach (digesting the source as removed) can follow.

.iter()
.filter_map(|fragment| u32::try_from(fragment.id).ok())
.collect();
Transaction::withdraw_in_place_rewrites(

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.

rebind_fields only prunes segments present when the rewrite happens, but finish_frag_reuse_history applies rebound_fields to the final index list.

On a table with tagged history, a rewrite followed by AddIndexSegment drops coverage for the rewritten fragment even though the segment was added afterward. We could probably skip segments added after the rewrite here?

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.

Will do this in a follow-up.

@@ -1648,6 +1643,42 @@ async fn build_config_for_attempt(
Ok(config)

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 here we should also load spilled row lineage for composite operations here?

this method only handles Update and DataOverlay, so a composite with AddOverlays or a partial RefreshRowVersionMetadata won't load the existing row versions. If those versions have spilled, the action fails because the metadata wasn't loaded before the commit.

The AddOverlays test supplies config.spilled_row_lineage manually, so it doesn't catch this.

let loaded = LoadedRowLineage {
last_updated_at: Some(Arc::new(RowDatasetVersionSequence::from_versions(&[
2, 3, 4,
]))),
..Default::default()
};
config.spilled_row_lineage = Arc::new(SpilledRowLineage::from([(0, loaded)]));
}
let transaction = Transaction::new(
manifest.version,
Operation::CompositeOperation(CompositeOperation::new(vec![UserStep::new(
"step",
vec![add(Ref::Committed(0), vec![overlay("new.lance", &[0])])],
)])),

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.

Will do this in a follow-up.

lance-gatekeeper[bot]

This comment was marked as outdated.

wjones127 and others added 2 commits November 17, 2026 21:23
…ed earlier in the operation

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he operation

The source digest is read from the committed fragment, so a deletion,
overlay, or in-place rewrite applied to a source before its removal made
the digest stale. Such sources are now rejected.

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 source-state blocker is fixed: recorded compactions now reject a source changed earlier in the same operation. No blocker remains.

Two bounded limitations remain: tagged-history coverage pruning can cause unnecessary scan fallback, and missing spilled-lineage loading can reject composite overlays or partial row-version refreshes. Use the legacy path for affected spilled-lineage updates.

@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.

Thanks for addressing comments!

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