Repository navigation
Conversation
A replica catching up on WAL after a restart, or a primary performing crash recovery, can spend more than startDelay without accepting connections. The startup probe then fails and the kubelet kills the Pod, losing all the replay work done so far and repeating it at every restart (#11024). The instance manager now tracks evidence that WAL replay is making progress by sampling the title of the PostgreSQL startup process. The startup process sets its title to "recovering <segment>" every time it opens a WAL segment, whether it comes from pg_wal, streaming replication or the WAL archive, so the segment name is a replay position advancing in every form of recovery, on any supported PostgreSQL version and regardless of the log messages locale. While replay is progressing, the startup probe reports success instead of failing, handing control over to the readiness probe, which keeps the instance out of the ready set until PostgreSQL accepts connections. Since the kubelet stops running the startup probe after its first success, the liveness probe takes over stall detection: if replay stops making progress for more than startDelay before PostgreSQL accepts connections, the liveness probe fails and the Pod is restarted. startDelay therefore bounds the time allowed without replay progress instead of the total startup time. Based on the diagnosis of #11024 and on the probe design proposed in #11138. Fixes #11024 Co-authored-by: Jeremy Schneider <[email protected]> Signed-off-by: Armando Ruocco <[email protected]>
The startup probe now reports success during a progressing WAL replay only when the new .spec.probes.startup.skipOnWALReplay option is enabled, and only with the default pg_isready startup strategy, so that custom startup strategies keep their configured semantics. Since the replay position is observed at WAL segment granularity, the stall timeout enforced by the liveness probe is now scaled with the WAL segment size read from the control file, avoiding the restart of an instance that is still making progress within a segment larger than the default 16MiB. Signed-off-by: Armando Ruocco <[email protected]>
Persist the startup skip and completion latches to a file on the pod scratch volume: the kubelet keeps its startup probe state across an in-place instance manager upgrade, so a new instance manager process has to keep the stalled replay detection armed too. When a persisted skip latch is restored, the stall clock restarts from load time, giving a progressing instance a full fresh timeout while a stuck one is still detected. Log the state transitions (startup probe first reported as passed during replay, and replay completed) at info level, so the behavior can be diagnosed from the instance logs. Warn at admission time about skipOnWALReplay values that the schema accepts but the runtime ignores: the option set on the readiness probe, or enabled together with a custom startup strategy. Signed-off-by: Armando Ruocco <[email protected]>
succeedDuringWALReplay describes what actually happens: the startup probe succeeds while WAL replay is progressing. Nothing is skipped, that wording leaked from the probe response body. Signed-off-by: Armando Ruocco <[email protected]>
The freshness window used by the startup probe to decide whether the observed WAL replay progress is current defaults to 5 minutes and can now be tuned with .spec.probes.startup.walReplayProgressTimeoutSeconds, for instances whose replay of a single WAL segment may reasonably take longer. Signed-off-by: Armando Ruocco <[email protected]>
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
The admission webhook now also warns when walReplayProgressTimeoutSeconds is set on the readiness probe or without succeedDuringWALReplay enabled, since the runtime ignores it in both cases. Signed-off-by: Armando Ruocco <[email protected]>
Member
Author
|
/test |
Contributor
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/28869434787 |
Member
Author
|
closing in favor of #11152 |
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11024