Skip to content

[Feature]: detect a replica that diverged from the primary's timeline and keep it out of service #12007

Description

@mnencia

Is there an existing issue already for this feature request/idea?

  • I have searched for an existing issue, and could not find anything. I believe this is a new feature request to be evaluated.

What problem is this feature going to solve? Why should it be added?

After a failover or switchover, a replica can have replayed WAL past the point where the new primary's timeline forked away from its own. It can never follow the new primary. PostgreSQL logs "new timeline N forked off current database system timeline N-1 before current recovery point X/Y" and the replica waits for WAL that never arrives.

The operator does not notice. With the default probes the replica stays ready, the cluster stays in "Cluster in healthy state", and the replica stays in the -r and -ro services. Reads from it are stale and can return writes that the failover discarded.

It can also be promoted: the election orders replicas by LSN and ignores the timeline, so it wins while its LSN is the highest, or when it is the only replica. That brings the discarded writes back and loses every write made after the failover.

Its HA replication slot on the primary stays, so the primary keeps WAL for it without limit.

No status field, condition, event or metric reports it. cnpg_pg_replication_lag even reads 0 on that replica. The user has to find the PostgreSQL log line.

Related: #11557, #11114, #11715

Describe the solution you'd like

The operator detects the divergence and reports it. It keeps the replica out of the read services, never promotes it, and stops retaining WAL for it.

Describe alternatives you've considered

None. Today the user has to find the PostgreSQL log line and rebuild the replica by hand.

Additional context

Backport?

No

Are you willing to actively contribute to this feature?

Yes

Code of Conduct

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

Activity

  1. added
    bug 🐛
    on Nov 24, 2026
  2. self-assigned this
    on Nov 24, 2026
  3. added theissue type on Nov 24, 2026
  4. added this to the 1.31.0 milestone on Nov 24, 2026
  5. changed the title [-][Bug]: a replica that diverged from the primary's timeline stays ready and can be promoted[/-] [+][Feature]: detect a replica that diverged from the primary's timeline and keep it out of service[/+] on Nov 24, 2026
  6. added
    enhancement 🪄
    and removed
    bug 🐛
    on Nov 24, 2026
  7. changed the issue type fromtoon Nov 24, 2026
  8. added a commit that references this issue on Nov 24, 2026
    642d7aa
  9. added a commit that references this issue on Nov 24, 2026
    f4f0f33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement 🪄

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions