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

Randomise leader election #5944

Closed
CAJan93 opened this issue Oct 20, 2022 · 3 comments
Closed

Randomise leader election #5944

CAJan93 opened this issue Oct 20, 2022 · 3 comments
Labels

Comments

@CAJan93
Copy link
Contributor

CAJan93 commented Oct 20, 2022

Is your feature request related to a problem? Please describe.

I noticed that we are currently always waiting for the same amount of time during leader election (see here)

let mut tick_interval = tokio::time::interval(Duration::from_secs(lease_time / 2));
loop {
    tick_interval.tick().await;

Maybe it makes sense to randomise this a bit and give different instances a slightly different tick_interval. This way we would space out requests a bit.

CC @yezizp2012

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

Raft also uses randomised timeouts during leader election to avoid collisions

@github-actions github-actions bot added this to the release-0.1.14 milestone Oct 20, 2022
@fuyufjh fuyufjh removed this from the release-0.1.14 milestone Oct 25, 2022
@ArshErgon
Copy link
Contributor

@CAJan93 whats the minimum value lease_time can have? and can you tell me how to test that particular file?

@yezizp2012
Copy link
Member

Well, I think it's not that necessary to do this, because: 1. eventually we will replace it with APIs of etcd lib or (some big refactoring); 2. even in current implementation, etcd will guarantee only one node will register successfully, it will ensure sequential writing of each requests.

@CAJan93
Copy link
Contributor Author

CAJan93 commented Nov 23, 2022

I agree, it is not needed, but it would still reduce the likelihood of simultaneous election-runs that may then be repeated. Therefore I introduced this randomisation in #6466
(it really is just very few lines of code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants