Skip to content

feat: Add WAL Superblock And PrevLSN Chain - #4

Merged
ThomasHartDev merged 1 commit into
mainfrom
thomas/feat/wal
Sep 12, 2026
Merged

ThomasHartDev merged 1 commit into
mainfrom
thomas/feat/wal

Conversation

@ThomasHartDev

Copy link
Copy Markdown
Owner

The log was a CRC-framed byte stream with torn-tail recovery, but the file had no magic and records had no sequence numbers. This prefixes wal.log with a 32-byte superblock (FERWAL magic + version) and stamps every record with a monotonic LSN plus the previous LSN.

Replay walks the prevLSN chain and fails open if two CRC-valid records are out of order. A short superblock is treated as a torn write and rewritten. Creating the log also fsyncs the directory, because POSIX does not persist the dentry when you only fsync the file. Store::last_lsn is the durable high water mark after recovery.

Closes #3

Stamp each record with a monotonic LSN and the previous LSN so replay
can detect a hole. Prefix the file with a 32-byte magic/version header,
and fsync the parent directory when the log is created.
@ThomasHartDev
ThomasHartDev merged commit afed480 into main Sep 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stamp WAL records with LSNs and a versioned superblock

1 participant