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 have read the troubleshooting guide and I think this is a new bug.
Contact Details
Version
1.30 (latest patch)
What version of Kubernetes are you using?
1.37
What is your Kubernetes environment?
Cloud: Amazon EKS
How did you install the operator?
Helm
What happened?
This investigation was primarily done and documented with AI.
While investigating a rolling restart of a three-instance CloudNativePG
1.30.1 cluster, we found a pointer/value mismatch in the instance-status
HTTP retry logic. The mismatch is also present on current main.
In pkg/management/postgres/webserver/client/remote/instance.go,
rawInstanceStatusRequest returns *StatusError for a non-200 response.
However, getReplicaStatusFromPodViaHTTP checks:
var statuserror StatusError
if errors.As(err, &statuserror) {
return false
}
The destination holds a StatusError value, so it does not match the
returned *StatusError. Consequently, HTTP status errors take the retry
path and consume all five attempts.
Expected behavior: a non-200 HTTP response should stop immediately,
consistent with the existing comment and retry predicate. Transient
transport errors should continue to retry.
We independently reproduced this with a unit test using a mocked HTTP
transport through the actual getReplicaStatusFromPodViaHTTP path:
- HTTP 500: expected one request, observed five before the fix.
- Changing the declaration to
var statuserror *StatusErrormakes the
test pass with one request. - A separate test confirms that a transient transport error still retries
and succeeds on the second request. - The complete remote package suite passes after the fix.
Operational context: during the rolling restart, PostgreSQL on the new
primary became ready at 15:03:01.304, while the operator applied its primary
role label at 15:03:05.052—a 3.748-second gap delaying RW service routing.
During this interval, the old primary's /pg/status returned HTTP 500
because its PostgreSQL socket was absent.
The unnecessary retries plausibly contributed to that delay, but this
timing attribution is an inference. We have not measured an end-to-end
improvement after deploying the fix.
Proposed change: correct the errors.As destination type and add regression
tests for HTTP-error termination and transient transport-error recovery.
No timeout, failover-safety, or service-reconciliation changes are proposed.
Cluster resource
Relevant log output
22:02:58.481 operator "The primary needs to be restarted, we'll trigger a switchover to do that"
currentPrimary=core-db-1 targetPrimary=core-db-3
reason="cluster has been explicitly restarted via annotation"
22:02:58.719 core-db-1 "received fast shutdown request"
22:02:58.737 operator "Setting primary label to unhealthy in the old primary during failover"
pod=core-db-1
22:03:00.834 core-db-3 "received promote request"
22:03:01.304 core-db-3 "database system is ready to accept connections"
22:03:03.203 operator "Cannot extract Pod status"
podName=core-db-1
error="error status code: 500, body: failed to connect to
`user=postgres database=postgres`: /controller/run/.s.PGSQL.5432
(/controller/run): dial error: dial unix
/controller/run/.s.PGSQL.5432: connect: no such file or directory"
22:03:04.999 operator "Cannot extract Pod status"
podName=core-db-1
[same HTTP 500 / missing PostgreSQL socket error]
22:03:05.051 operator "Setting primary label"
pod=core-db-3Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
kabbydriver commentedon Oct 8, 2026
I'd like to work on this.
Proposed fix:
kabbydriver commentedon Oct 14, 2026
The patch is ready for review: kabbydriver#1
Regression tests confirm five HTTP requests before the fix and one afterward, while preserving transport retries. Local unit tests and 50 smoke/basic E2E specs passed using the patched operator. Could you confirm the approach and assign the issue to me?
pal-salih commentedon Oct 20, 2026
We hit the same bug independently and reported it with switchover timings in #11637: across seven planned switchovers on 1.30.1, the new primary got its
instanceRole=primarylabel 3.8–4.8 s after becomingcurrentPrimary, and each of the two reconciles in between spent about 1.6 s retrying the old primary's HTTP 500. The one-line fix in kabbydriver#1 (StatusError→*StatusError) matches what we found.@kabbydriver is ready to open the PR and is waiting for assignment. Could a maintainer confirm the approach and assign this issue?
kabbydriver commentedon Oct 22, 2026
@gbartolini would you mind taking a look?
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…