[Bug]: lastSuccessfulBackup/firstRecoverabilityPoint intermittently not updated after a completed volumeSnapshot backup (stale cache read in updateClusterWithSnapshotsBackupTimes)

Author: dpippengerCreated Aug 22, 2026Updated Sep 29, 2026

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I believe this is a new bug.

I am running a supported version of CloudNativePG

  • I have information about the versions I am running.

Version

1.29 (latest patch) — 1.29.1; the affected code is unchanged on current main

What version of Kubernetes are you using?

1.35

What is your Kubernetes environment?

Cloud: Google GKE (v1.35.6-gke.1641000)

How did you install the operator?

Helm

What happened?

Cluster.status.lastSuccessfulBackup / firstRecoverabilityPoint (and therefore the cnpg_collector_last_available_backup_timestamp metric) intermittently fail to advance after a completed volumeSnapshot backup, with no error logged. The status stays at the previous backup's end time until the next backup completes (a whole schedule interval later). With a 4h ScheduledBackup and backup-staleness alerting on the metric, each occurrence produces a false "backups stale" page while the backup catalog is actually healthy. We see this roughly a few times per week across five clusters.

Observed timeline (one occurrence, 2026-08-22, all UTC):

  • 04:30:00 scheduled Backup atlas-postgres-scheduled-20260822043000 starts (method volumeSnapshot, online, target = standby)
  • 04:31:46 Backup CR reaches phase: completed (stoppedAt: 04:31:46); the VolumeSnapshot is readyToUse: true and carries cnpg.io/backupEndTime: 2026-08-22T04:31:46Z (verified present afterwards)
  • 04:31:46 the cluster condition LastBackupSucceeded ("Backup was successful") is patched — so the post-completion code path in reconcileSnapshotBackup did run to its end
  • status.lastSuccessfulBackup remains 2026-08-22T00:31:04Z (the previous backup) for the next 4 hours; no operator log line matches "could not update cluster's backups metadata" or "Can't update the cluster with the completed snapshot backup data"
  • 08:31:45 the next scheduled backup completes and the status jumps directly to 08:31:45 — the 04:31:46 value never appears

Analysis:

In internal/controller/backup_controller.go, reconcileSnapshotBackup completes the backup (completeSnapshotBackupStep → annotateSnapshotsWithBackupData, which patches cnpg.io/backupEndTime onto the VolumeSnapshots) and then, in the same reconcile pass, calls updateClusterWithSnapshotsBackupTimes. That function recomputes the backup times via volumesnapshot.GetSnapshotsBackupTimes, which lists VolumeSnapshots through the manager's cached client — milliseconds after the annotation write. When the informer cache does not yet reflect the just-written annotation, the newest end time computed is the previous backup's, reflect.DeepEqual(origCluster.Status, cluster.Status) sees no change, and the patch is silently skipped. Nothing retries it: the Backup is now phase: completed, so subsequent reconciles return early, and the status stays stale until the next backup's completion recomputes it.

All the observed evidence matches this read-your-own-write race: completed Backup CR, annotation present, LastBackupSucceeded patched in the same second, no error logged, exactly-one-interval staleness, self-healing on the next backup.

Suggested fix ideas:

  • completeSnapshotBackupStep already holds the authoritative backup.Status.StoppedAt; updateClusterWithSnapshotsBackupTimes could take the just-completed backup's end time as a floor for newestSnapshot (keeping the listing only for oldestSnapshot / firstRecoverabilityPoint), or
  • read the snapshots with the API reader instead of the cached client in this path.

Happy to submit a PR if a maintainer confirms the preferred direction.

Cluster resource

yaml
# relevant excerpt
spec:
  instances: 3
  backup:
    retentionPolicy: 30d
    volumeSnapshot:
      className: csi-pd-snapshotclass
      online: true
# plus a ScheduledBackup, method: volumeSnapshot, every 4h ("0 30 */4 * * *")

Relevant log output

# operator logs for the affected backup, 04:30:00–04:32:00 — normal flow, then nothing after completion:
04:30:00 info Creating backup
04:30:00 info Waiting for VolumeSnapshot to be provisioned
04:30:06..04:31:36 info Waiting for VolumeSnapshot to be ready to use (repeats)
04:32:00 info Next backup schedule next=2026-08-22T08:30:00Z
# no "could not update cluster's backups metadata", no "Can't update the cluster with the completed
# snapshot backup data", no error-level lines for this cluster in the window

Source: cloudnative-pg/cloudnative-pg