Skip to content

backups: a cnpg Backup without a running BackupJob does not hold the WAL archive destination #5278

Open

Description

@scooby87

Describe the bug

After #5221 a Postgres BackupJob writes the shared WAL archive destination (the ObjectStore the Cluster's barman-cloud plugin archives to) only before its own cnpg.io/Backup exists, and only while no other running BackupJob of the application has a cnpg.io/Backup in flight. The queue deliberately counts only Backups whose owning BackupJob is still running, so two kinds of in-flight Backup do not hold the destination:

  1. A cnpg.io/Backup with no owning BackupJob: one created by hand, by a ScheduledBackup, or by anything else outside the backup controller.
  2. A cnpg.io/Backup whose BackupJob was deleted, or reached Failed, while the Backup was still pending or running.

When the next BackupJob of the application uses a different BackupClass, it rewrites the destination under such a Backup, and the base backup and the WAL it needs can end up in different places, so the Backup cannot be restored from. Before #5221 every running BackupJob rewrote the destination every few seconds regardless, so this is not a regression of that PR; it is the part of the problem the queue does not cover.

Environment

To Reproduce

  1. Give a Postgres application two BackupClasses whose CNPG strategies point at different destinations.
  2. Create a cnpg.io/Backup for the application's Cluster by hand (plugin method), or create a BackupJob and delete it while its cnpg.io/Backup is still pending.
  3. While that Backup is pending or running, create a BackupJob that uses the other BackupClass.
  4. The new BackupJob writes its destination to the ObjectStore and creates its own Backup.

Expected behaviour

The destination is not rewritten while any cnpg.io/Backup of the Cluster that already started writing is still in flight, whoever created it, and the wait is bounded so a stuck Backup cannot stall every later backup of the application.

Actual behaviour

The queue skips Backups without a running owning BackupJob, so the new job rewrites the destination under them.

Logs

Not applicable: the behaviour follows from the queue's selection of holders.

Screenshots

Not applicable.

Additional context

Holding for these Backups needs a bound the missing owner can no longer provide, for instance waiting only for Backups in an active phase, or for the CNPG Backup deadline, and then going ahead with a condition that names the Backup. The atomic per-application claim discussed in #4559 would be the natural place to also cover backups racing each other. Raised by an automated review on #5221.

Checklist

  • I have checked the documentation
  • I have searched for similar issues
  • I have included all required information
  • I have provided clear steps to reproduce
  • I have included relevant logs

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug
    triage/needs-triageIndicates an issue needs triage by a maintainer
    on Nov 11, 2026
  2. dosubot commented on Nov 11, 2026

    @dosubot

    The bounding work overlaps #5209: in CNPG 1.30.0, a Backup can return to pending when it restarts on another instance, not just before it first writes data. So treating pending as safe to release could also release a backup that has already started. That distinction matters for the proposed active-phase-only hold. [1]

    The existing Cozystack 30-minute backup deadline is not an in-flight timeout: it bounds plugin rollout before the cnpg.io/Backup exists, and existing Backups are explicitly uncapped. Reusing that deadline for ownerless holders would therefore introduce a new expiry policy, rather than inherit an existing one. [2]

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about cozystack Share Dosu with your team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bugtriage/needs-triageIndicates an issue needs triage by a maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions