Torn write
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.
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.
In 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. [8]
Constant 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. [6] Coverage of sector-aligned cuts does not establish coverage of every byte cut. [9]
Relations
- 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, Transactional Flash (TxFlash)
Limitations
- A transaction log containing only change records may not reconstruct a partially written page. [2]
Citations
- PostgreSQL 18: WAL settings
- Zheng et al.: Understanding the Robustness of SSDs under Power Fault, FAST 2013, sections 3.1-3.1.1, 4.2 and 5.3.
- SQLite: Powersafe Overwrite, scope, assumptions and torn pages.
- Hesela: SSD power-loss protection, evidence and qualification boundaries