Repository navigation
Description
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?
The problem is explained in discussion #7462 and relates to a potential and rare split-brain scenario caused by the non-transient isolation of a Postgres instance following a severe network partition.
Describe the solution you'd like
The solution proposed in this specific patch is to explore the possibility of relying on the Kubernetes liveness probe infrastructure to enable an isolated primary to self-fence itself in case of severe isolation.
Right now, the liveness probe returns false only if the REST web server of the instance manager is down. While this is still good for a replica and a single instance cluster, we could extend its behaviour and fail if all the following conditions are met:
- The instance is a primary in a multi-instance Postgres cluster.
- The API server cannot be reached.
- At least one replica’s WAL receiver is not connected to the primary.
- At least one instance is unreachable via the instance manager's REST API.
We should consider this a prototype feature for the moment. Should it fail, we will take a different approach. If it succeeds, we can continue exploring:
- the user interface (the current implementation of the
spec.probes.livenessstanza follows the Kubernetes standard, and we might think of introducing an option that enables/disables self-fencing) - the default values (currently, the liveness probe is set to 30 seconds via the
.spec.livenessProbeTimeoutoption)
As usual, during prototyping and exploration, feel free to change any of the above if better alternatives emerge.
Describe alternatives you've considered
If the liveness probe approach fails, we need to find a different way to achieve this that is equivalent in terms of steps and outcomes, but will require a different API.
Additional context
We should simulate the three main failures, cumulatively, in this order:
- API server is unreachable by the primary
- a WAL receiver is down
- an instance manager of a replica is non reachable
Network policies are the best way to test these scenarios, but I leave it up to the implementation.
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
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
gbartolini commentedon May 2, 2025
Related to #7407
gbartolini commentedon May 2, 2025
@leonardoce built a proof of concept and I was able to test it. See #7466 (comment)
I believe we should proceed in this direction.
5 remaining items
feat(cluster,status): track latest `Instance` IP (#7546)
feat(instance): liveness probe isolation checker
feat(instance): liveness probe isolation checker (cloudnative-pg#7466)
gbartolini commentedon May 13, 2025
This feature has now been introduced as opt-in experimental in 1.26. The ticket for the definitive API to be in 1.27 is #7551
[-][Feature]: Self-fencing of an isolated primary via the liveness probe[/-][+][Feature]: Experimental - Isolation Checker for the liveness probe of a primary[/+]