Write-Ahead Log

Summary: The Write-Ahead Log (WAL), also known as a redo log, is an append-only file on disk used to ensure durability and crash recovery for data structures that are updated in-place.

Sources: chapter3

Last updated: 2026-04-15


Function

In storage engines like b-trees, every modification must be written to the WAL before it can be applied to the data pages. If the database crashes, the log is used to restore the system to a consistent state (source: chapter3).

Use in Log-Structured Engines

LSM-trees also use a WAL to protect the in-memory memtable. Once the memtable is flushed to an sstables segment on disk, the corresponding WAL entries can be discarded (source: chapter3).