~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

A server started on a backup rolls back without telling anyone

Open
Open chadtmiller.com opened this issue 0 comments

spec/DURABILITY.md's "Backups" says a snapshot of the data directory is a backup, and that starting on one is a rollback the server does nothing about, as the reference does nothing for a database brought back.

The consequences:

  • Reused seqs. The firehose numbers its next events from the backup's last seq, so seqs it sent before go out again for other events. A relay whose cursor is past them gets FutureCursor until the server catches up, and then reads events it takes for ones it has already seen.
  • Lost commits. Relays and AppViews hold commits the server no longer has. An account's next commit has a later rev, but its since and prevData name a commit those consumers never saw from the restored chain.
  • Handle changes made after the backup stay at the PLC directory, while the server holds the old handle.

What would fix it:

  1. Restore is the operator's to say, by a flag or variable on the first start after a restore. The server cannot tell a restored directory from a normal restart.
  2. On that start, jump seq past every one it could have sent: the last reserved block's end plus a margin, or a value taken from the time.
  3. Tell consumers to resync. Emit #sync for every account, and #identity where its handle at the PLC directory differs from the one held, and settle the handle.
  4. Harness: take a snapshot, write after it, start a server on the snapshot with the flag. The firehose must carry on with no seq reused, the #sync events must come, and a relay-like consumer must accept the next commits.

Not needed for a first deploy: a restore happens only after a disaster.