Files
cozystack/internal
Alexey Artamonov 570fcec725 fix(postgres): hold a queued backup job while its application is restored
The restore gate in Reconcile looks only at a BackupJob that has not
started, and the CNPG driver stamps StartedAt on its first pass. A job
that then waits behind another backup of the application, for as long
as that backup runs, writes the WAL archive destination and the
Cluster plugin once released without looking for a restore that began
in the meantime. A write landing while the restore re-renders the
Cluster can put the restored Cluster back on the source's WAL prefix,
where recovery fails with "Expected empty archive".

Every pass that is about to write the destination now looks for a
restore of the application and holds the job the way the gate does.
A job whose Backup already runs writes nothing and is not held. The
hold resets the retry budget of the destination write, as the wait
for another backup does, so time spent behind a restore does not fail
the job on the first error after it.

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
Assisted-by: LLM
2026-11-09 23:52:25 +03:00
..