Skip to main content

Module commit_log

Module commit_log 

Source
Expand description

Standalone mongreldb_log::CommitLog adapter (spec section 9.4, FND-004).

Implemented in the Stage 0 foundation wave: wraps the shared WAL and group commit so the transaction commit path proposes versioned command envelopes through the CommitLog interface, and the apply path observes only committed commands.

§Stage 0 wiring choice

The commit sequencer (Database::commit_transaction_with_external_states_inner and the DDL commit paths) keeps the existing v4 WAL record format: a full envelope dual-write would change on-disk bytes and break the “current database format opens unchanged” Stage 0 gate. Instead this adapter owns the append + group-commit durability steps those paths already performed — [Self::append_transaction] writes the transaction command’s records and its commit marker, [Self::seal_transaction] drives group commit and issues the CommitReceipt — and Database gates publish_in_order (reader visibility) on that receipt, so spec section 9.4’s critical rule (“the storage apply path receives only committed commands”) is structurally true.

Generic commands proposed through CommitLog::propose are persisted as DdlOp::Command records carrying one encoded mongreldb_log::CommandEnvelope; CommitLog::read_committed replays them with the existing WAL reader.

§Dual timestamp model (ADR-0003)

Stage 1B wires the node’s real HlcClock (spec section 8.2) through this adapter: every commit receipt’s commit_ts is allocated from the one core clock — the transaction commit path assigns it under the sequencer lock strictly after the transaction’s read timestamp (spec section 8.2’s commit-timestamp rule) — and the durable Op::CommitTimestamp WAL ledger records the same timestamp’s physical component (byte format unchanged). During the migration, however, Epoch(u64) remains the reader-visibility counter: snapshots pin epochs, row versions carry epochs, and the WAL TxnCommit marker orders by epoch. HLC timestamps are the commit/identity timestamp of record (receipts, PITR’s epoch↔nanos ledger); the epoch↔HLC row-version cut-over arrives with the section 8.4 migration work, never inferring format from byte length.

Structs§

StandaloneCommitLog
The standalone commit log (spec section 9.4): one shared WAL + one group-commit coordinator are the single authority through which commands become committed. term is always 0; the log index is the commit epoch.

Constants§

COMMAND_TYPE_TRANSACTION
Reserved CommandEnvelope::command_type for the versioned transaction command produced by the commit sequencer (spec section 9.3, FND-003).

Functions§

to_log_control
Converts core’s rich crate::ExecutionControl into the log crate’s minimal mirror (see docs/architecture/adr/0002).