mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 13:52:20 +00:00
A weekly or nightly backup job whose process died (a restart, a container out of memory) stayed active until its two- or four-hour expiry, and its retry walked the accounts in the same order: the account that killed it has the oldest copy, so it led again, and every account after it went without a copy for as long as that record stayed too large. Both passes now send with a five-minute pg-boss heartbeat, so a dead run fails within minutes and its retry picks it up. Each pass records when it started and finished every account (backup_pass_attempts, migration 0373); an account whose last attempt never finished goes behind all the others. The backups page shows when the run in progress started and names an account a run died under, for the weekly and the off-host card, and a heartbeat timeout reads as what it means.
20 lines
834 B
SQL
20 lines
834 B
SQL
-- One row per account and backup pass, written when the pass starts the
|
|
-- account and again when it gets past it. A start newer than the finish with
|
|
-- no run active is an attempt the process died under; the pass takes that
|
|
-- account last, and the admin backups page names it.
|
|
CREATE TABLE "backup_pass_attempts" (
|
|
"user_id" TEXT NOT NULL,
|
|
-- The pass's queue name: data-backup or data-backup-offhost.
|
|
"pass" TEXT NOT NULL,
|
|
"started_at" TIMESTAMP(3) NOT NULL,
|
|
-- NULL until the pass has once got past this account.
|
|
"finished_at" TIMESTAMP(3),
|
|
|
|
CONSTRAINT "backup_pass_attempts_pkey" PRIMARY KEY ("user_id", "pass")
|
|
);
|
|
|
|
ALTER TABLE "backup_pass_attempts"
|
|
ADD CONSTRAINT "backup_pass_attempts_user_id_fkey"
|
|
FOREIGN KEY ("user_id") REFERENCES "users"("id")
|
|
ON DELETE CASCADE ON UPDATE CASCADE;
|