Skip to main content

reconstruct

Function reconstruct 

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

Reconstruct database state as believed at past instant ts using window-function log fold (§5.5, D-026).

When ts predates the hot log’s horizon the cold database is ATTACHed for exactly one fold and DETACHed unconditionally on the way out, error paths included. ATTACH is not transactional and survives ROLLBACK, so a handle leaked by an early return would make every later reconstruct and every later archive fail with “database cold is already in use” — one corrupt payload would permanently poison the connection. This is the same failure mode archive() carries a note about, and the two now share a shape. Snapshot composition (§5.5, D-049) applies when snapshots_dir holds a snapshot at or before ts and no archive database exists — see [snapshot_anchor] for why archiving disables it. Otherwise the fold runs from genesis, which is correct and costs what the whole log costs.