DEV Community

Cover image for Write-Ahead Logging: How PostgreSQL & MySQL Survive Power Loss
Binary Dose
Binary Dose

Posted on Originally published at binarydose.in

Write-Ahead Logging: How PostgreSQL & MySQL Survive Power Loss

Write-Ahead Logging (WAL) & ARIES Recovery

How do databases guarantee ACID Durability without grinding write throughput to a halt?

⚡ The WAL Protocol

Before any data page in shared buffers can be flushed to table storage, the corresponding log record must already exist on non-volatile disk.

🛠️ The ARIES Phase Trio

  1. Analysis Phase: Reconstructs dirty page tables from last checkpoint.
  2. Redo Phase: Repeats history to recover state at the moment of crash.
  3. Undo Phase: Rolls back operations of all uncommitted transactions.

Read the complete storage engine lesson on Binary Dose.

Top comments (0)