Skip to main content

Module wal

Module wal 

Source
Expand description

Write-ahead log (L2).

The WAL is the durability layer that sits between the pager and the main file. Writes go to an append-only sidecar (<main>-wal) first; a checkpoint (M3 issue #16) later rolls them into the main file. Recovery / replay on open is implemented by Wal::open_for_recovery (M3 issue #15).

See docs/format.md § Write-ahead log for the byte layout this module is the reference implementation of, and § Recovery semantics for the algorithm open_for_recovery enacts.

§Power-of-ten posture

  • Rule 2. Every loop in this module is bounded — either by a Vec’s length (txn buffer) or by the WAL file’s frame-count limit (recovery, added in #15).
  • Rule 5. Per-frame salt, per-frame crc32c, commit-marker pivot, and the file-level magic are layered defenses against torn writes and stale generations. Every decision is driven by an explicit invariant check, not an implicit cast.
  • Rule 7. No unwrap / expect in production code paths.
  • Rule 8. All file I/O goes through crate::platform; this module is #![forbid(unsafe_code)].

Modules§

frame
WAL frame encode / decode helpers.

Structs§

Recovered
Result of walking an on-disk WAL during recovery.
Wal
The write-ahead log.
WalConfig
WAL construction options.
WalTxn
An in-progress WAL transaction.

Constants§

DEFAULT_CHECKPOINT_THRESHOLD
Default automatic-checkpoint threshold, in frames. When the WAL has more than this many frames committed, the pager will call its checkpoint routine inline (M3 issue #16).
DEFAULT_WAL_SIZE_LIMIT
Default size cap on the WAL file, in bytes. The cap exists so that a runaway “write without ever committing or checkpointing” workload cannot make recovery walk unboundedly many frames (power-of-ten Rule 2).

Functions§

remove_wal
Remove the WAL file at path. Idempotent — missing-file is OK.

Type Aliases§

Lsn
Log sequence number.