Skip to content

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.

  1. Write the file. A data file is written directly under its final name <id>.stc, with no temporary name, using O_DIRECT, in 1 MiB chunks padded to 4096 bytes, followed by fdatasync (write_file at sst.rs:1382, finish_spill at sst.rs:1370). The file id comes from next_file, which the MANIFEST persists.
  2. 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.
  3. 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.
  4. Sweep at startup. See below.

The writer syncs file data but does not sync data/ between creating <id>.stc and logging the edit that references it.

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 .stc or .stci, or containing .aside-, and
  • is not live. Live means <id>.stc for local files and <id>.stci for remote files.

A crash between steps 1 and 2 therefore leaves only an orphan that the next open removes.

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.