You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: double switchover on configuration upgrade #6956
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.32
What is your Kubernetes environment?
Self-managed: kind (evaluation)
How did you install the operator?
YAML manifest
What happened?
In a cluster with PrimaryUpgradeMethod: true, there is a nonzero probability that an update of a parameter that requires a restart triggers two switchovers, first restarting the primary, and later the newly promoted instance.
This can happen if an event happens after the primary has applied the new configuration while the other instances have not.
Applying the cluster-example.yaml with an instance controller that is forced to wait can be used to trigger the issue editing the clusters while the replicas are waiting
diff --git a/docs/src/samples/cluster-example.yaml b/docs/src/samples/cluster-example.yaml
index fb331362f..f4a5903dd 100644
--- a/docs/src/samples/cluster-example.yaml
+++ b/docs/src/samples/cluster-example.yaml
@@ -4,6 +4,7 @@ metadata:
name: cluster-example
spec:
instances: 3
+ primaryUpdateMethod: switchover
storage:
size: 1Gi
diff --git a/internal/management/controller/instance_controller.go b/internal/management/controller/instance_controller.go
index c1386796c..3036e73c1 100644
--- a/internal/management/controller/instance_controller.go
+++ b/internal/management/controller/instance_controller.go
@@ -222,6 +222,12 @@ func (r *InstanceReconciler) Reconcile(
restarted = restarted || restartedInplace
if reloadNeeded && !restarted {
+ // Wait one minute before reloading PostgreSQL to trigger the bug
+ if r.instance.GetPodName() != cluster.Status.CurrentPrimary {
+ contextLogger.Info("WAITING ONE MINUTE")
+ time.Sleep(1*time.Minute)
+ }
+
contextLogger.Info("reloading the instance")
if err = r.instance.Reload(ctx); err != nil {
return reconcile.Result{}, fmt.Errorf("while reloading the instance: %w", err)
Activity
fcanovai commentedon Feb 24, 2025
Applying the cluster-example.yaml with an instance controller that is forced to wait can be used to trigger the issue editing the clusters while the replicas are waiting
jsilvela commentedon Mar 5, 2025
Just want to make double-sure now that I'm testing Leo's fix:
@fcanovai in the description I see
This is rather
PrimaryUpdateMethod: switchover, right?fix: delay rollout until every Pods received the same configuration
fix: delay rollout until every Pods received the same configuration (#…
fix: delay rollout until every Pods received the same configuration (#…
fix: delay rollout until every Pods received the same configuration (#…
fix: delay rollout until every Pods received the same configuration (c…