Systems & Backend

Write-Ahead Log

also: WAL · redo log

Append the change to a log before touching the data — the trick behind durability in nearly every database.

A write-ahead log records every change as an append before applying it to data structures. Appends are fast and atomic; after a crash, replay the log to recover. The WAL is the backbone of ACID durability, the source CDC reads, the thing replicas replay — arguably the single most reused idea in storage systems.

Worked example: before changing a data page, the database appends the change to a sequential write-ahead log and flushes that; if it crashes mid-write, on restart it replays the log to recover — durability without random-write cost. Gotcha: the write-before-page ordering is the whole point; the WAL also feeds replication (ship it to replicas), but an unbounded log fills the disk, so checkpointing and retention need tuning.