{
  "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.\n\nTorn-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.\n\nIn FAST 2013, shorn writes described partial updates below the expected atomic unit; the tested SSDs included mixed old/new 4 KiB records. This historical observation does not estimate current-device risk. Powersafe overwrite is independent: it concerns unchanged bytes outside the requested range, so it can coexist with a torn target range. [sqlite-psow]\n\nConstant padding can hide an interrupted update outside the identifying header. Repeated self-describing headers help identify surviving fragments when a complete header remains. Interpreting mixed bytes as an atomicity failure requires comparison with the promised atomic unit and completion semantics; a clean endpoint does not prove an uninterrupted write. [zheng-power] Coverage of sector-aligned cuts does not establish coverage of every byte cut. [hesela-power]",
  "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",
    "physical-sector",
    "powersafe-overwrite",
    "doublewrite-buffer",
    "nvme-atomic-write-unit-power-fail",
    "txflash"
  ],
  "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"
    },
    {
      "id": "zheng-power",
      "title": "Zheng et al.: Understanding the Robustness of SSDs under Power Fault, FAST 2013, sections 3.1-3.1.1, 4.2 and 5.3.",
      "url": "https://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf",
      "accessed": "2026-11-06"
    },
    {
      "id": "hesela-sector-alignment",
      "title": "512e, 4Kn and alignment: geometry is not durability",
      "url": "https://hesela.com/analyses/sector-sizes-alignment-not-durability/",
      "accessed": "2026-10-12"
    },
    {
      "id": "sqlite-psow",
      "title": "SQLite: Powersafe Overwrite, scope, assumptions and torn pages.",
      "url": "https://www.sqlite.org/psow.html",
      "accessed": "2026-10-14"
    },
    {
      "id": "hesela-power",
      "title": "Hesela: SSD power-loss protection, evidence and qualification boundaries",
      "url": "https://hesela.com/analyses/ssd-power-loss-protection-failures/",
      "accessed": "2026-11-06"
    }
  ],
  "updated": "2026-11-13"
}
