pub async fn verify_last_link(
conn: &Connection,
archive_path: Option<&Path>,
snapshots_dir: &Path,
) -> Result<Option<ChainCheck>>Expand description
Check the newest link of the snapshot chain (0.15.19, review C-18).
§What it is for
verify_snapshot_chain is right and unaffordable: two folds, one of them
from genesis over the whole log. Its own rustdoc calls scheduling it the
open problem, and nothing schedules it, so in practice a composition defect
is copied forward with nothing looking. This is the cheap half of the same
idea — re-derive snapshot n from snapshot n−1 and compare — which costs
one anchored delta and can therefore run whenever a snapshot is written.
The snapshot cadence does exactly that and logs a divergence.
Ok(None) when there are not two snapshots to compare, which is a young
database and not a fault.
§What it catches, and what it does not
It catches a defect as it is introduced: a snapshot that does not
survive its own serialize/load round trip, an apply_to that composes
differently from how it was composed, or a delta that has stopped covering
the window between the two anchors. That last one is the practical case —
rows archived out of the hot log between the two writes, with no archive
path given here to fold them back in.
It does not catch a defect inherited from further back. If the chain
went wrong at link three and every link since has composed faithfully onto
it, this agrees at every one of them, because both sides descend from the
same wrong state. Only a genesis fold answers that, which is what
verify_snapshot_chain is and why it stays.
Pass archive_path whenever there is an archive. Without it the delta is
folded from the hot log alone, and a link spanning an archive session will
disagree for a reason that is not a defect.
§It reports; it does not repair
verify_snapshot_chain’s reasoning, unchanged: under Doctrine VI a
snapshot is derivative, so the repair is delete the snapshots, which is
one line and the caller’s to run. Rewriting the file here would destroy the
only evidence that composition has a bug.