Segments
A segment is one file in wal/. Segments are read in id order.
File names
Section titled “File names”| Name | Meaning |
|---|---|
seg-<id:016x>.wal |
WAL format 1 |
seg-<id:016x>.w<N>.wal |
WAL format N, for N at least 2 |
None of the format N files exist: WAL format is 1 in every release and pre-release stamp. A format above the build’s refuses to open with NewerFormat("wal segment"), and duplicate ids refuse with Corrupt("duplicate wal segment id"), see Error classes.
A segment is preallocated with set_len and an fsync to segment_size. The default is 64 MiB. The size must be a multiple of 4096 and hold at least 4 blocks. Unwritten blocks are zero.
Files are opened O_DIRECT and writes are 4096-aligned, one block at a time.
Deletion
Section titled “Deletion”Segments wholly before replay_from are deleted after open and every 512 commits, unless the archive gate holds them for upload (SPEC V60, V68). See Recovery.