mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
fix(backup): notice a backup run the process died under, and take its account last
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.
This commit is contained in:
1 parent
d55e329c48
commit
f18e6ed34b
31 files changed
+734
-19
No files matched your search
@@ -157,6 +157,15 @@ describe("restore preview kept with the copy", () => {
|
||||
const row = await prisma.dataBackup.findFirstOrThrow({
|
||||
where: { userId: admin.id, type: "WEEKLY_AUTO" },
|
||||
});
|
||||
// The pass marked the account started and then finished: only a process
|
||||
// that died under it would leave the start alone.
|
||||
const attempt = await prisma.backupPassAttempt.findUniqueOrThrow({
|
||||
where: { userId_pass: { userId: admin.id, pass: "data-backup" } },
|
||||
});
|
||||
expect(attempt.finishedAt).not.toBeNull();
|
||||
expect(attempt.finishedAt!.getTime()).toBeGreaterThanOrEqual(
|
||||
attempt.startedAt.getTime(),
|
||||
);
|
||||
expect(row.preview).toMatchObject({
|
||||
version: 1,
|
||||
copy: `chunks:${row.chunkStreamId}:${row.chunkCount}`,
|
||||
|
||||
Reference in new issue
Block a user