percona / percona/percona-postgresql-operator
Race condition between backup and database deletion causes stuck resources
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 385
- Forks
- 83
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 39
Description
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
Readystate - 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-secretsSecret - Running backup pod fails with:
MountVolume.SetUp failed for volume "pgbackrest-config": secret "<db-name>-pgbackrest-secrets" not found - Backup remains stuck
Running, database stuckDeleting
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the database deletion flow and its handling of in-progress PerconaPGBackups, then reproduce the rapid delete case described with kubectl and inspect the Secret and backup resource states. Done means deletion waits for or cancels active backups before removing pgbackrest-secrets, and the database reaches a completed deletion state without leaving a Running backup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes, postgresql
- Domain
- database, devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100