pub fn recover_predecessors(
base_dir: &Path,
instance_id: &str,
) -> Result<RecoveryOutcome, EventStoreError>Expand description
Sweeps <base_dir>/<instance_id>/ for crashed predecessor runs and seals each one.
A predecessor is a run file whose manifest still reads RunStatus::Running: the
previous trader exited (cleanly via drop, or crashed) without sealing. The sweep
scans every entry in the run, validating hashes; on success the manifest seals as
RunStatus::CrashedRecovered, otherwise as RunStatus::Quarantined. The
most-recently-crashed survivor’s run_id is returned so the new run records it as
parent_run_id.
Quarantined runs do not become parents: a future replay must skip the corrupted tail rather than chain through it.
A predecessor that cannot be reopened, scanned, or sealed is skipped with a logged error rather than failing the sweep: recovery must never leave the trader unbootable because one run file is damaged. Skipped runs keep their on-disk status, so the next boot retries them.
§Errors
Returns EventStoreError when the directory enumeration fails, or when a
predecessor unexpectedly reopens without the
EventStoreError::CrashedPredecessor handshake the backend uses to surface
unsealed runs.