Files
cozystack/internal/backupcontroller
Alexey Artamonov 9cc9a3b48d fix(postgres): stop backup jobs from fighting over the WAL archive destination
The ObjectStore a Postgres Cluster archives its WAL to is shared by
every backup of the app, yet each running BackupJob server-side applied
its own strategy's destination onto it every five seconds with forced
ownership. Two BackupJobs of one app with different BackupClasses
flipped the destination back and forth until the healthy backup failed
too, and a webhook or apiserver blip during that apply failed the
BackupJob at once.

A BackupJob now writes the destination only before its cnpg.io/Backup
exists, and waits, with a WaitingForOtherBackup condition, while
another running BackupJob of the app has a Backup in flight. The check
reads the informer cache, so jobs released together, or one created
while another's Backup is not yet cached, can still both proceed; an
atomic per-application claim is a separate change.

Write errors that cannot succeed on retry (invalid, bad request,
forbidden) still fail the job at once. Any other is retried for the
backup deadline counted from its first failure since the job last left
the queue, recorded in a DestinationApplied condition. Once the Backup
exists the Cluster is only read, and a failed read is returned for a
controller retry instead of failing the running backup. The plugin
rollout deadline counts from the attach rather than from the job's
start, so queueing before the attach no longer shortens it.

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