From bd168d57ffed1dc73cb000b301674ebb1b9fd5d2 Mon Sep 17 00:00:00 2001 From: Alejo Sanchez Date: Fri, 4 Jun 2021 08:25:30 -0400 Subject: [PATCH] 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 Message-Id: <20210604122530.1975388-1-alejo.sanchez@scylladb.com> --- raft/fsm.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/raft/fsm.cc b/raft/fsm.cc index 38d1304c0a..970d1f7c76 100644 --- a/raft/fsm.cc +++ b/raft/fsm.cc @@ -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(_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()) {