Skip to main content

Module mvcc

Module mvcc 

Source
Expand description

Multi-version concurrency control primitives (Phase 11).

This module is the foundation for SQLRite’s BEGIN CONCURRENT story — see docs/concurrent-writes-plan.md for the full sequenced design.

Surface as of Phase 11.3:

  • MvccClock — process-wide monotonic u64 counter that hands out begin- and commit-timestamps. Persisted to the WAL header so timestamps don’t reuse the same value across reopens.
  • ActiveTxRegistry — tracks the begin-timestamps of in-flight transactions; ActiveTxRegistry::min_active_begin_ts is the GC watermark.
  • TxId / TxTimestampOrId — types the version chains carry.
  • MvStore — the in-memory version index. Holds row chains keyed by RowID; read(row, begin_ts) implements the snapshot-isolation visibility rule (begin <= T < end).
  • JournalMode — per-database setting toggled by PRAGMA journal_mode = …. Wal (default) keeps every pre-Phase-11 read path in place; Mvcc is the opt-in that 11.4 will wire reads through.

The executor doesn’t consult MvStore yet — that wiring lives in 11.4 alongside BEGIN CONCURRENT writes. Decoupling the data structure (this PR) from the read/write integration (next PR) keeps the diffs reviewable.

Re-exports§

pub use clock::MvccClock;
pub use log::MVCC_BODY_MAGIC;
pub use log::MVCC_FRAME_MARKER;
pub use log::MvccCommitBatch;
pub use log::MvccLogRecord;
pub use registry::ActiveTxRegistry;
pub use registry::TxHandle;
pub use registry::TxId;
pub use registry::TxTimestampOrId;
pub use store::MvStore;
pub use store::MvStoreError;
pub use store::RowID;
pub use store::RowVersion;
pub use store::RowVersionChain;
pub use store::VersionPayload;
pub use transaction::ConcurrentTx;

Modules§

clock
MvccClock — the logical-clock primitive that hands out begin- and commit-timestamps for MVCC transactions (Phase 11.2).
log
MVCC commit log records — the WAL-resident representation of BEGIN CONCURRENT writes (Phase 11.9).
registry
ActiveTxRegistry — the live-transaction table that garbage collection consults to know which row versions are still possibly visible (Phase 11.2).
store
MvStore — the in-memory version index sitting in front of the pager (Phase 11.3 skeleton).
transaction
ConcurrentTx — per-Connection BEGIN CONCURRENT transaction state (Phase 11.4).

Enums§

JournalMode
Selects the durability + concurrency story a database operates under. Toggled by PRAGMA journal_mode = … (see crate::sql::pragma::execute_pragma).