fix(backup): durable restore gate and resolved install outcomes (review 3a34ae3)

The restore no longer relies on an auxiliary lock session. One install
transaction holds the dump, a nonce claim row, fenced leases and retired builds,
so the world is unservable until a nonce-checked publish after verification,
regardless of connection loss or restarts. A failed install is resolved from the
claim (committed, rolled back, or unknown with the target kept unservable and
--abandon NONCE to resolve); cleanup only removes what the nonce owns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-01 06:14:34 -04:00
co-authored by Claude Opus 5.5
parent 3a34ae39bc
commit 68da5654ff
5 changed files with 386 additions and 145 deletions
+46
View File
@@ -3087,3 +3087,49 @@ Review: `.cache/reviews/M8_REVIEW_680e7e5-5b482ad.md` (one P1, five P2).
objects, 0 failures.
- ROADMAP corrected: M8-dev/stage is implemented and locally qualified, but **not
passed** until the live gates listed there are run.
## Review 3a34ae3 follow-up: durable restore gate - 2026-10-01
Review: `.cache/reviews/REVIEW_3a34ae3.md`. P1: losing the auxiliary claim session
released authority before verification. P2: a nonzero `pg_restore` exit was taken
as proof of rollback.
- `restore-world.sh` no longer relies on an auxiliary lock session. It works in
three steps, as the ADR-0074 amendment describes:
- an install transaction holds the dump, a claim row with the invocation's
nonce, fenced leases and retired builds;
- verification follows;
- a nonce-checked publish transaction re-enables exactly the held builds.
Ambiguous outcomes are resolved from the claim row. An unresolvable one is
OUTCOME UNKNOWN (exit 5): the target stays unservable, and
`--abandon NONCE --objects DIR` resolves it later.
- `backup-check.sh` passed in the Release, analysis and ASan/UBSan PostgreSQL
builds, with these cases:
- a competing schema before install: the rollback was confirmed and the
competitor's table survived;
- two concurrent restores: the first installer was verified and published; the
second rolled back, confirmed, and left the winner intact;
- after install, `acquire_region_lease` was refused ("build not current") both
before and after `pg_ctl restart` mid-restore; the restore then verified, and
one current build was restored;
- a lost install acknowledgement: "install outcome resolved: committed", then
verified;
- an unreachable resolution: exit 5, both schemas and the objects kept,
acquisition refused, `--abandon` with a wrong nonce removed nothing, the right
nonce removed everything, and a retry restore succeeded;
- an occupied objects path: refused and untouched;
- damaged bundles: refused, with no `evolution` or `evolution_restore` left.
- The reviewer's claim-loss reproduction, adapted to the renamed hook
(`after-install`), finds no lock to terminate. The runtime acquisition inside it
failed with `build not current` (exit 1), and the restore then published.
- `dr-check.sh` (in-place restore) and `upgrade-check.sh` passed in all three
builds.
- Mutations:
- install without retiring builds: caught ("authority was available before
publication");
- resolution ignoring a committed claim: caught (exit 5 instead of verified);
- cleanup ignoring the claim's nonce: NOT exercised (the edit pattern failed to
apply). The abandon path also checks the nonce first, so that defense is two
layers deep and only the outer layer is tested.
- Not run: a real network partition around COMMIT. The lost acknowledgement is an
injected test mode (`EVO_RESTORE_TEST_INSTALL_ACK`).