Skip to main content

Crate reifydb_transaction

Crate reifydb_transaction 

Source
Expand description

Transactional layer over the storage tier: opens a read or read-write transaction, accumulates deltas, validates conflicts, and commits atomically. The crate offers two flavours - a multi-version path for OLTP traffic that needs snapshot isolation, and a single-version path for workloads where versioning would only add overhead - and exposes both behind a uniform Transaction handle that the engine threads through every request.

Every change recorded inside a transaction is captured as a delta, surfaced through the change accumulator, and published downstream so CDC consumers, replication, and subscriptions observe the same write set the engine just committed. Interceptors hook the commit boundary and let policy, audit, and consistency checks run with full visibility into what is about to be written.

Invariant: a TransactionId is unique system-wide and monotonic via Uuid7; downstream consumers (CDC, replication, subscriptions) order events by transaction id, so reusing or back-dating an id silently breaks consumer consistency.

Modules§

change
change_accumulator
delta
error
interceptor
multi
Multi-version transactional path. Owns the conflict detector that decides whether a write transaction can commit at its read snapshot, the watermark machinery that tracks the lowest still-readable version for GC, and the oracle that hands out commit versions in monotonic order. Read, write, and replica transaction bodies are the three concrete shapes a multi-version transaction can take.
single
Single-version transactional path. No snapshot isolation, no conflict detector, no version oracle - a write transaction sees its own buffered changes and commits them atomically against the underlying single-version store. Suitable for OLTP workloads that do not need history and are willing to take last-writer-wins semantics between concurrent writers in exchange for less overhead.
transaction
Public Transaction handle. Wraps either a single-version or multi-version transaction body in a uniform shape so callers in the engine, planner, and policy layers do not branch on backend. Exposes the get/set/range primitives, delta accumulation, commit, the shape-resolution helpers, and the admin-only mutations the catalog tier needs.

Structs§

TransactionId
TransactionVersion