Home/Labs/ACID & Crash Recovery
All 280 Labs
INTERACTIVE LAB🧾

ACID & Crash Recovery Lab (Interactive)

Run a bank transfer through the WAL, crash it mid-flight, and watch ARIES replay. Commit a transfer with synchronous or group-committed fsync, kill power at any step, and see which edits redo, which undo, and how many acknowledged transactions are lost.

ACID Bank Transfer & ARIES Crash Recovery

Drive a two-statement transfer step by step, pull the plug mid-flight, and watch the WAL make it all-or-nothing.

Account A (sender)$500
Account B (receiver)$200
Ledger invariant A + B$700 / $700 ✅ Consistency
Tx state: IDLE
Write-Ahead Log — 0/0 records fsynced
Begin a transaction to see undo/redo records appended…
Durable transfers
$0
Acked, not fsynced
$0
Commit throughput
1,000 TPS
RPO on next crash
$0

Experiment: crash mid-transfer with sync ON (Undo phase saves you — Atomicity). Then flip synchronous_commit OFF, commit twice, and crash — the acked money vanishes while constraints stay valid: a pure Durability breach. Batch slider shows why group commit buys 1× the TPS for one fsync.

How It Works Under the Hood

Atomicity and durability share one mechanism: the Write-Ahead Log. Before a transaction is acknowledged, its WAL record is fsynced to disk — RAM-only page writes survive because recovery replays them, and half-finished work is rolled back with undo records. ARIES runs Analysis, Redo, and Undo passes on boot. The durability knob is fsync timing: synchronous_commit flushes per commit for slow-but-safe writes, while group commit batches many commits into one fsync, multiplying TPS but risking acknowledged-but-unflushed work in a crash.

Core Architectural Principles

  • Durability = WAL Redo records fsynced before the commit ACK; atomicity = Undo records for uncommitted transactions.
  • Group commit amortizes one fsync across many concurrent commits, spiking throughput while shrinking the durability window it covers.
  • On restart, ARIES replays committed-but-unflushed changes and undoes half-finished transactions, restoring the ledger invariant.
Interview Round Script

Explain ACID as subsystems, not definitions: undo/redo logging, checkpoints, and ARIES phases. Quantify durability — a commit is only safe once its WAL segment is fsynced, and group commit can lose acknowledged transactions inside the batch window. That nuance signals production experience rather than textbook recall.

Key Trade-Offs

Stronger durability guarantees mean more fsyncs, lower TPS, and higher commit latency; weaker ones trade a small crash-loss window for speed.

Related Curriculum Chapter

ACID Properties (Atomicity, Consistency, Isolation, Durability)

Read Full Chapter Blueprint

Explore More Interactive Labs

View All 280 Labs