Skip to content

Reading and the torn tail

A reader walks the MANIFEST record by record after the header. The log can end in a half-written record after a crash, so reading must stop at damage without failing the open.

  1. Read records in order.
  2. Stop, without error, at the first record whose length is out of range (outside 32 to 64 MiB), that runs past end of file, or that fails authentication. That is the torn tail (SPEC V6).
  3. If zero valid records were read, fail with Corrupt("manifest has no valid snapshot").
  4. A record that authenticates but does not decode is Corrupt.

Each record authenticates under an AAD that binds generation, seq and the header stamps, so a record from another position or generation fails step 2.

  • The first record must be the full snapshot, see State and levels.
  • A reader that sees an authentication failure cannot tell a torn tail from damage in the middle of the file: both end the log.