Repository navigation
Description
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 think this is a new bug.
I am running a supported version of CloudNativePG
- I am running a supported version of CloudNativePG.
Version
1.30.1 (operator image ghcr.io/cloudnative-pg/cloudnative-pg:1.30.1, Helm chart cloudnative-pg-0.29.1)
What version of Kubernetes are you using?
1.35.7
What is your Kubernetes environment?
Cloud: Azure AKS
How did you install the operator?
Helm
What happened?
After a switchover, the new primary is labelled cnpg.io/instanceRole=primary 3.8–4.8 s after it has become status.currentPrimary. The -rw Service follows that label, so for those seconds clients behind it (PgBouncer Poolers here) have no endpoint.
From the operator's log, two reconciles happen between the promotion and the label. Each spends about 1.6–1.8 s in GetStatusFromInstances on the old primary:
- The old primary's instance manager is up, but its PostgreSQL is stopped while it waits to come back as a replica.
- So it answers the status request at once with HTTP 500 (
failed to connect … /controller/run/.s.PGSQL.5432). pkg/management/postgres/webserver/client/remote/instance.goretries that answer with backoff: 10 ms × 5ⁿ, 5 attempts, about 1.56 s.
The first of the two reconciles ends without relabelling (we suspect a status update conflict, which requeues it after 1 s; not confirmed). The second relabels (updateRoleLabels, pkg/reconciler/instance/metadata.go).
Measured across seven switchovers on 2026-10-09. All were planned switchovers of two-instance Clusters, made by setting status.targetPrimary.
Expected: a definite HTTP answer (5xx) from an instance manager is not retried; only connection-level errors are. The new primary is then relabelled within one reconcile. Fetching the instances' statuses concurrently would bound this as well.
Relevant log output
07:17:09.324 Setting primary label to unhealthy in the old primary during failover pod=…-1
07:17:09–17 There is a switchover or a failover in progress, waiting for the operation to complete (every ~1 s)
07:17:20.299 Cannot extract Pod status podName=…-1 error status code: 500, body: failed to connect to `user=postgres database=postgres`: /controller/run/.s.PGSQL.5432
07:17:22.114 Cannot extract Pod status podName=…-1 (same)
07:17:22.169 Setting replica label pod=…-1
07:17:22.208 Setting primary label pod=…-2The new primary was status.currentPrimary at about 07:17:18.
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
io41 commentedon Oct 12, 2026
Just found this bug while trying to figure out why switchovers are taking so long. Thanks for reporting!
kabbydriver commentedon Oct 13, 2026
Thanks for reporting, I think we may be looking at the same things: #11628
kabbydriver commentedon Oct 14, 2026
I put together a patch here: kabbydriver#1
fix(status): do not retry instance status HTTP errors (#11793)
fix(status): do not retry instance status HTTP errors (#11793)
fix(status): do not retry instance status HTTP errors (cloudnative-pg…