Definition
A write-ahead log (WAL) is an append-only file to which a database writes every change before applying it to the main data structures. Because appends are sequential and fsynced, a committed transaction survives a crash: on restart, the database replays the log to redo committed changes and roll back incomplete ones. The WAL is the mechanism behind the D (durability) in ACID.
The same idea recurs across systems infrastructure: the append-only log is the durability primitive in LSM-tree storage engines (the memtable's WAL), the replication stream shipped to replicas, and — generalized — the entire data model of Kafka. Writing sequentially first and updating structures later is one of the most reusable patterns in storage design.
How it comes up in interviews
"How does the database not lose data on a crash?" is the direct probe. The stronger signal is recognizing the pattern elsewhere — explaining that replicas consume the WAL stream, or that a message log is a WAL turned into a product, marks a candidate who understands storage rather than memorized ACID.