Updated Transaction Model #3734
Replies: 5 comments 16 replies
-
If constructing transactions is somehow confusing, why make every write() a single transaction, then merge could help. I mean there will be more read_version and blob operation need be handled? Or is there something missed here |
Beta Was this translation helpful? Give feedback.
-
Can we put a DDL like drop_column and merge_column into one transaction? cause we have met the demand to implement a update_column operation(update the whole column by a stream or udf) |
Beta Was this translation helpful? Give feedback.
-
@wjones127 I discussed with @majin1102 a bit on the transaction topic in #4219, want to revive this thread a bit: could you clarify a bit about the data model we envision for transactions? I see in the prototype, we are designing this 4 layer transaction layout in Given right now we have the conflict resolver, the logic for committing a list of transactions could basically be:
One question becomes now that the committed transaction file need to include all the transaction information. Maybe this is why you are saying why we need a composite operation? |
Beta Was this translation helpful? Give feedback.
-
Why not just use a nested transaction list like:
We could have whatever we want layers transactions. Typical the leaf transactions under the same parent should share the same read_version(as well as uuid I think). none-leaf transactions should be equavilent to the 'UserOperation' you metiond(merged by detached mode?). From format specification, this seems easier to be explained as 'nested transactions'. WDYT @wjones127 @jackye1995 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
TLDR
Introduce
CompositeOperation
to allow aTransaction
with multiple operations in one.The new operation type could also be an opportunity to solve several other long-standing issues with transactions.
Design goals
Primary goal: Allow merging multiple transactions into one.
Part of merging will need to be conflict resolution. To make this possible, transactions need to serve as true diffs between manifests. In some respects already they do: an Append operation shows the new fragments added. But other operations are not helpful: in
Update
operation, we just provide the new fragments, but it's unclear which data files were modified. If we want to detect conflicts thoroughly, we need to be able to tell from just the transaction what changed.Secondary goals we can accomplish while refactoring transactions:
history
metadata table from Iceberg)Use cases
If
Transaction
can be merged, this unlocks three different use cases:Use case 1: Higher write TPS
Currently, each transaction requires committing a new manifest to storage. This makes the sequential writing of this file a bottleneck. If you can merge transactions, then you could batch many operations, and commit several at once.
Use case 2: Simplified distributed commits
Right now, when users do distributed writes, they have to construct transactions themselves. This means handling the
read_version
andblob_operation
themselves, which can sometimes be confusing. If instead we made each partial change return a transaction, we could merge these transactions later before committing the overall operation.This is already implemented for append, where you can use InsertBuilder::execute_uncommitted() to write new data files, and it returns a
Transaction
. Meanwhile CommitBuilder::execute_batch() can take an array ofTransaction
.Use case 3: Multi-statement transactions
Combining successive transactions could also be used to do multi-statement transactions. To make successive operations see the one before, this would have to be combined with detached commits. We could make several detached commits, then take the transaction files from those commits, merge them, and use that to commit the multi-statement transaction.
Proposed design
An early prototype exists here: #3204
Provide a new
CompositeOperation
type that is meant to be a generic operation type. It will be three levels:CompositeOperation
represents the full operation that is applied to create the next version of the manifestUserOperation
, which represent a logical user-facing operation. (For example, delete multiple rows.)UserOperation
contains multipleActions
, which represent a single change to the manifest.To apply a
CompositeOperation
to create a new manifest, simply apply the flattened list ofAction
s in order.Example
Consider the SQL query:
Could be represented as a single
CompositeOperation
:lance/protos/transaction.proto
Lines 93 to 124 in 5ea6589
Beta Was this translation helpful? Give feedback.
All reactions