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.
(#11280 is related — an isolated primary that keeps accepting writes — but it is the opposite case.)
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
- Yes.
Version
1.30 (operator ghcr.io/cloudnative-pg/cloudnative-pg:1.30.1)
What version of Kubernetes are you using?
1.36
What is your Kubernetes environment?
Self-managed: RKE2
How did you install the operator?
Helm
What happened?
With the primary isolation check enabled (the default since 1.27, requestTimeout/connectionTimeout 1000 ms), the loss of a
node that hosted one replica restarted the healthy primary on another node. Every client lost the database for about
21 s, and there was no failover — the same pod came back as primary. Nothing was gained.
The documentation (docs/src/instance_manager.md, "Primary Isolation") says the liveness probe of a primary fails if both
"the instance manager cannot reach the Kubernetes API server" and "the instance manager cannot reach any other instance";
the note below it speaks of "a primary that has lost connectivity to both the API server and the other instances":
https://github.com/cloudnative-pg/cloudnative-pg/blob/v1.30.1/docs/src/instance_manager.md#L226-L245
The code fails the probe as soon as one instance in the last known InstancesReportedState is unreachable —
ensureInstancesAreReachable returns the first ping error:
https://github.com/cloudnative-pg/cloudnative-pg/blob/v1.30.1/pkg/management/postgres/webserver/probes/pinger.go#L104-L114
called from IsHealthy when the API server could not be reached:
https://github.com/cloudnative-pg/cloudnative-pg/blob/v1.30.1/pkg/management/postgres/webserver/probes/liveness.go#L91-L116
So when a replica's node dies and, at the same time, the API server does not answer the primary within 1 s for ~30 s (here an API
server endpoint was on the lost node), the primary — which can still reach the other replica — reports itself isolated and is
killed by the kubelet after failureThreshold (3 × 10 s).
Expected: an unreachable replica should not make a primary "isolated" while it can still reach another instance — i.e. fail
only if NO other instance is reachable, as documented (or by a majority rule). A sketch:
func (e pinger) ensureInstancesAreReachable(cluster *apiv1.Cluster) error {
var lastErr error
for name, state := range cluster.Status.InstancesReportedState {
if string(name) == cluster.Status.CurrentPrimary {
continue // ourselves
}
if err := e.ping(string(name), state.IP); err != nil {
lastErr = err
continue
}
return nil // at least one other instance answers: not isolated
}
return lastErr
}Workaround: spec.probes.liveness.isolationCheck.enabled: false (applied; the instance manager picks it up live, no rollout).
Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
spec:
instances: N # N >= 2: one primary, asynchronous streaming replicas on other nodes
imageName: ghcr.io/cloudnative-pg/postgresql:16.15
primaryUpdateStrategy: unsupervised
smartShutdownTimeout: 10
# probes: defaults at the time (isolationCheck enabled, requestTimeout/connectionTimeout 1000, livenessProbeTimeout 30)Relevant log output
The primary's instance manager (a replica's node powered off at ~22:04:20Z):
22:04:24.609 Instance connectivity error - liveness probe failing
22:04:25.919 readiness probe using cached cluster definition due to API server connectivity issue
22:04:34.608 Instance connectivity error - liveness probe failing
22:04:35.920 readiness probe using cached cluster definition due to API server connectivity issue
22:04:44.609 Instance connectivity error - liveness probe failing
22:04:44.617 Requesting smart shutdown of the PostgreSQL instance
22:04:54.653 Requesting fast shutdown of the PostgreSQL instance
Events of the primary's pod:
22:04:44Z Unhealthy: Liveness probe failed: HTTP probe failed with statuscode: 500
22:04:44Z Killing: Container postgres failed liveness probe, will be restarted
22:05:05Z Started: Container started
Clients saw FATAL: terminating connection due to administrator command at 22:05:05Z.
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
AhmedShaltout commentedon Oct 25, 2026
Another occurrence on 1.30.1, with one extra detail that makes the API leg of the predicate fire on a fault elsewhere in the cluster.
Setup: 3 instances, one per site across 3 sites,
synchronous: {method: any, number: 1, failoverQuorum: true},failoverDelay: 60, default liveness (10 s × 3) and default isolation check (1000/1000 ms). k3s with 5 apiservers, each talking only to its local etcd member.What happened:
default/kubernetesendpoints twice in between did not move the connection.cache.go), and/failsafeto that one replica timed out at 1000 ms, while the primary could reach the other replica and 4 of 5 apiservers.Instance connectivity error - liveness probe failingat +10/+20/+30 s withapiServerReachable:falseand the error naming the one replica. The kubelet sent SIGTERM 8 ms after the third failure. Smart shutdown, then fast shutdown and an in-place restart followed, with no failover. Clients lost the database for about 24 s, and it all started after the network fault had already cleared.Why this matters beyond the "ANY peer" semantics in this issue: with instances spread across sites, every primary has a peer on any given failing node, and its API connection lands on that node's apiserver about 1/N of the time. The two legs of the predicate are therefore not independent evidence of isolation. One sick node can satisfy both.
Requests, in addition to fixing the "any other instance" semantics described above:
InstancesReportedStateis unreachable, not on the first failed ping.Raising
livenessProbeTimeoutwould have masked this one, but it can't go abovefailoverDelaywithout risking two primaries, so the fix needs to be in the predicate.fix(postgres-operator-cloudnative-pg-migration): the isolation check …