Skip to main content

write_final

Function write_final 

Source
pub async fn write_final(
    conn: &Connection,
    snapshots_dir: &Path,
    ts: &str,
    archive_path: Option<&Path>,
) -> Result<PathBuf>
Expand description

Write the final snapshot on clean shutdown (§5.1.7).

Called after the Write Actor has stopped, so the state it folds is quiescent — nothing can commit between the fold and the write. Returns the snapshot’s path so a caller can log or verify it.

This was a Ok(()) stub that close() never called, which meant every restart replayed the log from whatever snapshot happened to be lying around rather than from the shutdown anchor.

The fold is async and the write is not, so the write goes to a blocking thread (save_and_prune, 0.13.11, W8.1). Both halves used to run on the caller’s worker, and the second half is the expensive one.