Skip to main content

Module recovery

Module recovery 

Source
Expand description

Check and repair a damaged engine journal. Engine::open refuses a journal with any bad record; these functions apply the same rules to report the longest prefix that still replays, and to rebuild a journal from it or from an intact copy. See docs/ENGINE-RECOVERY.md for what each step can and cannot get back.

Structs§

JournalCheck
What Engine::open would make of a journal.
JournalDamage
The first record that does not replay, and why.
JournalRecovery
The journal a repair keeps, and where it came from.
JournalRepair
Outcome of repair_journal_file.

Functions§

check_journal
Replay entries with the checksum, format, revision, allocator and selected constraint rules of Engine::open. Never fails: damage is part of the report. Costs the same O(N) replay as opening, without a log.
read_journal_file_lossy
Complete lines of a file journal, in the form FileTransitionLog reads them, but tolerating damage it would reject: invalid UTF-8 becomes U+FFFD (so the checksum flags that record) and a missing file is empty.
recover_journal
Pick the longest valid prefix among copies of one journal: the damaged primary first, then replicas, mirrors or a restored backup. Every other copy’s valid prefix must be a prefix of the chosen one. Copies that disagree are refused rather than guessed between, because each may hold commits the other lacks; choose one explicitly. A copy compacted into an engine3 checkpoint disagrees with an uncompacted copy of the same history.
repair_journal_file
Rebuild the journal at path from the longest valid prefix among it and copies (see recover_journal). The original bytes are first copied to <path>.damaged-<n>; the replacement is flushed, then renamed over path. Holds the writer lock that FileTransitionLog::open_exclusive takes, so it fails while an engine owns the journal. Copies are only read; their owners must not be writing them.