feat(statestore): offline backup, restore, validate and rollback
archie-state-store gains the offline recovery commands
docs/prds/runtime-control-plane.md ("Bootstrap, migration, and recovery")
asks for. They work on the task database file directly -- <db_path>-tasks.sqlite,
not db_path -- and need neither archied nor the Web UI, which matters because
the failure they exist for is the one that stops archied starting:
backup -db F -out F consistent snapshot (VACUUM INTO), verified as a
usable store before it is published; safe against
a serving store
restore -db F -from F replace the database with a snapshot, dropping the
replaced file's -wal/-shm
validate -db F readable, not corrupt, schema no newer than this
binary, every stored resource decoding under the
definition that owns it
rollback -db F -kind K replay an earlier revision of a stored resource
[-revision N] through the ordinary replace, recorded as a new
revision
No rollback RPC is added and none is needed: a revision carries its own value,
so restoring one is the same replace the dashboard and the channels already
use, by hand, with the store stopped.
"The State Store is stopped" is checked rather than assumed. The serving
process now takes an exclusive flock on <db>.lock for its whole life
(store.AcquireOwnership), and restore/rollback refuse with
`task database is owned by another process` while it holds it. backup is the
deliberate exception: the update installer runs inside the process it is
replacing and cannot stop the State Store.
scripts/archie-update-install takes its pre-flight snapshot through
`go run ./cmd/archie-state-store backup` from the release being installed
instead of its own sqlite3 shell, so the installer and an operator run one
implementation. The watchdog's refusal semantics are unchanged: an update that
cannot back up still must not start.
Docs: safe-change-and-recovery.md's "Recovery: not yet built" now describes
what exists.
This commit is contained in:
14 files changed
+1417
-18
No files matched your search
@@ -183,10 +183,18 @@ fi
|
||||
# that cannot take one must not start: once binaries are replaced, a failure
|
||||
# leaves the previous release unable to read the store it just migrated. This
|
||||
# runs ahead of the adapter refresh below so a refusal changes nothing at all.
|
||||
#
|
||||
# The snapshot is taken by the recovery subcommand of the release being
|
||||
# installed, from its own checkout, rather than by hand-rolled sqlite3 shell:
|
||||
# the operator running `archie-state-store backup` by hand and the installer
|
||||
# are then the same implementation, and the two cannot drift. The installed
|
||||
# binary is the previous release, which may predate the subcommand, so it
|
||||
# cannot be the one asked -- and a release whose recovery path will not build is a
|
||||
# release that cannot back up, which is exactly what this pre-flight refuses.
|
||||
if [[ ",$components," == *,daemon,* ]] && [ -n "$TASK_DB_PATH" ] && [ -f "$TASK_DB_PATH" ]; then
|
||||
echo "==> backing up task database for schema-safe rollback"
|
||||
mkdir -p "$(dirname "$TASK_DB_BACKUP")"
|
||||
if ! sqlite3 "$TASK_DB_PATH" ".backup '$TASK_DB_BACKUP'"; then
|
||||
if ! go run ./cmd/archie-state-store backup -db "$TASK_DB_PATH" -out "$TASK_DB_BACKUP"; then
|
||||
echo "refusing to install $GW: could not back up the task database at $TASK_DB_PATH, so a failed update could not be rolled back" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user