An industrial-grade C++ implementation of RAFT consensus algorithm based on brpc, widely used inside Baidu to build highly-available distributed systems.
Apache License 2.0
3.99k
stars
886
forks
source link
Ignore prevote if leader lease is still valid. #366
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
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