Skip to main content

Module clock

Module clock 

Source
Expand description

MvccClock — the logical-clock primitive that hands out begin- and commit-timestamps for MVCC transactions (Phase 11.2).

Per docs/concurrent-writes-plan.md:

A monotonic u64 counter, per-Database. Hands out begin_ts at BEGIN CONCURRENT and commit_ts at the start of validation. Wrapped in AtomicU64; no contention because each transaction calls it twice.

The clock is persisted to the WAL header on each checkpoint so reopens resume past the highest committed timestamp — see crate::sql::pager::wal::WalHeader::clock_high_water. Without persistence, two transactions on either side of a reopen could receive the same timestamp and the snapshot-isolation visibility rule (begin <= ts < end) would mis-classify one of them.

Structs§

MvccClock
Process-wide logical clock. Cheap to clone — internally an Arc over an AtomicU64 in the Database wiring (added in Phase 11.3). Standalone today.