Repository navigation
fix(instance): align enforced parameters on the demotion path (#10716) - #10856
Open
ermakov-oleg wants to merge 2 commits into
Open
ermakov-oleg wants to merge 2 commits into
ermakov-oleg wants to merge 2 commits into
Conversation
…ative-pg#10716) Signed-off-by: ermakov-oleg <[email protected]>
…parameter decrease Signed-off-by: ermakov-oleg <[email protected]>
ermakov-oleg
requested review from
NiccoloFei,
jsilvela and
litaocdl
as code owners
June 9, 2026 14:45
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
4 tasks done
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.
When a hot-standby-sensitive ("enforced") parameter such as
max_connectionsis decreased in the spec underprimaryUpdateStrategy: supervisedand a switchover then happens, the demoted old primary cannot rejoin: it starts as a standby with the lower value whilepg_controldatastill holds the higher one, and PostgreSQL aborts recovery. The pod stays inCrashLoopBackOffand the only way out is to wipe its PVC and let CNPG re-bootstrap it.Root cause.
initialize()runsverifyParametersForFollowerbeforeverifyPgDataCoherenceForPrimary. On the demoting podIsPrimary()is still true at that point (standby.signalis written later, insideDemote()), so the follower parameter alignment short-circuits and never runs.Demote()only writesstandby.signal/primary_conninfoand does not touch the enforced parameters, so the standby comes up with the decreased value and aborts recovery.Fix.
pg_controldataright afterDemote()(both demotion branches ofverifyPgDataCoherenceForPrimary), through a dedicatedalignEnforcedParametersForFollower. It intentionally bypasses thecnpg_initializedstartup-flag guard used byverifyParametersForFollower: a former primary that was never a follower has no such flag, so merely re-runningverifyParametersForFollowerafterDemote()would short-circuit again and silently skip the alignment. Calling the alignment directly makes it run on the first standby start, before recovery begins.PhaseWaitingForUserreason now points to an in-place primary restart instead of a switchover: a switchover does not converge a decrease (the promoted replica still carries the higher value, since followers are kept aligned upward), an in-place restart of the primary does.Covered by a new e2e suite (
supervised_switchover_param_test.go).Closes #10716