Skip to content

[Bug]: /pg/status keeps reporting healthy while primary write-path is wedged, delaying operator failover #10678

Closed as not planned

Description

@Robert-Manolea

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.28 (latest patch)

What version of Kubernetes are you using?

1.34

What is your Kubernetes environment?

Cloud: Amazon EKS

How did you install the operator?

Helm

What happened?

Summary

We ran into this in production. An AWS EBS performance degradation event in us-east-1 wedged the data volume on a CNPG v1.28.0 primary: COMMITs hung at XLogFlush, replicas stopped receiving WAL, and the postmaster stayed alive. The operator did not initiate failover for hours after writes stopped completing. We had to manually destroy the primary to initiate the failover.

We managed to reproduce the operator-side behavior on a dev EKS cluster running the same CNPG version and image catalog as production, using AWS FIS aws:ebs:pause-volume-io against the primary's data EBS volume.

Two independent pauses, both reliably:

  • Blocked every client COMMIT for the full pause window.
  • Left the Cluster CR .status and the operator's view completely unchanged. Ready=True did not flip, no failover, no log lines for the affected cluster at default verbosity.

The cluster setup is as follows:

  • 3 instances (1 primary, 2 replicas), no .spec.probes.liveness.type, no livenessProbeTimeout, failoverDelay: 0.

Lab observation

The finding (the operator does not act on a write-path stall under default config) is reproduced deterministically in seconds with the following setup:

Same cluster config as above, single-row INSERT loop with wall-clock timestamps around each statement, FIS aws:ebs:pause-volume-io targeting the primary's EBS volume ARN.

We have observed the same identical behavior multiple times:

  • The INSERT in flight at pause-start printed start and blocked. Its done printed within 1 s of the pause ending. Hang duration matched the pause window. No INSERT completed inside the window.
  • Cluster CR .status: currentPrimary == targetPrimary throughout, instancesStatus.healthy listed all 3 pods, Ready=True with lastTransitionTime unchanged from the previous value, phase: "Cluster in healthy state".
  • Operator logs at default verbosity: zero lines mentioning this cluster's namespace during either window. Other clusters continued to generate reconcile chatter, so the operator was alive and processing work.

What this confirms: the operator's view of cluster health is fully decoupled from the primary's ability to serve writes. A primary that cannot complete any COMMIT is, to the operator, indistinguishable from a healthy primary.

Why we believe this happens (v1.28.0 source)

/pg/status is served by remote.go calling (*Instance).GetStatus().

On a primary the SQL touched is:

None dirty a buffer, write WAL, or flush. They read shared memory (pg_control_*, the WAL-sender ring, ProcArray) and catalog tables that are typically cached. So while user COMMITs block at issue_xlog_fsync, these queries return promptly with sensible values. pg_stat_replication rows continue to appear but with stale LSNs; GetStatus() does not record a timestamp against currentLsn, so a frozen LSN across many polls is not detectable from the payload alone.

The kubelet liveness probe is not a backstop either: at v1.28.0 livenessExecutor.IsHealthy on a primary returns OK whenever the API server is reachable; it issues no SQL. The streaming liveness type (streaming.go) short-circuits on NOT pg_is_in_recovery(). IsolationCheck only verifies external reachability.

What we would like to see (other suggestions welcome)

  1. Write-aware probe. A rate-limited tiny operation in /pg/status that exercises the WAL flush path; fail if it doesn't complete in a configurable budget. Specific mechanism up to maintainers.
  2. Per-poll LSN-advance check on the operator side. GetStatus() already returns currentLsn. If it does not advance across K consecutive polls while connections > N, flag suspect. Pure observation, no extra writes.

Cluster resource

Relevant log output

Code of Conduct

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

Activity

  1. dosubot commented on May 12, 2026

    @dosubot

    Hi @Robert-Manolea! I'm Dosu and I’m helping the cloudnative-pg team.

    Thank you for this thorough and well-researched report. Your analysis of the code paths is correct — the status endpoint and liveness probes exercise only read-only queries and connectivity checks, so a primary with a wedged write path (stuck at XLogFlush) remains invisible to the operator.

    This is a confirmed gap, and you're not the first to hit it in production. There are closely related issues tracking similar failure modes:

    Your two proposals align well with what the community has discussed:

    1. Write-aware probe — no implementation exists today. The probes only check connectivity (pg_isready, PingContext()) and isolation detection, never actual write/flush capability [4].
    2. LSN-advance check — currentLsn is indeed already returned by GetStatus(), but the operator collects it fresh each cycle with no historical comparison infrastructure in place [3].

    Additionally, the failover gates (AreWalReceiversDown in replicas.go, waitForWalReceiverDown in the instance controller) use effectively infinite polling loops with no timeout or staleness escalation — a separate but compounding factor in your scenario [1].

    Recent PRs (#10445, #10509) improved handling of transient /pg/status failures (network blips), but do not address the case where the endpoint succeeds with stale data because the underlying queries don't touch the write path [5] [6].

    In short: this is a real and reproducible gap across multiple production environments, with no current workaround within the operator itself. Your FIS reproduction is a clean demonstration of it.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about cloudnative-pg with Dosu Add Dosu to your team

  2. ardentperf commented on May 28, 2026

    @ardentperf
    Contributor

    I think there could be some other benefits to having some kind of write heartbeat. I think might be worth starting a discussion for the general topic. It can also help ensure that WAL files rotate and get archived.

  3. added
    bug 🐛
    and removed on Jun 21, 2026
  4. ardentperf commented on Jun 24, 2026

    @ardentperf
    Contributor

    caveat to above comment though - idk if we'd want to automatically trigger failover on write path failures. for example, a fairly obvious case would be where sync replication is configured (which it should be) and writes are stalled because there's no healthy replica. in this case, the primary is perfectly healthy and the replicas are the problem - we probably don't want a failover.

  5. github-actions commented on Aug 24, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open for 60 days with no activity.

  6. github-actions commented on Oct 11, 2026

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stalebug 🐛triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions