Skip to content

fix(probes): stop an isolated primary with an immediate shutdown - #11504

Closed
mnencia wants to merge 1 commit into
mainfrom
dev/11280-minimal
Closed

mnencia wants to merge 1 commit into
mainfrom
dev/11280-minimal

Conversation

@mnencia

@mnencia mnencia commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

The isolation check only failed the liveness probe, leaving the shutdown to the kubelet's ordinary termination path. That is a smart shutdown: it lets already-open sessions keep committing for up to smartShutdownTimeout (180s default), while a replacement primary may already be promoting.

On the first isolation failure, request an immediate shutdown of PostgreSQL directly, instead of waiting for the kubelet's SIGTERM. Immediate shutdown skips the checkpoint and the fast phase, so nothing delays it. The instance is already headed for a rewind, so the crash recovery this costs on the next start is free. Reuses the non-blocking request PR #11347 added for the same reason, a primary that can't be trusted to shut down cleanly.

Firing on the first failure, rather than matching the kubelet's own failureThreshold, means a transient blip a retry would have cleared can trigger a shutdown too. Accepted trade-off: a truly isolated primary should stop immediately.

This does not order detection against replica promotion. Detection follows the kubelet's probe cadence; promotion follows the primary lease's LeaseDuration on branches that have one (1.30+), with no time floor at all on branches that don't (1.28/1.29). At the defaults the two are roughly a tie, not a guaranteed order. Only PR #11357 closes that gap, by detecting isolation off the lease's own renewal clock instead of the probe.

PR #11283 took the same approach as this patch. It was closed as partially superseded by #11357 on main. This is a backport-sized version for the release branches #11357 won't reach.

Closes #11280

@mnencia
mnencia requested a review from a team as a code owner September 18, 2026 12:32
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.29 release-1.30 labels Sep 18, 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

The isolation check only failed the liveness probe, leaving the shutdown
to the kubelet's ordinary termination path. That is a smart shutdown: it
lets already-open sessions keep committing for up to smartShutdownTimeout
(180s default), while a replacement primary may already be promoting.

On the first isolation failure, request an immediate shutdown of
PostgreSQL directly, instead of waiting for the kubelet's SIGTERM.
Immediate shutdown skips the checkpoint and the fast phase, so nothing
delays it. The instance is already headed for a rewind, so the crash
recovery this costs on the next start is free. Reuses the non-blocking
request PR #11347 added for the same reason, a primary that can't be
trusted to shut down cleanly.

Firing on the first failure, rather than matching the kubelet's own
failureThreshold, means a transient blip a retry would have cleared can
trigger a shutdown too. Accepted trade-off: a truly isolated primary
should stop immediately.

This does not order detection against replica promotion. Detection
follows the kubelet's probe cadence; promotion follows the primary
lease's LeaseDuration on branches that have one (1.30+), with no time
floor at all on branches that don't (1.28/1.29). At the defaults the two
are roughly a tie, not a guaranteed order. Only PR #11357 closes that
gap, by detecting isolation off the lease's own renewal clock instead of
the probe.

PR #11283 took the same approach as this patch. It was closed as
partially superseded by #11357 on main. This is a backport-sized version
for the release branches #11357 won't reach.

Closes #11280

Signed-off-by: Marco Nenciarini <[email protected]>
@mnencia

mnencia commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

Copy link
Copy Markdown
Contributor

@mnencia mnencia added the do not merge 🙅 This PR cannot be merged (yet) label Sep 19, 2026
@mnencia

mnencia commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

Not merging this. CI found it can shut down the primary on an ordinary transient connectivity blip, not just a real isolation event, which makes it unsafe to backport. Superseded by the primary-lease mechanism landing in 1.31.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases do not merge 🙅 This PR cannot be merged (yet) release-1.28 release-1.30

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: the primary isolation check does not stop an isolated primary from accepting writes

2 participants