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
No response
Version
trunk (main)
What version of Kubernetes are you using?
1.33
What is your Kubernetes environment?
Cloud: Amazon EKS
How did you install the operator?
YAML manifest
What happened?
This is a recurrence of #6956, which was fixed by #6991. The fix does not fully close the window, and the double switchover reappeared on the main nightly e2e (configuration_update, "performing a rolling update when a GUC requiring restart is modified").
On a 3-instance cluster with primaryUpdateMethod: switchover, changing a parameter that requires a restart (shared_buffers) triggers two switchovers in quick succession that cancel out, leaving status.currentPrimary on the original pod. Same second:
03:39:04.100primary-1reloads, reports the pending restart03:39:04.194/.200replicas-2/-3reload, report the pending restart03:39:04.215operator status snapshot:-1 pendingRestart=true,-2/-3 pendingRestart=false(allReady, no errors)03:39:04switchover-1 -> -2;-2is promoted in place without a restart, still running the oldshared_buffers03:39:35the new primary-2now reports the pending restart, switchover back-2 -> -1currentPrimaryends on-1, the original primary; no further switchovers
Expected: a single switchover to a replica that has already applied the change, so the primary role moves once and stays.
Why the #6991 gate does not catch it: the "delay rollout until every Pod received the same configuration" check keys on LoadedConfigurationHash, read from pg_show_all_file_settings() (pkg/management/postgres/probes.go), i.e. the hash of the postgresql.conf on disk. That goes uniform as soon as the operator distributes the config files, before the instances reload them. pending_restart (from pg_settings) only flips after each instance actually reloads. In the window between "files distributed" and "replicas reloaded", the gate sees a uniform config and proceeds while the replicas still report pendingRestart: false, and updatePrimaryPod promotes a replica that needs the same restart. Same race as #6956, at ~90ms under cloud latency instead of the artificial one-minute sleep from the original repro. The relevant code is unchanged across the current release branches (1.28, 1.29, 1.30) and main.
Impact is unchanged from #6956: self-healing (the parameter is applied, no data loss), but an extra failover and a brief window with a primary running stale configuration.
Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-configuration-update
spec:
instances: 3
primaryUpdateMethod: switchover
storage:
size: 1Gi
postgresql:
parameters:
shared_buffers: 128MB # then changed to 256MB to reproduceRelevant log output
03:39:04.100 pg-configuration-update-1 parameter "shared_buffers" cannot be changed without restarting the server
03:39:04.194 pg-configuration-update-2 parameter "shared_buffers" cannot be changed without restarting the server
03:39:04.200 pg-configuration-update-3 parameter "shared_buffers" cannot be changed without restarting the server
03:39:04.215 pod status name=pg-configuration-update-1 isPrimary=true isPodReady=true pendingRestart=true
03:39:04.215 pod status name=pg-configuration-update-2 isPrimary=false isPodReady=true pendingRestart=false
03:39:04.215 pod status name=pg-configuration-update-3 isPrimary=false isPodReady=true pendingRestart=false
03:39:04 The primary needs to be restarted, we'll trigger a switchover to do that currentPrimary=pg-configuration-update-1 targetPrimary=pg-configuration-update-2
03:39:06 The PostgreSQL instance has been promoted successfully (pg-configuration-update-2, same postmaster session, no restart)
03:39:35 The primary needs to be restarted, we'll trigger a switchover to do that currentPrimary=pg-configuration-update-2 targetPrimary=pg-configuration-update-1
03:39:41 Setting primary label pod=pg-configuration-update-1
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
fix(rollout): compare the running configuration hash, not the on-disk…
test(e2e): verify a restart-requiring change performs a single switch…
Update probes.go
fix(rollout): compare the running configuration hash, not the on-disk…
test(e2e): verify a restart-requiring change performs a single switch…
fix(rollout): compare the running configuration hash, not the on-disk…
fix(rollout): compare the running configuration hash, not the on-disk…
fix(rollout): compare the running configuration hash, not the on-disk…
fix(rollout): compare the running configuration hash, not the on-disk…