Skip to content

[Bug]: Replica cluster may fail over to the wrong instance #11495

Description

@leonardoce

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

[email protected]

Version

1.30.0

What version of Kubernetes are you using?

1.37

What is your Kubernetes environment?

Self-managed: kind (evaluation)

How did you install the operator?

YAML manifest

What happened?

In a replica cluster (https://cloudnative-pg.io/documentation/current/replica_cluster/),
CloudNativePG determines which instance is the current/designated primary
(and therefore the failover candidate) by sorting the list of instance statuses and
picking the first entry.

Due to a bug in the comparison function used for this sort, the designated primary
instance was not always guaranteed to end up first in the list.

Because the operator relies on the first item of the sorted status list as the
current/promotion-candidate primary, an incorrect ordering could lead the operator
reporting or acting on the wrong instance as the current primary of a replica cluster.

Note that all instances in a replica cluster are standbys replicating from an external
source and none of them accept writes, so this did not put data at risk of being
lost or diverged, the impact was limited to incorrect primary/failover bookkeeping
within the replica cluster.

Cluster resource

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. self-assigned this
    on Sep 16, 2026
  2. added
    bug 🐛
    on Sep 16, 2026
  3. added
    triage
    on Sep 16, 2026
  4. added this to the 1.30.1 milestone on Sep 18, 2026
  5. removed
    triage
    on Sep 18, 2026
  6. added 3 commits that reference this issue on Sep 21, 2026
    6c91950
    aa0e865
    29b5461
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

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions