Ignore prevote if leader lease is still valid. #366
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Suppose a raft group ng0 consists of three nodes(A(localhost:8001),
B(localhost:8011), C(localhost:8021)), timeline is as follows: T1: A is elected
as the leader of group ng0. term 2. T2: Restart B. T3: B start prevote for
ng0, with log message node ng0:127.0.0.1:8011 term 2 start pre_vote T4: B got
prevote grant ack from A with log message node ng0:127.0.0.1:8011:1 received
PreVoteResponse from 127.0.0.1:8001:0 term 2 granted 1 rejected_by_lease 0
disrupted 1 T5: B start to vote. T6: B got vote grant ack from A. node
ng0:127.0.0.1:8011:1 received RequestVoteResponse from 127.0.0.1:8001:0 term 3
granted 1 rejected_by_lease 0 disrupted 1 T7: B got vote reject from C. node
ng0:127.0.0.1:8011:1 received RequestVoteResponse from 127.0.0.1:8021:0 term 2
granted 0 rejected_by_lease 1 disrupted 0 T8: B become the leader of ng0 with
term 3.
It's a bug that old leader A will accept the prevote and vote from reboot node B