Every time you commit a bank transfer, place an online order, or save a document, a database promises you something remarkable: that data will not vanish, even if the server loses power a millisecond after you press Submit.
How can it make that promise? Flushing every changed data page to disk on every commit would work, but a random write to disk is slow — far too slow for a busy database. Write-ahead logging (WAL) is the elegant escape hatch: instead of rewriting scattered data pages immediately, the database first appends a compact description of the change to a sequential log file and flushes that. Sequential writes are much faster than random ones, and once the log record is on stable storage, the commit is durable by definition.
The rule is simple to state: the log record must reach disk before the corresponding data-page change can be declared committed. Everything else in crash recovery flows from that one invariant. If the system crashes, the database replays the log forward (REDO) to reconstruct committed changes and rolls back uncommitted ones — restoring a consistent state with no human intervention.
WAL is not exotic research; it is the proven engineering backbone of PostgreSQL, MySQL InnoDB, SQLite, and virtually every other ACID-compliant database in production today.
Comments
Loading comments...