Write-ahead log
A write-ahead log is a recovery log whose relevant records must become durable before the corresponding changes are persisted in database data files.
Write-ahead logging names the ordering protocol; the write-ahead log is its record stream. PostgreSQL can replay logged changes after a crash, so committing a transaction need not flush every modified data page. A record in a memory buffer is not yet a durable record. Preserving older WAL for point-in-time recovery is a separate archive-retention task. [4] SQLite's alternative rollback journal stores before-images; its WAL-mode atomicity applies per database, not to a multi-file ATTACH transaction as a set. [5] Replication-slot retention serves a consumer's catch-up needs; it does not replace a separately preserved recovery archive. [6]
Relations
- related
- Database checkpoint, Full-page write, fsync, Persistence ordering, Crash consistency, Log sequence number, Point-in-time recovery, WAL archiving, Rollback journal, SQLite super-journal, Checkpoint starvation, SQLite WAL end mark, RocksDB column family, RocksDB atomic flush, Group commit, Asynchronous commit, Replication slot, Logical decoding, Doublewrite buffer, LLAMA, Frangipani, LevelDB
Advantages
- Allows changed data pages to be written later while preserving logged recovery information. [1]
Limitations
- Recovery still depends on storage honoring synchronization requests. [2]
Citations
- PostgreSQL 18: Write-Ahead Logging
- PostgreSQL 18: Reliability
- PostgreSQL 18: Continuous Archiving and Point-in-Time Recovery
- SQLite: ATTACH DATABASE, atomicity across files
- PostgreSQL 18: replication slots and WAL retention