{
  "slug": "torn-write",
  "term": "Torn write",
  "aliases": [
    "partial page write"
  ],
  "definition": "A torn write is an interrupted write that persists only part of its intended update, potentially leaving a database page with mixed old and new contents.",
  "note": "A database page may span several storage write units, so a page write cannot automatically be treated as atomic. PostgreSQL documents full-page images as protection for recovery from this failure. Transaction atomicity and page-write atomicity describe different boundaries. Torn-write protection permits the complete old value instead of a mixture; it does not by itself make the replacement durable. Linux RWF_ATOMIC requests this protection for one supported direct-I/O range.",
  "status": "shipping",
  "advantages": [],
  "limitations": [
    {
      "text": "A transaction log containing only change records may not reconstruct a partially written page.",
      "citationIds": [
        "pg-settings"
      ]
    }
  ],
  "related": [
    "full-page-write",
    "write-ahead-log",
    "crash-consistency",
    "power-loss-protection",
    "rwf-atomic",
    "statx-write-atomic",
    "raid-write-hole",
    "lost-write"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "citations": [
    {
      "id": "pg-reliability",
      "title": "PostgreSQL 18: Reliability",
      "url": "https://www.postgresql.org/docs/18/wal-reliability.html",
      "accessed": "2026-10-11"
    },
    {
      "id": "pg-settings",
      "title": "PostgreSQL 18: WAL settings",
      "url": "https://www.postgresql.org/docs/18/runtime-config-wal.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": "pwritev2",
      "title": "Linux man-pages 6.19, readv(2): RWF_ATOMIC",
      "url": "https://man7.org/linux/man-pages/man2/readv.2.html",
      "accessed": "2026-10-12"
    },
    {
      "id": "hesela-atomic",
      "title": "Linux atomic writes: untorn does not mean durable",
      "url": "https://hesela.com/analyses/linux-atomic-writes-durability/",
      "accessed": "2026-10-12"
    }
  ],
  "updated": "2026-10-12"
}
