[Bug]: rapid termination of two replicas leads to stalled recovery

Aperta
#11,729 0 commenti 4 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@gbartolini ci sta già lavorando.

Dal 22/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug :bug: triage
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 (latest patch)

What version of Kubernetes are you using?

1.37

What is your Kubernetes environment?

Cloud: Amazon EKS

How did you install the operator?

YAML manifest

What happened?

A 3-instance cluster using synchronous replication and:

number: 1
failoverQuorum: true

can deadlock during a failover if the primary and one of the quorum-set replicas are preempted around the same time (in my case within about 1 second). Yes we should probably not be allowing preemption but I don't think it should lead to a total cluster stall.

The operator seemed to initiate failover fine when the primary became unhealthy and set targetPrimary to pending and waited for WAL receivers to go down. Then the second quorum-set replica disappeared and PR #11336 quorum re-check correctly returned ErrQuorumCheckFailed because only one member of the quorum set remains. It enters a loop logging Refusing to restore future timeline history file.

The operator loop handles that error by logging There is a switchover or a failover in progress, waiting for the operation to complete and returning a 1-second requeue result, which skips reconcileResources. Therefore it never reaches the pod/PVC reconciliation that would recreate the missing replica from its existing PVC.

Cluster resource

Relevant log output
| Time | Event (source) |
|---|---|
| 11:02:40.313 | kube-scheduler: "Preemptor Pod preempted victim Pod" victim=instance-3 (**primary**), preemptor = higher-priority app pod |
| 11:02:40.323 | instance-3: "Received termination signal", "Requesting smart shutdown" |
| 11:02:40.608 | operator: "Quorum check algorithm results" isStronglyConsistent=**true**, readSet=[1,2], W=1, N=2 |
| 11:02:40.608 | operator: pod status, both replicas ready, receivedLsn = replayLsn = `1AD/3706D628` |
| 11:02:40.608 | operator: "Current primary isn't healthy, initiating a failover"; sets `targetPrimary=pending`; "Setting primary label to unhealthy in the old primary" |
| 11:02:40.661 → 11:05:40.315 | operator: "Waiting for all WAL receivers to be down to elect a new primary" (169×). instance-1 still streaming from instance-3, which is in smart shutdown |
| 11:02:41.459 | kube-scheduler: preempted victim=instance-2 (**replica, member of quorum node set**) |
| 11:02:41.64 | instance-2: "database system is shut down" (shut down in recovery) |
| 11:05:40.743 | instance-3: smart-shutdown timeout hit, "checkpoint starting: shutdown immediate" |
| 11:05:40.993 | instance-3: checkpoint complete, lsn=`1AD/39000028`; instance-1: "replication terminated by primary server" |
| 11:05:41.440 | operator: quorum re-check isStronglyConsistent=**false**, readSet=[1]; "Strong consistency check failed. Preventing failover."; "Quorum check no longer satisfied, waiting before completing the failover" |
| 11:05:42.170 | instance-1: replayed to `1AD/390000A0` (end of valid WAL, past the shutdown checkpoint) |
| 11:05:43 | instance-3 pod deleted |
| 11:05:43 → ongoing | Every reconcile (~1 s): "Old primary pod not found in managed instances, skipping label demotion", "There is a switchover or a failover in progress…", quorum check fails. 13,000+ times. Status: `currentPrimary=instance-3`, `targetPrimary=pending` |
| after 11:05 | **No pod create** for instance-2 or instance-3 in the API audit log. Earlier preemptions this week were recreated by the operator within ~1 min |
Code of Conduct
  • I agree to follow this project's Code of Conduct
Lingua principale
Go
Stelle
9.7k
Fork
826
Merge medio
2g 1h
PR unite (30g)
122

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cloudnative-pg/cloudnative-pg

Tutte le issue di cloudnative-pg/cloudnative-pg

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.