diff --git a/src/raft.rs b/src/raft.rs index 8a539f114..55d7b3ec5 100644 --- a/src/raft.rs +++ b/src/raft.rs @@ -1289,6 +1289,18 @@ impl Raft { "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(()); } }