feat(ops): M8.8 World0 acknowledgment gate and host-loss recovery (ADR-0075)
Ratifies dev/stage RPO/RTO from measurements and keeps World0 launch blocked (policy-enforced) until acknowledged outcomes survive host loss in an independent failure domain. Adds in-place restore with an explicit rewind, barrier-based fencing of a superseded database, and promotion of stage-pinned digests only. dr-check.sh rehearses host loss in every PostgreSQL build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
# source database or the object volume, and no admission barrier is needed.
|
||||
#
|
||||
# Bundle (DIR): MANIFEST, database.dump (pg_dump custom format, schema `evolution`,
|
||||
# no owners or grants: a restore never needs the source's roles or credentials),
|
||||
# no owners; grants are kept for an in-place restore, ADR-0075, and skipped by every
|
||||
# other restore, which therefore never needs the source's roles or credentials),
|
||||
# objects/w<world>/r<region>/<sha256>, SHA256SUMS over every other file. A source
|
||||
# object whose bytes differ from its name fails the backup.
|
||||
set -euo pipefail
|
||||
@@ -71,7 +72,7 @@ SELECT 'rows', (SELECT count(*) FROM evolution.region_commits),
|
||||
(SELECT count(*) FROM evolution.region_outbox),
|
||||
(SELECT count(*) FROM evolution.region_origins);
|
||||
\setenv EVO_BACKUP_SNAPSHOT :snapshot
|
||||
\! pg_dump --no-password --format=custom --schema=evolution --no-owner --no-privileges --snapshot="$EVO_BACKUP_SNAPSHOT" --file="$EVO_BACKUP_DUMP" && echo 'dumped' || echo 'dump-failed'
|
||||
\! pg_dump --no-password --format=custom --schema=evolution --no-owner --snapshot="$EVO_BACKUP_SNAPSHOT" --file="$EVO_BACKUP_DUMP" && echo 'dumped' || echo 'dump-failed'
|
||||
COMMIT;
|
||||
SQL
|
||||
grep -qx 'dumped' "$out/.cut" || { echo "backup failed: pg_dump did not complete" >&2; exit 3; }
|
||||
@@ -95,6 +96,7 @@ done < <(find "$objects" -mindepth 3 -maxdepth 3 -type f ! -name '.tmp-*' -print
|
||||
echo "format aevolution-backup-v1"
|
||||
echo "created $started"
|
||||
echo "label ${label:--}"
|
||||
echo "dump privileges"
|
||||
grep -E '^(database|schema|build|head|rows) ' "$out/.cut"
|
||||
echo "objects $count $bytes"
|
||||
} > "$out/MANIFEST"
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
# M8.8 supersession fence (ADR-0075): makes a database whose world was restored
|
||||
# elsewhere permanently unable to grant authority again.
|
||||
#
|
||||
# tools/backup/fence-database.sh --superseded-by LABEL --confirm
|
||||
#
|
||||
# Connection: PG* environment naming the OLD database, as its owner (migrator).
|
||||
# Run it as soon as the old database is reachable, before any of its hosts can
|
||||
# return (or immediately, when it never went away).
|
||||
#
|
||||
# It uses the upgrade barrier (ADR-0068), which serializes with every acquisition,
|
||||
# lease check and provisioning. It first retains a supersession identity,
|
||||
# SHA-256("AEVOLUTION-SUPERSEDED-v1"), which no image digest can equal, and then
|
||||
# retires every other build. Each retirement fences every lease. So:
|
||||
# - a running host's next lease check or commit fails, and it re-acquires;
|
||||
# - no retained build remains current, so every acquisition is refused and the
|
||||
# host quarantines (evo-server exit 4);
|
||||
# - a commit that names a retired build is refused by the trigger.
|
||||
# History, objects and heads are untouched. The database stays readable for audits
|
||||
# and for comparing what was lost. The heads at the moment of fencing are printed:
|
||||
# they are the old environment's final state, and record what the restore rewound.
|
||||
# Undoing this means deliberately retaining a new build as owner: that is an
|
||||
# unfencing decision, not an operation.
|
||||
set -euo pipefail
|
||||
usage() { echo "usage: $0 --superseded-by LABEL --confirm" >&2; exit 2; }
|
||||
label="" confirm=0
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--superseded-by) label="${2:-}"; shift 2 ;;
|
||||
--confirm) confirm=1; shift ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
[[ "$label" =~ ^[A-Za-z0-9._:-]+$ ]] && [ "$confirm" = 1 ] || usage
|
||||
if [ -n "${EVO_PGPASS_SOURCE:-}" ]; then
|
||||
umask 077
|
||||
export PGPASSFILE
|
||||
PGPASSFILE="$(mktemp /tmp/evo-pgpass.XXXXXXXX)"
|
||||
trap 'rm -f -- "$PGPASSFILE"' EXIT
|
||||
cat "$EVO_PGPASS_SOURCE" > "$PGPASSFILE"
|
||||
fi
|
||||
psql -X --no-password -q -A -t -F ' ' -v ON_ERROR_STOP=1 -v "label=$label" <<'SQL'
|
||||
BEGIN;
|
||||
INSERT INTO evolution.retained_builds(build_identity)
|
||||
VALUES (sha256(convert_to('AEVOLUTION-SUPERSEDED-v1', 'UTF8')))
|
||||
ON CONFLICT (build_identity) DO NOTHING;
|
||||
SELECT 'retired', encode(b.build_identity, 'hex'), evolution.upgrade_barrier(b.build_identity)
|
||||
FROM evolution.retained_builds b
|
||||
WHERE b.retired_at IS NULL
|
||||
AND b.build_identity <> sha256(convert_to('AEVOLUTION-SUPERSEDED-v1', 'UTF8'))
|
||||
ORDER BY b.build_identity;
|
||||
SELECT 'current', count(*) FROM evolution.retained_builds b
|
||||
WHERE b.retired_at IS NULL
|
||||
AND b.build_identity <> sha256(convert_to('AEVOLUTION-SUPERSEDED-v1', 'UTF8'));
|
||||
SELECT 'held', count(*) FROM evolution.region_leases WHERE holder IS NOT NULL;
|
||||
SELECT 'final', h.world_id, h.region_id, h.commit_sequence, h.end_tick, h.published_epoch
|
||||
FROM evolution.region_heads h ORDER BY 2, 3;
|
||||
SELECT 'superseded-by', :'label';
|
||||
COMMIT;
|
||||
SQL
|
||||
@@ -2,11 +2,12 @@
|
||||
# M8.7 verified restore of a backup bundle (ADR-0074) onto independent storage.
|
||||
#
|
||||
# tools/backup/restore-world.sh --bundle DIR --objects DIR
|
||||
# [--in-place --runtime-role ROLE --accept-rewind]
|
||||
#
|
||||
# Target connection: PG* environment naming an EMPTY database that the login owns
|
||||
# (PGHOST/PGPORT/PGDATABASE/PGUSER, or PGSERVICE with PGSERVICEFILE/PGPASSFILE).
|
||||
# The restore needs no source role, credential or key: the dump carries no owners
|
||||
# or grants, so the target login owns everything restored. --objects must not
|
||||
# The restore needs no source role, credential or key: owners and grants are not
|
||||
# restored, so the target login owns everything restored. --objects must not
|
||||
# exist yet (it is created 0700). evo-world-clone comes from EVO_WORLD_CLONE_BIN or
|
||||
# PATH.
|
||||
#
|
||||
@@ -22,18 +23,42 @@
|
||||
# so an unverified restore can never be mistaken for a world. The result is a
|
||||
# verbatim, owner-only copy with the source's world identities: it has no runtime
|
||||
# grants and is never served. To run it, clone it into an isolated world
|
||||
# (tools/backup/verify-backup.sh --isolate); host-loss recovery in place is M8.8.
|
||||
# (tools/backup/verify-backup.sh --isolate).
|
||||
#
|
||||
# --in-place (M8.8 host-loss recovery for dev/stage, ADR-0075) restores the world
|
||||
# under its own identity so its hosts can serve it again: the dump's grants are
|
||||
# restored (the environment's roles must already exist in the target cluster), every
|
||||
# restored lease is fenced so a new owner acquires under a newer epoch, and
|
||||
# migrate-postgres.sh audits the runtime role's effective rights. Every acknowledgement
|
||||
# after the bundle's cut is undone: deaths may reverse and resources may reappear.
|
||||
# --accept-rewind states that this is acceptable, which it is for dev and stage only;
|
||||
# World0 launch stays blocked until acknowledgements survive host loss (ADR-0075).
|
||||
# Fence the old database with fence-database.sh before any of its hosts can return.
|
||||
set -euo pipefail
|
||||
usage() { echo "usage: $0 --bundle DIR --objects DIR" >&2; exit 2; }
|
||||
bundle="" objects=""
|
||||
usage() {
|
||||
echo "usage: $0 --bundle DIR --objects DIR [--in-place --runtime-role ROLE --accept-rewind]" >&2
|
||||
exit 2
|
||||
}
|
||||
bundle="" objects="" in_place=0 runtime_role="" accept_rewind=0
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--bundle) bundle="${2:-}"; shift 2 ;;
|
||||
--objects) objects="${2:-}"; shift 2 ;;
|
||||
--in-place) in_place=1; shift ;;
|
||||
--runtime-role) runtime_role="${2:-}"; shift 2 ;;
|
||||
--accept-rewind) accept_rewind=1; shift ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
[ -n "$bundle" ] && [ -n "$objects" ] || usage
|
||||
if [ "$in_place" = 1 ]; then
|
||||
[ -n "$runtime_role" ] || { echo "--in-place needs --runtime-role" >&2; exit 2; }
|
||||
[ "$accept_rewind" = 1 ] ||
|
||||
{ echo "--in-place undoes every acknowledgement after the backup; pass --accept-rewind (dev/stage only)" >&2; exit 2; }
|
||||
elif [ -n "$runtime_role" ] || [ "$accept_rewind" = 1 ]; then
|
||||
usage
|
||||
fi
|
||||
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
bundle="$(realpath -- "$bundle")" objects="$(realpath -m -- "$objects")"
|
||||
clone_bin="${EVO_WORLD_CLONE_BIN:-evo-world-clone}"
|
||||
umask 077
|
||||
@@ -58,6 +83,11 @@ done <<< "$present"
|
||||
grep -qx 'format aevolution-backup-v1' "$bundle/MANIFEST" || refuse "unknown bundle format"
|
||||
expected_heads="$(grep '^head ' "$bundle/MANIFEST" | cut -d' ' -f2- | sort)"
|
||||
[ -n "$expected_heads" ] || refuse "manifest names no region"
|
||||
privileges=(--no-privileges)
|
||||
if [ "$in_place" = 1 ]; then
|
||||
grep -qx 'dump privileges' "$bundle/MANIFEST" || refuse "bundle predates in-place restore (no grants in its dump)"
|
||||
privileges=()
|
||||
fi
|
||||
|
||||
# 2. Target: empty, same server version.
|
||||
[ ! -e "$objects" ] || refuse "objects target already exists: $objects"
|
||||
@@ -79,7 +109,7 @@ trap cleanup EXIT
|
||||
target="${PGDATABASE:-}"
|
||||
[ -n "${PGSERVICE:-}" ] && target="service=$PGSERVICE"
|
||||
[ -n "$target" ] || { echo "set PGDATABASE or PGSERVICE for the target" >&2; exit 2; }
|
||||
pg_restore --no-password --exit-on-error --single-transaction --no-owner --no-privileges \
|
||||
pg_restore --no-password --exit-on-error --single-transaction --no-owner "${privileges[@]}" \
|
||||
--dbname="$target" "$bundle/database.dump"
|
||||
mkdir -m 700 -- "$objects"
|
||||
(cd "$bundle/objects" && find . -mindepth 2 -maxdepth 2 -type d -printf '%P\0' |
|
||||
@@ -117,5 +147,18 @@ while read -r world region _ _ tick _; do
|
||||
commits=$((commits + BASH_REMATCH[1]))
|
||||
echo "region $world/$region $line"
|
||||
done <<< "$expected_heads"
|
||||
if [ "$in_place" = 1 ]; then
|
||||
# No lease from before the loss survives: the next owner acquires a newer epoch.
|
||||
psql -X --no-password -q -v ON_ERROR_STOP=1 -c \
|
||||
'UPDATE evolution.region_leases SET holder = NULL, expires_at = NULL WHERE holder IS NOT NULL' > /dev/null
|
||||
EVO_PG_RUNTIME_ROLE="$runtime_role" bash "$root/tools/migrate-postgres.sh" > /dev/null ||
|
||||
{ echo "runtime role $runtime_role failed the rights audit" >&2; exit 3; }
|
||||
created="$(sed -n 's/^created //p' "$bundle/MANIFEST")"
|
||||
while read -r world region _ _ tick _; do
|
||||
echo "REWIND region $world/$region restored at tick $tick (backup $created): every acknowledgement after this tick is undone"
|
||||
done <<< "$expected_heads"
|
||||
fi
|
||||
restored=1
|
||||
echo "RESTORE VERIFIED regions=$(wc -l <<< "$expected_heads") commits=$commits duration_ms=$(( $(date +%s%3N) - begin_ms ))"
|
||||
what="RESTORE VERIFIED"
|
||||
[ "$in_place" = 1 ] && what="RESTORE IN PLACE VERIFIED"
|
||||
echo "$what regions=$(wc -l <<< "$expected_heads") commits=$commits duration_ms=$(( $(date +%s%3N) - begin_ms ))"
|
||||
|
||||
@@ -15,7 +15,10 @@ environment-isolation or World0-protection invariant is broken:
|
||||
cascade-delete finalizer, and each stays in its own environment;
|
||||
- the live Argo path (deploy/kubernetes/dev) holds no Namespace, Secret, quota or
|
||||
RBAC objects;
|
||||
- the cleanup tool refuses World0 before invoking kubectl.
|
||||
- the cleanup tool refuses World0 before invoking kubectl;
|
||||
- World0 launch stays blocked (ADR-0075): no workload targets World0 and its
|
||||
Application keeps an unresolved path; any image a World0 overlay pins must be
|
||||
the digest already pinned in stage (promotion, never a fresh build).
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
@@ -253,6 +256,31 @@ for path, doc in objects:
|
||||
if path.startswith('deploy/') and doc['kind'] in ('ClusterRole', 'ClusterRoleBinding', 'Role', 'RoleBinding'):
|
||||
check(False, f'{path}: AEvolution grants no Kubernetes RBAC')
|
||||
|
||||
# M8.8 World0 launch gate (ADR-0075). This host has no independent durable failure
|
||||
# domain, so an acknowledged death could be undone by host loss: World0 must not run
|
||||
# or acknowledge. Lifting this rule is itself the launch decision and needs its own
|
||||
# accepted ADR with host-loss RPO-0 evidence.
|
||||
workload_kinds = {'Deployment', 'StatefulSet', 'DaemonSet', 'Job', 'CronJob', 'Pod', 'ReplicaSet'}
|
||||
for path, doc in objects:
|
||||
in_world0 = doc['metadata'].get('namespace') == 'evolution-world0' or '/world0/' in path
|
||||
check(not (in_world0 and doc['kind'] in workload_kinds),
|
||||
f'{path}: World0 launch is blocked (ADR-0075); no {doc["kind"]} may target World0')
|
||||
if doc['kind'] == 'Application' and doc['metadata'].get('name') == 'aevolution-world0':
|
||||
check('REPLACE' in doc['spec'].get('source', {}).get('path', ''),
|
||||
f'{path}: the World0 Application must keep an unresolved path while launch is blocked')
|
||||
for component in ('region', 'stores'):
|
||||
check(not os.path.exists(os.path.join(ROOT, 'deploy', 'kubernetes', component, 'world0')),
|
||||
f'deploy/kubernetes/{component}/world0: World0 launch is blocked (ADR-0075)')
|
||||
# Promotion: World0 may only ever pin a digest that stage already runs.
|
||||
for directory, _, files in os.walk(os.path.join(ROOT, 'deploy', 'kubernetes')):
|
||||
rel = os.path.relpath(directory, ROOT).replace(os.sep, '/')
|
||||
if rel.endswith('/world0') and 'kustomization.yaml' in files:
|
||||
stage = rel[:-len('world0')] + 'stage/kustomization.yaml'
|
||||
staged = {(i.get('name'), i.get('digest')) for i in manifests.get(stage, [{}])[0].get('images', [])}
|
||||
for image in manifests[rel + '/kustomization.yaml'][0].get('images', []):
|
||||
check((image.get('name'), image.get('digest')) in staged,
|
||||
f'{rel}: {image.get("name")} must be promoted from {stage}, not pinned independently')
|
||||
|
||||
# The platform bundle: every rendered object is protected from prune and deletion.
|
||||
bundle = manifests.get(platform + '/cluster/kustomization.yaml', [{}])[0]
|
||||
check(bundle.get('commonAnnotations', {}).get('argocd.argoproj.io/sync-options') == 'Prune=false,Delete=false',
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
# M8.8 host-loss rehearsal (ADR-0075). Run by postgres-check.sh inside its throwaway
|
||||
# cluster (PG* set; EVO_SERVER_BIN, EVO_WORLD_CLONE_BIN, runtime roles exported).
|
||||
#
|
||||
# The old environment keeps serving world 400 past an online backup, so it has
|
||||
# acknowledged ticks the backup does not hold. The world is restored in place, under
|
||||
# the same identity, into a replacement database, and a new host serves it. The old
|
||||
# database is then fenced while its host is still running. Expected:
|
||||
# - the new owner resumes exactly at the backup head, under a newer epoch;
|
||||
# - the tick-20 death stays in history exactly once and is never repeated;
|
||||
# - the full history audit (deaths, offspring, inventory, ancestry) passes;
|
||||
# - the old host quarantines and acknowledges nothing after the fence;
|
||||
# - a host started later against the old database never becomes ready;
|
||||
# - the rewind (acknowledged by the old host but absent from the restore) is
|
||||
# measured and reported. It is why World0 launch stays blocked.
|
||||
set -euo pipefail
|
||||
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
work="$(mktemp -d /tmp/evo-dr-check.XXXXXXXX)"
|
||||
chmod 700 "$work"
|
||||
pids=()
|
||||
trap 'for p in "${pids[@]}"; do kill -9 "$p" 2> /dev/null || true; done; rm -rf -- "$work"' EXIT
|
||||
fail() { echo "host-loss rehearsal FAILED: $*" >&2; exit 1; }
|
||||
build=b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1
|
||||
db() { local d="$1"; shift; PGDATABASE="$d" psql -XAt -v ON_ERROR_STOP=1 "$@"; }
|
||||
serve() { # serve <database> <objects> <log>: evo-server under synthetic load.
|
||||
"$EVO_SERVER_BIN" --profile lineage --world 400 --region 1 --frame 9 \
|
||||
--pg-host "$PGHOST" --pg-port "$PGPORT" --pg-database "$1" --pg-user "$EVO_PG_RUNTIME_USER" \
|
||||
--objects "$2" --build "$build" --flush-ms 200 --lease-profile fast \
|
||||
--synthetic-inputs development-v1 < /dev/null > "$3" 2>&1 &
|
||||
pids+=($!)
|
||||
server_pid=$!
|
||||
}
|
||||
acked_through() { awk -v t="$2" '$1 == "ack" && $3 >= t {f = 1} END {exit !f}' "$1"; }
|
||||
max_ack() { awk '$1 == "ack" && $3 > m {m = $3} END {print m + 0}' "$1"; }
|
||||
wait_ack() { for _ in $(seq 1 300); do acked_through "$1" "$2" && return 0; sleep 0.1; done; return 1; }
|
||||
|
||||
# The old environment: provisioned, serving, backed up online, then serving on.
|
||||
createdb evo_dr_old
|
||||
PGDATABASE=evo_dr_old bash "$root/tools/migrate-postgres.sh" > /dev/null
|
||||
mkdir -m 700 "$work/old-objects"
|
||||
"$EVO_WORLD_CLONE_BIN" provision --world 400 --region 1 --opening development-v1 \
|
||||
--pg-host "$PGHOST" --pg-port "$PGPORT" --pg-database evo_dr_old --pg-user "$PGUSER" \
|
||||
--objects "$work/old-objects" --build "$build" --retain-build true > /dev/null
|
||||
serve evo_dr_old "$work/old-objects" "$work/old.log"; old_pid=$server_pid
|
||||
wait_ack "$work/old.log" 40 || fail "the old host acknowledged nothing"
|
||||
PGDATABASE=evo_dr_old bash "$root/tools/backup/backup-world.sh" --objects "$work/old-objects" \
|
||||
--out "$work/bundle" --label rehearsal > /dev/null
|
||||
read -r _ _ _ _ _ cut _ < <(grep '^head 400 1 ' "$work/bundle/MANIFEST")
|
||||
[ "$cut" -ge 20 ] || fail "the backup precedes the death ($cut)"
|
||||
wait_ack "$work/old.log" $((cut + 30)) || fail "the old host stopped after the backup"
|
||||
|
||||
# Host loss: the world is restored in place into a replacement database, while the
|
||||
# old host still runs (a partition, the worst case for competing authority).
|
||||
createdb evo_dr_new
|
||||
PGDATABASE=evo_dr_new bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" \
|
||||
--objects "$work/new-objects" --in-place --runtime-role "$EVO_PG_RUNTIME_ROLE" --accept-rewind \
|
||||
> "$work/restore.log" 2>&1 || { cat "$work/restore.log" >&2; fail "in-place restore"; }
|
||||
grep -q "^REWIND region 400/1 restored at tick $cut " "$work/restore.log" &&
|
||||
grep -q '^RESTORE IN PLACE VERIFIED regions=1 ' "$work/restore.log" || fail "restore evidence"
|
||||
[ "$(db evo_dr_new -c 'SELECT count(*) FROM evolution.region_leases WHERE holder IS NOT NULL')" = 0 ] ||
|
||||
fail "a restored lease is still held"
|
||||
serve evo_dr_new "$work/new-objects" "$work/new.log"; new_pid=$server_pid
|
||||
wait_ack "$work/new.log" $((cut + 30)) || { tail "$work/new.log" >&2; fail "the new host did not serve"; }
|
||||
grep -q "^phase running epoch=2 committed=$cut " "$work/new.log" ||
|
||||
fail "the new owner did not resume at the backup head under a newer epoch"
|
||||
first_new="$(awk '$1 == "ack" {print $3; exit}' "$work/new.log")"
|
||||
[ "$first_new" = $((cut + 1)) ] || fail "the new owner resumed at $first_new, not $((cut + 1))"
|
||||
|
||||
# Fence the old database while its host is still running.
|
||||
PGDATABASE=evo_dr_old bash "$root/tools/backup/fence-database.sh" --superseded-by evo_dr_new \
|
||||
--confirm > "$work/fence.log" || fail "fence"
|
||||
grep -qx 'current 0' "$work/fence.log" && grep -q "^retired $build " "$work/fence.log" || fail "fence evidence"
|
||||
final_old="$(db evo_dr_old -c 'SELECT end_tick FROM evolution.region_heads WHERE world_id = 400')"
|
||||
fenced_acks="$(max_ack "$work/old.log")"
|
||||
code=0
|
||||
for _ in $(seq 1 300); do kill -0 "$old_pid" 2> /dev/null || break; sleep 0.1; done
|
||||
wait "$old_pid" || code=$?
|
||||
[ "$code" = 4 ] || { tail "$work/old.log" >&2; fail "the fenced old host exited $code, not 4 (quarantined)"; }
|
||||
[ "$(max_ack "$work/old.log")" -le "$final_old" ] || fail "the old host acknowledged past its final head"
|
||||
[ "$(db evo_dr_old -c 'SELECT end_tick FROM evolution.region_heads WHERE world_id = 400')" = "$final_old" ] ||
|
||||
fail "the old database advanced after the fence"
|
||||
# A host started later against the old database never serves.
|
||||
serve evo_dr_old "$work/old-objects" "$work/late.log"; late_pid=$server_pid
|
||||
code=0; wait "$late_pid" || code=$?
|
||||
[ "$code" = 4 ] && ! grep -q '^ready 1' "$work/late.log" && ! grep -q '^ack ' "$work/late.log" ||
|
||||
fail "a late host on the fenced database exited $code or served"
|
||||
|
||||
kill -TERM "$new_pid"; code=0; wait "$new_pid" || code=$?
|
||||
[ "$code" = 0 ] || fail "the new host exited $code"
|
||||
new_head="$(db evo_dr_new -c 'SELECT end_tick FROM evolution.region_heads WHERE world_id = 400')"
|
||||
audit="$("$EVO_WORLD_CLONE_BIN" audit --world 400 --region 1 --pg-host "$PGHOST" --pg-port "$PGPORT" \
|
||||
--pg-database evo_dr_new --pg-user "$PGUSER" --objects "$work/new-objects" --retained "$build")" ||
|
||||
fail "history audit of the restored world"
|
||||
[[ "$audit" == *" tick=$new_head "* ]] || fail "audit: $audit"
|
||||
# The death at tick 20 is durable once, before the cut, and never repeated.
|
||||
[ "$(db evo_dr_new -c 'SELECT count(*) FROM evolution.region_decisions WHERE world_id = 400')" = 1 ] ||
|
||||
fail "the restored world lost or repeated the death"
|
||||
[ "$(grep -c '^outcome 20 ' "$work/new.log" || true)" = 0 ] || fail "the new owner repeated the death"
|
||||
echo "host-loss rehearsal passed: cut=$cut old_acknowledged=$fenced_acks old_final=$final_old" \
|
||||
"rewound=$((final_old - cut)) ticks new_head=$new_head ($audit)"
|
||||
@@ -32,6 +32,8 @@ EVO_WORLD_CLONE_BIN="$(dirname "$1")/evo-world-clone"
|
||||
"$1"
|
||||
# M8.7: online backup under load, restore on a separate cluster, isolated rebuild.
|
||||
bash "$root/tools/ci/backup-check.sh"
|
||||
# M8.8: host-loss rehearsal: in-place restore, fenced old environment, measured rewind.
|
||||
bash "$root/tools/ci/dr-check.sh"
|
||||
v1_sha="$(sha256sum "$root/migrations/0001_region_bootstrap.sql")"
|
||||
v1_sha="${v1_sha%% *}"
|
||||
# Migration failure must not publish a partial schema.
|
||||
|
||||
Reference in New Issue
Block a user