raft: fix vote reply handling in prevote

Do not register a reply to prevote as a real vote

Found and authored by @kostja.

Signed-off-by: Alejo Sanchez <alejo.sanchez@scylladb.com>
Message-Id: <20210604122530.1975388-1-alejo.sanchez@scylladb.com>
This commit is contained in:
Alejo Sanchez
2021-06-04 08:25:30 -04:00
committed by Avi Kivity
parent 50d64646cd
commit bd168d57ff

View File

@@ -692,6 +692,10 @@ void fsm::request_vote_reply(server_id from, vote_reply&& reply) {
logger.trace("{} received a {} vote from {}", _my_id, reply.vote_granted ? "yes" : "no", from);
auto& state = std::get<candidate>(_state);
// Should not register a reply to prevote as a real vote
if (state.is_prevote != reply.is_prevote) {
return;
}
state.votes.register_vote(from, reply.vote_granted);
switch (state.votes.tally_votes()) {