Repository navigation
feat(transaction): action-based transaction wire format (Transaction V2) - #7954
Conversation
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: QUIET Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Important This PR touches the Lance format specification. Substantive changes to the format specification — the If this is a meaningful format change:
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
19ac8e0 to
f53d35a
Compare
f53d35a to
5422956
Compare
5422956 to
132c3b4
Compare
4734fe4 to
ddafb45
Compare
Self-review pass (polish-pr), 2026-09-20DecisionNo code changes. The diff is mechanical apart from the new wire schema and one fail-closed decode arm; the self-review found nothing here that should be auto-applied, because every finding either pins a proto field number or reshapes a message, and the field numbers ripple through all three PRs above this one. StatusOpen. The items below want a decision before the vote pins the tags. Open questionsWire schema:
Tests and process:
🤖 Generated with Claude Code |
Legacy conflict characterization run against this PR (burn-down item 14)Decision#9220's characterization suite passes unchanged on this PR: 42 passed, 0 failed, 6 ignored, ~2s. StatusVerified 2026-09-20. Nothing in the stack changes legacy conflict behaviour. Options and criteriaThe suite's branch ( Method: for each PR, a throwaway branch off the PR head, merge Results, all four layers:
#8644 is the layer that matters most here — it is the one that touches Open questions
🤖 Generated with Claude Code |
geruh
left a comment
There was a problem hiding this comment.
Went through this and the stacked PRs, and this LGTM!
There was a problem hiding this comment.
Delta actions with relocatable IDs remain a reasonable foundation for compound commits and replay. This rebase preserves the assessed wire contract and adds inspection-only CompositeOperation summaries to lance-tools, reporting step and action counts without enabling V2 execution. Acceptance makes the current wire field numbers and meanings durable compatibility commitments.
This remains a format-only change, with no V2 writer or executor. Core transaction loads fail closed. Merged #9482 supplies manifest field 23, allowing unaware readers to open and scan while transaction-history reads and concurrent older writers can fail safely. The earlier findings remain addressed.
The write-path contract still includes:
- Required-field coverage after data-file or required-schema changes; committed references within the read version’s allocation bounds, including earlier reservations; duplicate local-token rejection within each ID space; correct drop ordering and index-coverage preconditions. Independent keyed/carried declarations must lower without loss, rejecting overlap until the manifest supports it.
- Absent
data_changemeans true. Paireddata_change=falsere-encodes preserve raw base values without applying overlays, retain overlays, index coverage and row versions, and commute with overlays, matching merged #9705. Re-encodes still count as writes against cell/key assertions. - Partial row-version refresh uses whole-fragment or bitmap selections, preserves unselected versions, leaves
created_atuntouched, and defaults previously untracked rows to version 1. - Fragment-reuse append/trim uses the latest history, excludes stable-row-ID indices in either admission order, and is discarded by
ResetTable. Missing translation falls back to scanning. Direct coverage takes precedence over translated coverage, as in merged #9068 and #9107; overlapping metadata can remain for maintenance.
The author’s chosen follow-up for the MemWAL incarnation-identity gap remains an accepted, non-blocking limitation of this format-only vote; incarnation fencing is still needed when enabling a V2 writer.
Runtime enforcement of these contracts—including bitmap/row bounds, mapping payloads and replay/trim races—remains unverified here, not a merge prerequisite for a PR that cannot write V2 transactions. Read-derived writes still need AssertCellsUnchanged. Adoption costs remain an earlier ID-reservation commit for append-plus-index/delete, and per-field metadata overhead for wide appends.
The new renderer has a focused regression test, but I could not execute it locally because the repository’s pinned Rust toolchain is unavailable in this environment.
westonpace
left a comment
There was a problem hiding this comment.
There's a lot here so this is partially a YOLO review. We will probably have some tweaks and lessons learned with time but I think the overall premise of multiple operations separate from user intention is the direction we want to head.
| - "protos/table.proto" | ||
| - "protos/fragment_metadata.proto" | ||
| - "protos/transaction.proto" | ||
| - "protos/transaction/*.proto" |
There was a problem hiding this comment.
Will this miss transaction.proto now? I don't think that file is entirely removed.
There was a problem hiding this comment.
transaction.proto has been moved to protos/transaction/transaction.proto
| writer [feature flags](../../table/versioning.md#current-feature-flags) to guard against this. | ||
| writer [feature flags](../../table/versioning.md#current-feature-flags) to guard against this, | ||
| whatever the FRI index version. A tagged history on such a table sets it alongside | ||
| `FLAG_FRAGMENT_REUSE_INDEX`. |
There was a problem hiding this comment.
Is this change making things more clear?
| FRI translates row addresses, so it applies only to indices that store row addresses. Tagged | ||
| histories (`index_version >= 1`) are allowed on tables with stable row IDs, but an index that | ||
| stores stable row IDs must not coexist with a tagged entry: writers must refuse to record a | ||
| transition while such an index exists, and to add such an index while a tagged entry exists. |
There was a problem hiding this comment.
I think we want to block row-id-domain-index and FRI regardless of FRI version. This paragraph makes it seem like we only block tagged FRIs.
|
|
||
| A `CompositeOperation` holds `UserStep`s, each a human-recognizable step with | ||
| a description, which in turn hold the granular `Action`s applied to the | ||
| manifest. The two levels support multi-statement transactions: each statement |
There was a problem hiding this comment.
We should be careful about the term "multi-statement transaction". The classical multi-statement transaction allows for reads after earlier steps in the transaction have executed. This leads to phenomenon like "repeatable reads", "phantom reads", etc. and the definition of classic isolation levels.
I don't think that is what is being proposed here.
There was a problem hiding this comment.
We are actually moving towards that. A big part of the changes in these protos is about referring to changes earlier in the transaction, such as the idea of "local" ids in the transaction. Drew is working on the library side of this, where we'll actually be able to do things like make updates and create indexes referencing data added or modified during a transaction. So the "multi-statement transaction" reference is intentional.
| Every fragment must store data for each required field, one that is | ||
| non-nullable and has only non-nullable ancestors; a fragment without it would | ||
| read the field back as nulls. Apply checks each fragment whose data files the | ||
| operation sets. When the operation makes a field required, by adding it as | ||
| non-nullable or by making it non-nullable, apply checks every fragment. |
There was a problem hiding this comment.
This isn't harmful but seems out of place or slightly extraneous.
There was a problem hiding this comment.
Agreed. i'll remove it.
| One vocabulary detail is a format contract rather than an implementation | ||
| choice. `AddIndexSegment.fields` names only the columns the segment is keyed | ||
| on, and `covering_fields` is an independent declaration of the columns whose | ||
| values it carries, so the segment's dependency set is the union of the two. | ||
| This is the contract an index action targets, not the legacy one where | ||
| `IndexMetadata.fields` means keyed columns followed by carried columns. A | ||
| declaration whose two lists overlap can only be represented by a manifest | ||
| declaring `FLAG_INDEPENDENT_COVERING_FIELDS`; until a release implements that | ||
| flag, apply rejects the overlapping form and lowers a disjoint one to the | ||
| legacy subset representation. |
There was a problem hiding this comment.
Again, slightly related but also slightly extraneous. Can we add a validation section or something that lists validation requirements run against any kind of transaction (composite or otherwise)?
There was a problem hiding this comment.
Added a Validation section under Commit Protocol listing the checks every commit runs, legacy or composite (required-field data, non-empty data files, unique fragment IDs, field ID allocation), in eb02eb5. Dropped the covering-fields paragraph; AddIndexSegment's docs in actions.proto and "Covering-field contracts" in index/index.md already cover it.
| Actions apply in order, with one exception: `ReserveFragmentIds` and | ||
| `ReserveRowIds` are summed and taken after the operation's own mints, wherever | ||
| they appear. A reservation creates nothing another action can reference, so | ||
| this has no other visible effect within the operation, and a fragment can claim | ||
| a reserved id only from an earlier commit's reservation. `ResetTable` discards | ||
| objects but never rewinds the id counters. |
There was a problem hiding this comment.
Do you think placeholders remove the need for reserving fragment ids entirely?
There was a problem hiding this comment.
Yes. In fact, we should deprecate reservations. It's impossible for us to validate a later transaction was done by the same system that did a reservation, so it's possible with reservations to create duplicate fragment ids. Not something I'm super worried about, but it's a fragile point in the current design. Something gatefixer has complained about.
| `data_change` is per action, and absent means true. `false` asserts the action changes no row's | ||
| values: the rows it adds, removes, or rebinds are the same logical rows with | ||
| the same values before and after, as when compaction moves rows or a column | ||
| file is re-encoded. Change-data-capture readers emit rows only from | ||
| `data_change = true` actions, and one operation may mix both. |
There was a problem hiding this comment.
It's slightly odd that "absent means true" but maybe too late in the game to rename to something like data_unchanged or data_preserved
There was a problem hiding this comment.
Ah I see. This is because protobuf defaults to false? I'm open to changing that now.
There was a problem hiding this comment.
Done in d2d0be1: actions now carry a plain bool data_unchanged (default false = changed), so omitting it is still the conservative reading without relying on presence.
| * An assertion (precondition), not a delta: the declared cells -- the cross | ||
| * product of `fields` and `rows` -- hold the values they held at the | ||
| * operation's read version. Conflict detection otherwise compares only what | ||
| * two operations write (snapshot isolation), so a writer whose values depend | ||
| * on what it read (an update computing `a = b`) must declare the read here. | ||
| * | ||
| * "Unchanged" follows the cell preconditions proposed for the legacy | ||
| * transaction (#9121): a cell counts as changed if its field was dropped or its | ||
| * definition altered, its fragment was removed, the data file carrying its | ||
| * field was replaced (a re-encode included), or an overlay touching it was | ||
| * added. A change to the deletion | ||
| * vector does not count. Implementations may over-reject (e.g. at fragment | ||
| * granularity) but must never under-reject. | ||
| */ | ||
| message AssertCellsUnchanged { | ||
| /* | ||
| * The fields read. Committed schema field ids only: a field minted in the | ||
| * same operation has no prior value. | ||
| */ | ||
| repeated FieldRef fields = 1; | ||
| // The rows read, one entry per fragment. | ||
| repeated RowSelection rows = 2; | ||
| } |
There was a problem hiding this comment.
Is this new or have I just fallen behind on what actions we have?
There was a problem hiding this comment.
This is new. It's shaped like the proposal in #9121
|
|
||
| A `CompositeOperation` holds `UserStep`s, each a human-recognizable step with | ||
| a description, which in turn hold the granular `Action`s applied to the | ||
| manifest. The two levels support multi-statement transactions: each statement |
There was a problem hiding this comment.
We are actually moving towards that. A big part of the changes in these protos is about referring to changes earlier in the transaction, such as the idea of "local" ids in the transaction. Drew is working on the library side of this, where we'll actually be able to do things like make updates and create indexes referencing data added or modified during a transaction. So the "multi-statement transaction" reference is intentional.
| Every fragment must store data for each required field, one that is | ||
| non-nullable and has only non-nullable ancestors; a fragment without it would | ||
| read the field back as nulls. Apply checks each fragment whose data files the | ||
| operation sets. When the operation makes a field required, by adding it as | ||
| non-nullable or by making it non-nullable, apply checks every fragment. |
There was a problem hiding this comment.
Agreed. i'll remove it.
| Actions apply in order, with one exception: `ReserveFragmentIds` and | ||
| `ReserveRowIds` are summed and taken after the operation's own mints, wherever | ||
| they appear. A reservation creates nothing another action can reference, so | ||
| this has no other visible effect within the operation, and a fragment can claim | ||
| a reserved id only from an earlier commit's reservation. `ResetTable` discards | ||
| objects but never rewinds the id counters. |
There was a problem hiding this comment.
Yes. In fact, we should deprecate reservations. It's impossible for us to validate a later transaction was done by the same system that did a reservation, so it's possible with reservations to create duplicate fragment ids. Not something I'm super worried about, but it's a fragile point in the current design. Something gatefixer has complained about.
| `data_change` is per action, and absent means true. `false` asserts the action changes no row's | ||
| values: the rows it adds, removes, or rebinds are the same logical rows with | ||
| the same values before and after, as when compaction moves rows or a column | ||
| file is re-encoded. Change-data-capture readers emit rows only from | ||
| `data_change = true` actions, and one operation may mix both. |
There was a problem hiding this comment.
Ah I see. This is because protobuf defaults to false? I'm open to changing that now.
| * An assertion (precondition), not a delta: the declared cells -- the cross | ||
| * product of `fields` and `rows` -- hold the values they held at the | ||
| * operation's read version. Conflict detection otherwise compares only what | ||
| * two operations write (snapshot isolation), so a writer whose values depend | ||
| * on what it read (an update computing `a = b`) must declare the read here. | ||
| * | ||
| * "Unchanged" follows the cell preconditions proposed for the legacy | ||
| * transaction (#9121): a cell counts as changed if its field was dropped or its | ||
| * definition altered, its fragment was removed, the data file carrying its | ||
| * field was replaced (a re-encode included), or an overlay touching it was | ||
| * added. A change to the deletion | ||
| * vector does not count. Implementations may over-reject (e.g. at fragment | ||
| * granularity) but must never under-reject. | ||
| */ | ||
| message AssertCellsUnchanged { | ||
| /* | ||
| * The fields read. Committed schema field ids only: a field minted in the | ||
| * same operation has no prior value. | ||
| */ | ||
| repeated FieldRef fields = 1; | ||
| // The rows read, one entry per fragment. | ||
| repeated RowSelection rows = 2; | ||
| } |
There was a problem hiding this comment.
This is new. It's shaped like the proposal in #9121
Co-Authored-By: Claude Opus 5.5 <[email protected]>
BREAKING CHANGE: In
lance_table::format::pb, the generatedpb::transaction::UpdateMap,UpdateMapEntry,KeyExistenceFilter,BloomFilter,ExactKeySetFilter, andkey_existence_filter::Datamoved to the newlance_table::format::pb_actionsmodule, andpb::transaction::Operationgains aCompositeOperationvariant, so exhaustive matches on it must handle it. The wire encoding of existing messages is unchanged.Defines the wire format for action-based transactions (Transaction V2): a
CompositeOperationthat replaces the single legacyOperationwith an ordered list of granular, composableActiondeltas. This is the format change only — read-side fail-closed, no write path. Every protobuf and spec change the implementation stack needs lands here, so the format is a single vote; the PRs stacked on top of it change no.protofile or format doc.Layout
The V2 vocabulary lives in its own files under
protos/transaction/, and its messages in their ownlance.transactionpackage, apart from the table messages inlance.table(which already has an unrelatedAddDataFile, a fragment-tree mutation). In Rust, the generated code islance_table::format::pb_actions.actions.proto— the V2 vocabulary (Ref,CompositeOperation,UserStep,Action+ the action messages), with the design rationale summarized in an in-tree file header so it stands on its own.common.proto— shared building blocks (UpdateMap,KeyExistenceFilter, …) referenced by both legacy operations and V2 actions, promoted from nestedTransactionmessages to top-levellance.transactionmessages to avoid a circular import. Wire-compatible: field numbers unchanged and none areAny-packed.transaction.proto— moved into the directory; keeps theTransactionenvelope, legacy operations, and the newcomposite_operationoneof arm (field 116).What's in the wire format
Design principles (fully documented in
actions.proto):AddDataFile,TombstoneFieldData), so compound commits and branch merge fall out uniformly.Localtoken via a singleRefand relocate on merge/rebase; reference-stable changes key off stable coordinates and keep a post-image with a derivable delta.AddField/DropField/ identity-preservingAlterField(rename and nullability;logical_typeis reserved and rejected at apply, so a cast isDropField+AddField+ data). No wholesaleSetSchema.AddIndexSegment/RemoveIndexSegment/AdjustIndexCoverage(a logical index is the segments sharing aname; per-segment config duplication is a pre-existing limitation this draft doesn't fix).AssertUniqueKeyscarries merge-insert's non-derivable key-existence filter as an explicit precondition.RefreshRowVersionMetadatarestamps are on the wire, as a per-fragmentRowSelection(whole fragment or an offsets bitmap), because they can't be derived from the files a change writes.optionalfields.Settled by the implementation
These started out in the PRs stacked above and were pulled down here so the format is voted on once:
UserOperationbecomesCompositeOperation, naming what distinguishes it from the other operations, and loses itsdescription— the per-stepUserStep.descriptionis what keeps history readable.UserActionis renamedUserStep(field numbers unchanged), so the step a user recognizes is not confused with theActions it holds.Ref, so an action can name a field the same operation is minting.AddIndexSegmentgainsbase,created_at, anddataset_version, and itscovered_fragmentsbecomes an optional wrapper rather than a barerepeated. A bare repeated field cannot distinguish "no coverage recorded" — what the MemWAL and fragment-reuse indices carry, and what the query path treats as "serve this segment" — from "covers no fragment", which it treats as "skip it".dataset_versionis a correctness gate rather than provenance: an overlay committed at or before it counts as already folded into the index.RemoveIndexSegmentandAdjustIndexCoveragecarry thenameof the logical index the segment belongs to, which is what conflict detection compares.update_compacted_ss_tablesoneof arm is named to match itsUpdateCompactedSsTablesmessage, which is what the action vocabulary keys the wire encoding off.AddFragmentcarries a spilled row lineage sequence as aRowLineageColumnarm, exactly asDataFragmentdoes since feat(format): define hidden row lineage columns #9253: the sequence is a hidden column of one of the data files the fragment'sAddDataFileactions add.SetDeletionFile.fragmentis committed-only because the deletion file path embeds the fragment id; an explicitAddIndexSegment.dataset_versionmust equal the read version for now;ResetTablediscards actions before it in the same operation.Worked examples
Add a column and its data in one commit
A new field has no id until the commit lands. The data files name it by the token its
AddFieldminted, so readers never see the column without its data:At apply,
Local(0)resolves to the next field id, and both files are stamped with it. Replaying the set onto a newer version re-resolves the token against that version's counter.Caveats
_deletions/{fragment_id}-{read_version}-{id}.{ext}), and apply does no IO, soSetDeletionFiletakes a committed id. An index segment's files likewise record real fragment ids and row addresses. CommitReserveFragmentIdsfirst. Then write the fragments asRef::Committed(reserved_id)and build the deletion file or segment against those ids.AddIndexSegment.fieldsacceptsLocal(0), but every index builder reads the column through the committed schema. Commit the column first, then build and add the segment.Library changes (minimal, fail-closed)
Read-side rejection only:
TryFrom<pb::Transaction>returnsError::NotSupportedfor aCompositeOperation, with a comment forbidding lenient parsing (thetry_collectcontract aborts a concurrent V2 commit rather than silently skipping it).test_composite_operation_rejected_on_load.lance-toolsmanifest output names aCompositeOperationand counts its steps and actions, since its operation match is exhaustive.No
Operationenum variant, noapply/ translation / conflict resolution, no write path, no Cargo feature gate, no Python/Java changes.Verification
lance-table+lancebuild; new test passes;cargo fmt --allandcargo clippy -p lance-table -p lance --tests -- -D warningsclean.🤖 Generated with Claude Code