Recovery and Format¶
Files¶
- Data file: fixed-size ring region.
- Meta file: two metadata slots with CRC and commit counters.
Data Records¶
Each record stores:
total_len(u32)crc32(u32)seq(u64)ts_ns(u64)payload_len(u32)reserved(u32, must be0)- payload bytes (
utf-8JSON line) - alignment padding to 8-byte boundary
Special total_len value 0xFFFFFFFF marks wrap points.
Metadata Layout¶
Each slot stores:
- magic and version
- ring capacity
head,tail,seq_nextcommitcrc32
On load, the newest valid slot (highest commit) is used.
Recovery Strategy¶
On open():
- Load the newest valid metadata slot.
- Scan records from
tailtowardhead. - Stop and truncate
headat the last valid offset if corruption is found. - If scan limit is reached before
head, truncate at last validated offset. - Adjust
seq_nextif needed.
This keeps unreadable partial writes out of normal iteration.