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]: Replica can remain healthy after unrecoverable WAL replay loop #11134
A replica can enter an unrecoverable WAL replay failure loop while CNPG continues to treat the instance as healthy enough for normal operation. In this state the instance repeatedly logs WAL replay errors at the same LSN, but the operator does not get a hard status signal from the instance manager.
the broken replica becomes Ready even though WAL replay is stuck
the pod remains eligible for read traffic through normal service endpoints
the replica remains a possible failover/promotion target because /pg/status does not report an error
diagnosis currently depends on inspecting instance logs directly
Expected behavior:
When the instance manager detects repeated unrecoverable WAL replay errors with no replay progress, it should mark the instance unhealthy through existing readiness and status paths. CNPG should stop routing traffic to the replica and existing target-selection logic should avoid it.
Known log patterns include:
record with incorrect prev-link ... at ...
contrecord is requested by ...
A future enhancement may be useful to surface "user action needed" conditions directly on the Cluster object, but operator and instance logs are sufficient for the initial fix.
This is a well-documented report and aligns with a pattern of related issues that have been surfaced in production environments.
Confirming the gap: The codebase collects the relevant WAL replay metrics (ReplayLsn, ReceivedLsn, IsWalReceiverActive) and exposes them via /pg/status, but these values are only consulted during switchover/promotion target selection — not for continuous replica health assessment [1][2]. A replica whose WAL replay is looping at a fixed LSN will still return HTTP 200 from /pg/status and pass readiness checks as long as it can respond to read-only queries [3].
No existing detection for stuck replay: There is no operator-level logic that parses specific PostgreSQL WAL replay errors (like record with incorrect prev-link or contrecord is requested by) or tracks LSN stalls over time to mark an instance unhealthy [4].
Related prior incidents:
A replica stuck in WAL-restore loop for 40+ hours while the operator reported readyInstances: 3 and phase: "Cluster in healthy state" — same root cause of health probes not reflecting replication reality.
For the readiness side of this issue, one approach would be to have the instance manager track ReplayLsn across reconciliation cycles (or probe intervals) and mark the instance unhealthy via readiness when the LSN is not advancing despite PostgreSQL being in recovery. The failover target selection code already sorts replicas by LSN and excludes instances with status errors [5], so marking the instance with an error in its status response would automatically exclude it from promotion without requiring new failover logic.
This would pair nicely with your earlier pg_controldata-based progress signal proposal from #11024 — that one solves "don't kill a replica that IS making progress" while this issue is about "do mark a replica that ISN'T making progress."
Activity
dosubot commentedon Jul 6, 2026
This is a well-documented report and aligns with a pattern of related issues that have been surfaced in production environments.
Confirming the gap: The codebase collects the relevant WAL replay metrics (
ReplayLsn,ReceivedLsn,IsWalReceiverActive) and exposes them via/pg/status, but these values are only consulted during switchover/promotion target selection — not for continuous replica health assessment [1] [2]. A replica whose WAL replay is looping at a fixed LSN will still return HTTP 200 from/pg/statusand pass readiness checks as long as it can respond to read-only queries [3].No existing detection for stuck replay: There is no operator-level logic that parses specific PostgreSQL WAL replay errors (like
record with incorrect prev-linkorcontrecord is requested by) or tracks LSN stalls over time to mark an instance unhealthy [4].Related prior incidents:
readyInstances: 3andphase: "Cluster in healthy state"— same root cause of health probes not reflecting replication reality.IsActivelyReplaying()mechanism that would complement the fix needed here.For the readiness side of this issue, one approach would be to have the instance manager track
ReplayLsnacross reconciliation cycles (or probe intervals) and mark the instance unhealthy via readiness when the LSN is not advancing despite PostgreSQL being in recovery. The failover target selection code already sorts replicas by LSN and excludes instances with status errors [5], so marking the instance with an error in its status response would automatically exclude it from promotion without requiring new failover logic.This would pair nicely with your earlier
pg_controldata-based progress signal proposal from #11024 — that one solves "don't kill a replica that IS making progress" while this issue is about "do mark a replica that ISN'T making progress."To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
github-actions commentedon Oct 14, 2026
This issue is stale because it has been open for 60 days with no activity.
ardentperf commentedon Oct 20, 2026
I'm not sure if this is addressed yet. need to review