Cohesive Systems logoCOHESIVE SYSTEMS

Write-Ahead Logging

Write-Ahead Logging, or WAL, is a storage recovery pattern in which durable recovery records are written before the corresponding state changes are allowed to become unrecoverable.

The core rule is that the log record describing a change must reach stable storage before the changed data page or state image can be relied on after failure. A commit record must be durable before the system reports the transaction as committed. This lets recovery reconstruct a coherent state by replaying, undoing, or completing work according to the durable log.

WAL realizes persistence, reconstitution, and recovery for a storage or transaction boundary. It supports ACID durability and atomicity by making the recovery history more authoritative than any one cached page, memory image, or interrupted write.

Common WAL structures include:

  • Log sequence numbers.
  • Transaction identifiers.
  • Update records.
  • Commit and abort records.
  • Checkpoints.
  • Dirty-page and transaction tables.
  • Redo and undo information.
  • Compensation Log Records.

ARIES is the canonical database recovery design built around WAL. It uses analysis, redo, and undo phases after restart. Its Compensation Log Records, or CLRs, record undo actions in the log so recovery can repeat history safely, resume interrupted rollback, and avoid undoing the same action twice.

WAL is not the same as event sourcing. WAL records are usually internal storage-engine recovery material. Event-sourced records are committed domain events that are addressable in the application model. Both make durable ordered history central, but they assign different meanings to the records.

WAL is also not the same as saga compensation. ARIES Compensation Log Records are storage-engine recovery records for undo. Saga compensation is a semantic forward action, command, or process step across boundaries.

External References

Related concepts: storage systems, ACID, persistence, reconstitution, recovery, concurrency control, event sourcing, sagas and process managers, durable execution.