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

Changing interaction between Leave and RemovePeers #621

Merged
merged 4 commits into from
Jan 22, 2015
Merged

Changing interaction between Leave and RemovePeers #621

merged 4 commits into from
Jan 22, 2015

Conversation

armon
Copy link
Member

@armon armon commented Jan 21, 2015

Fixes #434. Previously, a graceful leave would just send the leave intention via Serf (gossip). The leader would detect the leave eventually and use that information to do a RemovePeer and catalog deregister. If the current leader was the one leaving, there was a race between the deregistration and the shutdown itself. Sometimes, the shutdown would happen first leaving the leader in the peer set. This was recoverable if quorum was not lost (e.g. >=3 servers). Other times deregister would happen, meaning quorum would not be lost for 2 node clusters. For a single node cluster, this RemovePeer against ourself was a bug. It would prevent the node from ever being able to establish leadership again when using -bootstrap or -bootstrap-expect.

This change prevents a node from ever processing a Serf leave intention about itself. This only affects a leave on the leader node. Instead, Leave() now does an explicit RemovePeer if we are the leader. This prevents the race condition, but allows us to guard against a single node cluster. For non-leaders, we now wait to ensure the RemovePeer can be replicated within a sane time window, preventing a potential quorum loss for small clusters.

@ryanuber
Copy link
Member

This LGTM. Clever fix!

armon added a commit that referenced this pull request Jan 22, 2015
Changing interaction between Leave and RemovePeers
@armon armon merged commit 149f25a into master Jan 22, 2015
@armon armon deleted the f-leave branch January 22, 2015 00:28
duckhan pushed a commit to duckhan/consul that referenced this pull request Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single-node bootstrapped server demotes only leader to follower on startup
2 participants