Skip to content

[Feature]: Experimental - Isolation Checker for the liveness probe of a primary #7465

Description

@gbartolini

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:

  1. The instance is a primary in a multi-instance Postgres cluster.
  2. The API server cannot be reached.
  3. At least one replica’s WAL receiver is not connected to the primary.
  4. 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.liveness stanza 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.livenessProbeTimeout option)

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

Activity

  1. added
    enhancement 🪄
    on May 1, 2025
  2. self-assigned this
    on May 1, 2025
  3. moved this to Todo in Roadmapon May 1, 2025
  4. added this to the 1.27.0 milestone on May 1, 2025
  5. gbartolini commented on May 2, 2025

    @gbartolini
    ContributorAuthor

    Related to #7407

  6. gbartolini commented on May 2, 2025

    @gbartolini
    ContributorAuthor

    @leonardoce built a proof of concept and I was able to test it. See #7466 (comment)

    I believe we should proceed in this direction.

  7. 5 remaining items

  8. added
    do not backport
    on May 12, 2025
  9. added a commit that references this issue on May 12, 2025
    26dee7f
  10. moved this from Todo to Done in Roadmapon May 12, 2025
  11. added a commit that references this issue on May 12, 2025
    0a18bcb
  12. gbartolini commented on May 13, 2025

    @gbartolini
    ContributorAuthor

    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

  13. modified the milestones: 1.27.0, 1.26.0 on May 13, 2025
  14. changed the title [-][Feature]: Self-fencing of an isolated primary via the liveness probe[/-] [+][Feature]: Experimental - Isolation Checker for the liveness probe of a primary[/+] on May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

do not backportenhancement 🪄

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions