{"id":"btree-wal-before-data","text":"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.","truth_value":"IN","source":"entries/2026/05/28/b-tree-storage-engine-btree.md","source_url":"","source_hash":"","justifications":[],"dependents":[],"metadata":{"example":"# WAL entry written before page modification\nwal_entry = struct.pack(\">II\", page_num, len(data)) + data\nself._wal_fd.write(wal_entry)\nos.fsync(self._wal_fd.fileno())\n# then write data page"},"explanation":{"steps":[{"node":"btree-wal-before-data","truth_value":"IN","reason":"premise"}]}}