12 releases (5 breaking)

Uses new Rust 2024

0.8.5-alpha Dec 3, 2025
0.8.3-alpha Nov 27, 2025
0.7.0-alpha Nov 5, 2025
0.6.0-alpha Oct 31, 2025
0.3.5-alpha Oct 20, 2025

#339 in Database implementations

25 downloads per month
Used in 6 crates (2 directly)

Apache-2.0

2MB
45K SLoC

Transaction management and MVCC (Multi-Version Concurrency Control) for LLKV.

This crate provides transaction isolation using MVCC semantics. Each transaction operates with a consistent snapshot of the database, determined by its transaction ID and snapshot timestamp.

Module Organization

  • core: Core MVCC primitives (TxnIdManager, TransactionSnapshot, RowVersion) - currently mvcc module
  • table: Table-level MVCC integration (row filtering, builders) - currently helpers module
  • context: Transaction context types (SessionTransaction, TransactionSession, TransactionManager)
  • types: Data type definitions (TransactionResult, TransactionKind, TransactionCatalogSnapshot)

Key Concepts

  • Transaction ID (TxnId): Unique 64-bit identifier for each transaction
  • Snapshot Isolation: Transactions see a consistent view of data as of their start time
  • Row Versioning: Each row tracks when it was created and deleted via created_by and deleted_by columns
  • TransactionSnapshot: Captures transaction ID and snapshot timestamp

Reserved Transaction IDs

  • TXN_ID_NONE (u64::MAX): Indicates no transaction (uninitialized state)
  • TXN_ID_AUTO_COMMIT (1): Used for auto-commit (single-statement) transactions
  • IDs 2+: Multi-statement transactions (allocated by TxnIdManager)

Visibility Rules

A row is visible to a transaction if:

  1. It was created before the transaction's snapshot (created_by <= snapshot_id)
  2. It was not deleted, or deleted after the snapshot (deleted_by == TXN_ID_NONE || deleted_by > snapshot_id)

Architecture


LLKV Transaction

llkv-transaction implements the MVCC substrate used across the LLKV database toolkit. It allocates transaction IDs, enforces snapshot isolation, and persists commit metadata so row visibility stays deterministic.

This crate is not intended for direct standalone use.

License

Licensed under the Apache-2.0 License.

Dependencies

~29MB
~520K SLoC