patternModeratepending
Write-ahead log (WAL) -- durability and crash recovery
Viewed 0 times
WALwrite-ahead logdurabilitycrash recoveryappend-onlyreplayAOF
Problem
Databases, message queues, and file systems need to survive crashes without data loss or corruption. Writing directly to data structures risks partial writes on crash.
Solution
Before modifying data, write the intended change to an append-only log. On crash recovery, replay the log to restore consistent state. Used by: PostgreSQL WAL, SQLite WAL mode, Kafka commit log, Redis AOF, LevelDB/RocksDB. Benefits: sequential writes (fast), crash recovery, replication (ship log to replicas), point-in-time recovery.
Why
Appending to a log is the simplest atomic operation: either the entry is written or it is not. Complex data structure updates can then be rebuilt from the log, ensuring consistency.
Revisions (0)
No revisions yet.