Skip to content

[Bug]: restart-requiring parameter change with primaryUpdateMethod: switchover can trigger a double switchover that leaves the primary unchanged #11129

Description

@mnencia

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.100 primary -1 reloads, reports the pending restart
  • 03:39:04.194 / .200 replicas -2 / -3 reload, report the pending restart
  • 03:39:04.215 operator status snapshot: -1 pendingRestart=true, -2/-3 pendingRestart=false (all Ready, no errors)
  • 03:39:04 switchover -1 -> -2; -2 is promoted in place without a restart, still running the old shared_buffers
  • 03:39:35 the new primary -2 now reports the pending restart, switchover back -2 -> -1
  • currentPrimary ends 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 reproduce

Relevant 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

  1. added
    bug 🐛
    triage
    on Jul 4, 2026
  2. self-assigned this
    on Jul 4, 2026
  3. removed
    triage
    on Jul 4, 2026
  4. added theissue type on Jul 4, 2026
  5. added 2 commits that reference this issue on Jul 6, 2026
    d4ea08c
    d2ca706
  6. added a commit that references this issue on Jul 7, 2026
    c9e8676
  7. added 2 commits that reference this issue on Jul 8, 2026
    1835e13
    c6218bc
  8. added 3 commits that reference this issue on Jul 8, 2026
    b29fc70
    82a33a9
    d614393
  9. added a commit that references this issue on Jul 8, 2026
    0b2b8e1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions