Skip to content

fix(instance-manager): stop a superseded primary when the isolation check is disabled - #11795

Merged
leonardoce merged 3 commits into
mainfrom
dev/step-down-superseded-check-disabled
Nov 3, 2026
Merged

leonardoce merged 3 commits into
mainfrom
dev/step-down-superseded-check-disabled

Conversation

@mnencia

@mnencia mnencia commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

With the isolation check disabled, a primary never looked at its peers, so one that could not reach the API server kept running even after a peer reported that another instance had been named the target primary. That answer is proof that the primary was replaced, not a sign of isolation.

The peers are now probed whatever the setting says. Disabled, only a peer that names another target primary stops the primary. Unreachable peers do not, so an isolated primary keeps running, as it did before.

Closes #11777


Reviewer notes

An enabled check behaves as before. When an unreachable peer and a peer naming another target show up in the same round, the logged reason is now the superseded one instead of whichever came first.

The comparison is by target name only, so a peer with a stale cache that still names an older target would now also stop a disabled primary, as it already stops an enabled one. A cluster with no isolationCheck stanza at all still skips the check, as before.

Unit tests cover the disabled and enabled cases and the single-instance skip; e2e not run. Checked by hand on kind: with the check disabled, the primary's route to the API server dropped and status.targetPrimary patched to a replica, the primary now stops (container exit code 5, two seconds after the patch). Without the change it kept running and accepting writes for 110 seconds. With the whole node cut off from every peer, a disabled check still does not stop the primary, as before. tests/e2e/primary_self_isolation_test.go keeps its disabled fixture unchanged, for the same reason.

@mnencia
mnencia requested a review from a team as a code owner October 29, 2026 14:05
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@mnencia

mnencia commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

Copy link
Copy Markdown
Contributor

@mnencia
mnencia force-pushed the dev/step-down-superseded-check-disabled branch from 47bfc92 to 5700189 Compare October 29, 2026 15:25
@mnencia mnencia added do not backport This PR must not be backported - it will be in the next minor release and removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Oct 29, 2026
@mnencia

mnencia commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

Copy link
Copy Markdown
Contributor

@mnencia

mnencia commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

Copy link
Copy Markdown
Contributor

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Oct 30, 2026
mnencia and others added 2 commits November 3, 2026 10:41
…heck is disabled

With the isolation check disabled, a primary never looked at its peers,
so one that could not reach the API server kept running even after a peer
reported that another instance had been named the target primary. That
answer is proof that the primary was replaced, not a sign of isolation.

The peers are now probed whatever the setting says. Disabled, only a peer
that names another target primary stops the primary. Unreachable peers do
not, so an isolated primary keeps running, as it did before.

Closes #11777

Assisted-by: Claude
Signed-off-by: Marco Nenciarini <[email protected]>
…the isolation check is disabled

The pinger already carries the isolation check configuration, so it can
leave an unreachable peer out of the failures itself when the check is
disabled. shouldStepDown then needs no special case: whatever
ensureInstancesAreReachable reports is a reason to step down.

This removes the reordering of the probe results and the package-level
checker constructor that the tests had to swap. The verdict is the same
for every combination of peer answers; with the check enabled the
logged reason is again the first failure found, as on main.

Signed-off-by: Armando Ruocco <[email protected]>
@leonardoce
leonardoce force-pushed the dev/step-down-superseded-check-disabled branch from 252f209 to 38caa22 Compare November 3, 2026 09:41
Signed-off-by: Leonardo Cecchi <[email protected]>
@leonardoce

Copy link
Copy Markdown
Contributor

/test

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@leonardoce
leonardoce merged commit 3207622 into main Nov 3, 2026
@leonardoce
leonardoce deleted the dev/step-down-superseded-check-disabled branch November 3, 2026 12:40
cnpg-bot pushed a commit to cloudnative-pg/api that referenced this pull request Nov 3, 2026
…heck is disabled (cloudnative-pg/cloudnative-pg#11795)

With the isolation check disabled, a primary never looked at its peers,
so one that could not reach the API server kept running even after a
peer reported that another instance had been named the target primary.
That answer is proof that the primary was replaced, not a sign of
isolation.

The peers are now probed whatever the setting says. Disabled, only a
peer that names another target primary stops the primary. Unreachable
peers do not, so an isolated primary keeps running, as it did before.

Closes cloudnative-pg/cloudnative-pg#11777

Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Co-authored-by: Armando Ruocco <[email protected]>
Co-authored-by: Leonardo Cecchi <[email protected]>

(cherry picked from commit cloudnative-pg/cloudnative-pg@3207622)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not backport This PR must not be backported - it will be in the next minor release ok to merge 👌 This PR can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: with the primary isolation check disabled, a primary ignores a peer that names another target primary

4 participants