fix: M8 review findings (restore ownership, barrier tool, World0 claimRef, CI selection, drill verdicts)
P1: restore-world.sh claims its objects path (mkdir) and the database (a held session with a restore try-lock and the exclusive upgrade lock), and removes only what it created, so a losing restore never drops a winner's schema. P2: barrier Ready-pod selection via shared jsonpath helper with fixtures; barrier pod fsGroup; script-generated pods inspected by the policy check; World0 PV claim references protected; ci-paths.sh uses the event's real base and runs on uncertainty; fault-drill asserts RTO and needs positive quarantine evidence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -90,4 +90,46 @@ PGDATABASE=evo_restore_twice bash "$root/tools/backup/restore-world.sh" --bundle
|
||||
[ "$code" = 4 ] && grep -q 'already has an evolution schema' "$work/twice.log" || fail "a second restore into one database"
|
||||
[ "$(PGDATABASE=evo_restore_twice psql -XAtc 'SELECT end_tick FROM evolution.region_heads WHERE world_id = 300')" = "$backup_tick" ] ||
|
||||
fail "the refused second restore changed the first"
|
||||
# Ownership races (review M8 P1). A competing actor creates the schema between this
|
||||
# restore's checks and its pg_restore: the restore fails and leaves that schema alone.
|
||||
createdb evo_restore_race
|
||||
code=0
|
||||
PGDATABASE=evo_restore_race EVO_RESTORE_TEST_HOOK='[ "$1" = before-restore ] && psql -XAtq -c "CREATE SCHEMA evolution" -c "CREATE TABLE evolution.winner(x int)" || true' \
|
||||
bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" --objects "$work/race-a" \
|
||||
> "$work/race-a.log" 2>&1 || code=$?
|
||||
[ "$code" = 4 ] && grep -q 'pg_restore failed; the database was not changed' "$work/race-a.log" ||
|
||||
{ cat "$work/race-a.log" >&2; fail "a pre-empted restore: exit $code"; }
|
||||
[ "$(PGDATABASE=evo_restore_race psql -XAtc "SELECT count(*) FROM pg_tables WHERE schemaname = 'evolution' AND tablename = 'winner'")" = 1 ] ||
|
||||
fail "a pre-empted restore deleted the competing schema"
|
||||
[ ! -e "$work/race-a" ] || fail "a pre-empted restore left its own objects directory"
|
||||
# Two restores of one database: the second refuses at once and touches nothing of
|
||||
# the first, which completes. While the first holds the database (after its install),
|
||||
# a lease acquisition there waits instead of running against unverified state.
|
||||
createdb evo_restore_pair
|
||||
PGDATABASE=evo_restore_pair EVO_RESTORE_TEST_HOOK='
|
||||
if [ "$1" = before-restore ]; then touch "'"$work"'/pair-claimed"; sleep 3; fi
|
||||
if [ "$1" = after-restore ]; then
|
||||
psql -XAt -c "SET lock_timeout = '"'"'1s'"'"'" -c "SELECT * FROM evolution.acquire_region_lease(300, 1, 20000, decode(repeat('"'"'b1'"'"', 32), '"'"'hex'"'"'))" > "'"$work"'/pair-acquire.log" 2>&1 || true
|
||||
fi' bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" --objects "$work/pair-a" \
|
||||
> "$work/pair-a.log" 2>&1 &
|
||||
pair_pid=$!
|
||||
for _ in $(seq 1 100); do [ -e "$work/pair-claimed" ] && break; sleep 0.1; done
|
||||
code=0
|
||||
PGDATABASE=evo_restore_pair bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" \
|
||||
--objects "$work/pair-b" > "$work/pair-b.log" 2>&1 || code=$?
|
||||
[ "$code" = 4 ] && grep -q 'another restore holds this database' "$work/pair-b.log" ||
|
||||
{ cat "$work/pair-b.log" >&2; fail "a concurrent restore: exit $code"; }
|
||||
[ ! -e "$work/pair-b" ] || fail "the refused concurrent restore left its objects directory"
|
||||
code=0; wait "$pair_pid" || code=$?
|
||||
[ "$code" = 0 ] && grep -q '^RESTORE VERIFIED regions=1 ' "$work/pair-a.log" ||
|
||||
{ cat "$work/pair-a.log" >&2; fail "the first of two restores: exit $code"; }
|
||||
grep -q 'lock timeout' "$work/pair-acquire.log" ||
|
||||
{ cat "$work/pair-acquire.log" >&2; fail "a lease acquisition ran during the restore"; }
|
||||
# An existing objects path is never claimed or removed.
|
||||
mkdir "$work/occupied"; echo keep > "$work/occupied/mine"
|
||||
createdb evo_restore_occupied
|
||||
code=0
|
||||
PGDATABASE=evo_restore_occupied bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" \
|
||||
--objects "$work/occupied" > "$work/occupied.log" 2>&1 || code=$?
|
||||
[ "$code" = 4 ] && [ "$(cat "$work/occupied/mine")" = keep ] || fail "an occupied objects path: exit $code"
|
||||
echo "backup and restore qualification passed (backup tick $backup_tick, acknowledged $acked_before, source $source_tick)"
|
||||
|
||||
Reference in New Issue
Block a user