Bedrock.DataPlane.Resolver.ConflictResolution (bedrock v0.5.2)
View SourceCore conflict detection logic for the Resolver using interval trees.
Processes transaction batches to detect read-write and write-write conflicts by checking for overlapping key ranges across different versions. Returns updated interval trees and lists of aborted transaction indices.
Each transaction is checked against the interval tree to determine if its reads or writes conflict with previously committed transactions at later versions.
Summary
Functions
Commits a batch of transactions using versioned conflicts, returning the updated conflicts structure and a list of the indexes of transactions that were aborted due to conflicts. Every transaction that can be applied, is.
Functions
@spec remove_old_transactions( Bedrock.DataPlane.Resolver.Conflicts.t(), Bedrock.version() ) :: Bedrock.DataPlane.Resolver.Conflicts.t()
@spec resolve( Bedrock.DataPlane.Resolver.Conflicts.t(), [Bedrock.DataPlane.Transaction.encoded()], write_version :: Bedrock.version() ) :: {Bedrock.DataPlane.Resolver.Conflicts.t(), aborted :: [non_neg_integer()]}
Commits a batch of transactions using versioned conflicts, returning the updated conflicts structure and a list of the indexes of transactions that were aborted due to conflicts. Every transaction that can be applied, is.
Each transaction is checked for conflicts using read and write versions.
Parameters
- conflicts: The versioned conflicts structure to check against.
- transactions: A list of transactions, each with read/write versions and operations (reads/writes) to resolve.
Returns
- A tuple with the updated conflicts and a list of transaction indexes that were aborted.
Transactions are rolled back in the order they are processed when conflicts are detected.
@spec try_to_resolve_transaction( Bedrock.DataPlane.Resolver.Conflicts.t(), Bedrock.DataPlane.Transaction.encoded(), Bedrock.version() ) :: {:ok, Bedrock.DataPlane.Resolver.Conflicts.t()} | :abort