Summary
When a PostgreSQL database is deleted while an initial backup is still running, the operator removes pgbackrest-secrets before the backup completes, causing the backup to fail and the database to get stuck in Deleting state.
Steps to Reproduce
- Provision a PostgreSQL database with backups enabled (scheduled + PITR)
- Wait for database to reach
Ready state
- Immediately delete the database (while backup is still
In Progress)
- Database gets stuck in deletion
Actual Behavior
- Database deletion is initiated
- Operator removes
<db-name>-pgbackrest-secrets Secret
- Running backup pod fails with:
MountVolume.SetUp failed for volume "pgbackrest-config":
secret "<db-name>-pgbackrest-secrets" not found
- Backup remains stuck
Running, database stuck Deleting
Resource State When Stuck
$ kubectl get pg # cluster gone
No resources found
$ kubectl get perconapgbackups
NAME STATUS AGE
postgresql-wza-backup-lcmn Running 5m13s
$ kubectl get perconapgcluster
NAME STATUS AGE
postgresql-wza Deleting 10m
Root Cause
Deletion flow removes Secrets before checking/waiting on in-progress backups. The backup pod needs the Secret to mount its config but it is already deleted.
Workaround
Manually recreate the pgbackrest-secrets Secret (clone from another DB using same S3 bucket). This allows backup to finish and deletion to proceed.
Proposed Fix
Ensure proper deletion ordering: wait for or cancel in-progress backups before deleting pgbackrest-secrets.
Environment
- Operator: percona-postgresql-operator (via everest-operator)
- Storage: S3
- Discovered during: automated health check workflows with rapid create/delete cycles
Summary
When a PostgreSQL database is deleted while an initial backup is still running, the operator removes
pgbackrest-secretsbefore the backup completes, causing the backup to fail and the database to get stuck inDeletingstate.Steps to Reproduce
ReadystateIn Progress)Actual Behavior
<db-name>-pgbackrest-secretsSecretRunning, database stuckDeletingResource State When Stuck
$ kubectl get pg # cluster gone No resources found $ kubectl get perconapgbackups NAME STATUS AGE postgresql-wza-backup-lcmn Running 5m13s $ kubectl get perconapgcluster NAME STATUS AGE postgresql-wza Deleting 10mRoot Cause
Deletion flow removes Secrets before checking/waiting on in-progress backups. The backup pod needs the Secret to mount its config but it is already deleted.
Workaround
Manually recreate the
pgbackrest-secretsSecret (clone from another DB using same S3 bucket). This allows backup to finish and deletion to proceed.Proposed Fix
Ensure proper deletion ordering: wait for or cancel in-progress backups before deleting
pgbackrest-secrets.Environment