btree-wal-before-data

Status: IN

Every page mutation is logged to the WAL (with fsync) before being written to the data file; recovery replays the WAL, so no committed write is lost on crash.

Source: entries/2026/05/28/b-tree-storage-engine-btree.md

Example

# WAL entry written before page modification
wal_entry = struct.pack(">II", page_num, len(data)) + data
self._wal_fd.write(wal_entry)
os.fsync(self._wal_fd.fileno())
# then write data page

JSON