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
[Feature]: Publish the primary's position on its lease and add the replica's "has all the data" decision #11884
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?
When a primary is shut down for a switchover, a replica may not yet have all the WAL the primary wrote. Today there is no way for the replica to tell, because the position of the old primary isn't available to it anywhere.
Describe the solution you'd like
The primary lease should carry a cnpg.io/position annotation holding the LSN, the timeline, the PostgreSQL state and the pod that wrote it, for example {"lsn":"0/7000028","timeline":3,"state":"in production","pod":"cluster-example-1"}.
While the primary runs, every write of the lease should refresh the annotation with the current WAL flush position.
When the primary shuts down, the lease should be released with the final position read from pg_controldata.
The state in the annotation should say whether PostgreSQL stopped cleanly or the position is only a lower bound.
If the position can't be determined, the annotation should say unknown instead of being removed.
We should then add a decision that compares the replica's own position with the one on the lease.
After a clean shutdown of the old primary, a replica that has all the data should promote.
After a clean shutdown of the old primary, a replica that is missing some data should wait for the WAL to arrive from the archive.
After a clean shutdown of the old primary, a replica on a later timeline than the old primary's last one should be blocked.
To keep the current behavior, after a failover, or when the position is unknown, the replica should promote and report the amount of WAL that may be missing.
Describe alternatives you've considered
N.A.
Additional context
No response
Backport?
No
Are you willing to actively contribute to this feature?
Activity
feat(instance): publish the primary's position and decide if a replic…