Skip to content

Commit

Permalink
reject prevote explicitly when in lease
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Lee <[email protected]>
  • Loading branch information
BusyJay committed Mar 7, 2021
1 parent 6a895ab commit 158f7f1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,18 @@ impl<T: Storage> Raft<T> {
"msg type" => ?m.get_msg_type(),
);

// When judge_split_prevote, reject explicitly to make candidate exit PreCandiate early
// so it will vote for other peer later.
if self.judge_split_prevote
&& m.get_msg_type() == MessageType::MsgRequestPreVote
{
let mut to_send =
new_message(m.from, MessageType::MsgRequestPreVoteResponse, None);
to_send.term = m.term;
to_send.reject = true;
self.r.send(to_send, &mut self.msgs);
}

return Ok(());
}
}
Expand Down

0 comments on commit 158f7f1

Please sign in to comment.