{
  "slug": "write-ahead-log",
  "term": "Write-ahead log",
  "aliases": [
    "WAL"
  ],
  "definition": "A write-ahead log is a recovery log whose relevant records must become durable before the corresponding changes are persisted in protected data.",
  "note": "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. [pg-archive] 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. [sqlite-attach] Replication-slot retention serves a consumer's catch-up needs; it does not replace a separately preserved recovery archive. [pg-slots]\n\nScope: Write-ahead logging is not limited to database files. Mnemosyne logs new persistent-memory values before installing them at their target addresses. [mnemosyne]",
  "status": "shipping",
  "advantages": [
    {
      "text": "Allows changed data pages to be written later while preserving logged recovery information.",
      "citationIds": [
        "pg-intro"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Recovery still depends on storage honoring synchronization requests.",
      "citationIds": [
        "pg-reliability"
      ]
    }
  ],
  "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",
    "stasis",
    "mnemosyne"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "citations": [
    {
      "id": "pg-intro",
      "title": "PostgreSQL 18: Write-Ahead Logging",
      "url": "https://www.postgresql.org/docs/18/wal-intro.html",
      "accessed": "2026-10-11"
    },
    {
      "id": "pg-reliability",
      "title": "PostgreSQL 18: Reliability",
      "url": "https://www.postgresql.org/docs/18/wal-reliability.html",
      "accessed": "2026-10-11"
    },
    {
      "id": "hesela-wal",
      "title": "WAL, checkpoints and torn pages: three different recovery guarantees",
      "url": "https://hesela.com/analyses/wal-checkpoints-torn-pages/",
      "accessed": "2026-10-11"
    },
    {
      "id": "pg-archive",
      "title": "PostgreSQL 18: Continuous Archiving and Point-in-Time Recovery",
      "url": "https://www.postgresql.org/docs/18/continuous-archiving.html",
      "accessed": "2026-10-14"
    },
    {
      "id": "sqlite-attach",
      "title": "SQLite: ATTACH DATABASE, atomicity across files",
      "url": "https://sqlite.org/lang_attach.html",
      "accessed": "2026-10-14"
    },
    {
      "id": "pg-slots",
      "title": "PostgreSQL 18: replication slots and WAL retention",
      "url": "https://www.postgresql.org/docs/18/warm-standby.html#STREAMING-REPLICATION-SLOTS",
      "accessed": "2026-10-16"
    },
    {
      "id": "mnemosyne",
      "title": "Volos, Tack and Swift. Mnemosyne: Lightweight Persistent Memory. ASPLOS 2011, section 5.",
      "url": "https://pages.cs.wisc.edu/~swift/papers/asplos11_mnemosyne.pdf",
      "accessed": "2026-12-04"
    }
  ],
  "updated": "2026-12-04"
}
