Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid re-electing primary during a switchover. #772

Merged
merged 8 commits into from
Aug 2, 2021

Conversation

DimCitus
Copy link
Collaborator

When all the nodes are up and running, including the primary, a switchover
has a great chance of finding that the current primary is then the best
candidate to with the primary election, making the operation a no-op.

In this PR we tweak the current primary node's candidate priority in a way
that should make it lose the election, and reset the priority when the
election is over.

Fixes #770.

@DimCitus DimCitus added bug Something isn't working Size: S Effort Estimate: Small labels Jul 12, 2021
@DimCitus DimCitus added this to the Sprint 2021 W31 W32 milestone Jul 12, 2021
@DimCitus DimCitus requested a review from JelteF July 12, 2021 15:42
@DimCitus DimCitus self-assigned this Jul 12, 2021
@JelteF
Copy link
Contributor

JelteF commented Jul 13, 2021

Needs a test

When all the nodes are up and running, including the primary, a switchover
has a great chance of finding that the current primary is then the best
candidate to with the primary election, making the operation a no-op.

In this PR we tweak the current primary node's candidate priority in a way
that should make it lose the election, and reset the priority when the
election is over.
Having two nodes with the same candidate priority, including the primary,
makes sure that we promote the node that is not a primary at failover() call
time.
@DimCitus DimCitus force-pushed the fix/avoid-re-electing-primary branch from 55f4dab to f1c4f5a Compare July 16, 2021 12:19
@DimCitus
Copy link
Collaborator Author

Needs a test

I tweaked an existing test to have the current primary and the target primary set to the same candidate priority, making sure that we still promote the target node rather than re-elect the current primary.

@DimCitus DimCitus merged commit 8702aea into master Aug 2, 2021
@DimCitus DimCitus deleted the fix/avoid-re-electing-primary branch August 2, 2021 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Size: S Effort Estimate: Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pg_autoctl perform switchover doesn't actually fail over since 1.6.1
2 participants