Lifecycle and atomic install
A SEAM data file is written under its final name and becomes part of the store only when a MANIFEST edit adds it. That edit is the commit point.
- Write the file. A data file is written directly under its final name
<id>.stc, with no temporary name, usingO_DIRECT, in 1 MiB chunks padded to 4096 bytes, followed byfdatasync(write_fileatsst.rs:1382,finish_spillatsst.rs:1370). The file id comes fromnext_file, which the MANIFEST persists. - Log the edit. The file becomes part of the store only when a MANIFEST edit that adds it is appended and
fdatasynced. That record is the commit point. Compaction, flush, tier moves, migration and range drops install their outputs and remove their inputs in one edit. - Unlink removed files. A file removed by an edit is unlinked afterwards, either immediately or once no pinned version, such as a base backup, still references it.
- Sweep at startup. See below.
Directory durability
Section titled “Directory durability”The writer syncs file data but does not sync data/ between creating <id>.stc and logging the edit that references it.
Startup sweep
Section titled “Startup sweep”The sweep runs in Lsm::open (crates/strata-lsm/src/db.rs:567-581), after the MANIFEST is replayed. It deletes every entry in data/ that
- has a name ending in
.stcor.stci, or containing.aside-, and - is not live. Live means
<id>.stcfor local files and<id>.stcifor remote files.
A crash between steps 1 and 2 therefore leaves only an orphan that the next open removes.
Store stamp
Section titled “Store stamp”Opening the store replays the MANIFEST and rewrites it, which stamps the store with the build’s current store format. The old store numbers 1 to 4 are pre-release stamps; pre-4 is the layout SEAM 1 adopts. A store is stamped at open, at one durable point before any data or WAL byte of that format is written, see Rewrite and format stamp. The stamp is not reversible: there is no downgrade.