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

Ignore non-voters in leadership transfer #398

Merged

Conversation

f3nry
Copy link
Contributor

@f3nry f3nry commented Apr 8, 2020

A leader should not initiate an election on a non-voter, causing it to temporarily become a leader for a short period of time.

A leader should not initiate an election on a non-voter,
causing it to temporarily become a leader for a short period of time.
@hashicorp-cla
Copy link

hashicorp-cla commented Apr 8, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@briankassouf briankassouf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this! Just a single comment about the test, otherwise looks good.

raft_test.go Outdated

follower := c.Followers()[0]

demoteFuture := c.Leader().DemoteVoter(follower.localID, 0, 1*time.Nanosecond)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this a larger timeout or no timeout? Seems like 1 nanosecond could cause this to be flakey if go doesn't schedule the receiver right away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback - I changed this to zero.

@f3nry
Copy link
Contributor Author

f3nry commented Apr 8, 2020

@briankassouf Thank you for the review! I'm separately working on signing the CLA.

I'm wondering if there's additional places where we'd want to protect against this occurring or if this is sufficient. For example, should a node to reject a TimeoutNow request if it is currently a non-voter? Should it be an invalid state transition to become a candidate if a node doesn't have a vote?

@hanshasselberg
Copy link
Member

@f3nry I think you are correct, a non-voter should not become a leader and should reject leadership transfers.

There is an issue in Consul for your PR: hashicorp/consul#7031. And another one that is similar: hashicorp/consul#6979. The first one should be fixed by this PR. The last one is still open.

@f3nry
Copy link
Contributor Author

f3nry commented Apr 9, 2020

@i0rek It seems like the second bug is mostly protected by the configuration index check on line 207.. Under what conditions would r.configurations.latestIndex == r.configurations.committedIndex not pass?

@f3nry
Copy link
Contributor Author

f3nry commented Apr 14, 2020

@briankassouf CLA is signed and PR is ready to go!

@briankassouf
Copy link
Contributor

@f3nry Great! Thanks!

@briankassouf briankassouf merged commit e51cd9f into hashicorp:master Apr 14, 2020
Kvicii pushed a commit to Kvicii/raft that referenced this pull request Apr 19, 2020
* 'master' of github.com:hashicorp/raft:
  more efficient append bytes (hashicorp#399)
  Ignore non-voters in leadership transfer (hashicorp#398)
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.

4 participants