Skip to main content

Module wal

Module wal 

Source
Expand description

Write-Ahead Logging (WAL) module for crash recovery.

The WAL ensures durability by logging all write operations before applying them to the database. In case of a crash, the WAL can be replayed to restore the database to a consistent state.

§Architecture

  • WalRecord: Enum representing different types of log entries
  • WriteAheadLog: Core WAL implementation with append/sync/replay
  • CheckpointManager: Manages periodic checkpoints and WAL trimming

§Example

use dbx_core::wal::{WriteAheadLog, WalRecord};
use std::path::Path;

let wal = WriteAheadLog::open(Path::new("./wal.log"))?;

// Log an insert operation
let record = WalRecord::Insert {
    table: "users".to_string(),
    key: b"user:1".to_vec(),
    value: b"Alice".to_vec(),
    ts: 0,
};
let seq = wal.append(&record)?;
wal.sync()?;  // Ensure durability

Modules§

buffer
checkpoint
Checkpoint manager for WAL maintenance and crash recovery.
encrypted_wal
Encrypted WAL (Write-Ahead Log) wrapper.
partitioned_wal
Partitioned WAL Writer — Phase 2: Section 5.1

Structs§

WriteAheadLog
Write-Ahead Log for crash recovery.

Enums§

WalRecord
WAL record types.