Skip to content

fix(replica clusters): requeue until the instances report a system ID - #11603

Closed
gabriele-wolfox wants to merge 1 commit into
cloudnative-pg:mainfrom
gabriele-wolfox:fix/replica-demotion-requeue
Closed

gabriele-wolfox wants to merge 1 commit into
cloudnative-pg:mainfrom
gabriele-wolfox:fix/replica-demotion-requeue

Conversation

@gabriele-wolfox

Copy link
Copy Markdown
Contributor

After a role swap, the demoted cluster could keep reporting ConsistentSystemID=False (NotFound) with an empty status.systemID for tens of minutes, although its instances were healthy again within seconds.

The instances are sampled while still fenced or restarting, and the follow-up reconciliations end without a requeue. Status-only updates do not retrigger the controller, and the short fence does not flip any Pod readiness, so nothing refreshes the condition until an unrelated event touches the Cluster.

On replica clusters, requeue after 5 seconds when instances were sampled but none reported a system ID, unless instances are fenced on purpose.

Closes #11602

Assisted-by: Claude

@gabriele-wolfox
gabriele-wolfox requested a review from a team as a code owner October 2, 2026 10:36
@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 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

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

After a role swap, the demoted cluster could keep reporting
ConsistentSystemID=False (NotFound) with an empty status.systemID for
tens of minutes, although its instances were healthy again within
seconds.

The instances are sampled while still fenced or restarting, and the
follow-up reconciliations end without a requeue. Status-only updates
do not retrigger the controller, and the short fence does not flip any
Pod readiness, so nothing refreshes the condition until an unrelated
event touches the Cluster.

On replica clusters, requeue after 5 seconds when instances were
sampled but none reported a system ID, unless instances are fenced on
purpose.

Closes cloudnative-pg#11602

Assisted-by: Claude
Signed-off-by: Gabriele Quaresima <[email protected]>
@gabriele-wolfox
gabriele-wolfox force-pushed the fix/replica-demotion-requeue branch from e3383a5 to 2082a7f Compare October 2, 2026 10:44
@armru
armru force-pushed the fix/replica-demotion-requeue branch from 2082a7f to 8a6c6c0 Compare October 12, 2026 10:56
@armru

armru commented Oct 12, 2026

Copy link
Copy Markdown
Member

/test

@github-actions

Copy link
Copy Markdown
Contributor

@armru
armru force-pushed the fix/replica-demotion-requeue branch 2 times, most recently from fa937b6 to 2082a7f Compare October 12, 2026 13:04
@armru

armru commented Oct 12, 2026

Copy link
Copy Markdown
Member

Hi @gabriele-wolfox, thanks for the detailed report and the analysis in #11602.

Could you take a look at #11645? It fixes the same problem in the instance manager instead of the operator. While an instance is fenced or restarting, the status probe masks the connection error and returns no system ID, even though pg_control holds it and can be read with PostgreSQL down. #11645 fills it from pg_control in that case, so after a demotion the instances keep reporting the system ID and ConsistentSystemID never drops to NotFound. That removes the need for the requeue.

I reproduced your swap on kind: on main the demoted cluster stayed False/NotFound for 300s, and with #11645 it stayed True/Unique throughout.

Let me know what you think.

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Oct 12, 2026
@gabriele-wolfox

Copy link
Copy Markdown
Contributor Author

Hi @armru , thanks to look into the issue.
I agree with your approach, I think this version is more precise than my original proposal.
I think we can abandon my PR and go with yours.

@mnencia

mnencia commented Oct 15, 2026

Copy link
Copy Markdown
Member

Superseded by #11645

@mnencia mnencia closed this Oct 15, 2026
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 ok to merge 👌 This PR can be merged release-1.28 release-1.30

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ConsistentSystemID stays False (NotFound) for a long time after a replica cluster demotion

4 participants