Skip to content

Commit

Permalink
raft: handle non voting members correctly in stepdown procedure
Browse files Browse the repository at this point in the history
For leader stepdown purposes a non voting member is not different
from a node outside of the config. The patch makes relevant code paths
to check for both conditions.
  • Loading branch information
Gleb Natapov committed Nov 18, 2021
1 parent 6a9b3cd commit 814dea3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions raft/fsm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,11 @@ void fsm::tick_leader() {

if (state.stepdown) {
logger.trace("tick[{}]: stepdown is active", _my_id);
if (leader_state().tracker.find(_my_id) == nullptr) {
auto me = leader_state().tracker.find(_my_id);
if (me == nullptr || !me->can_vote) {
// Do not abort stepdown if not part of the current
// config.
// config or non voting member since the node cannot
// be a leader any longer
} else if (*state.stepdown <= _clock.now()) {
logger.trace("tick[{}]: cancel stepdown", _my_id);
// Cancel stepdown (only if the leader is part of the cluster)
Expand Down Expand Up @@ -995,7 +997,8 @@ void fsm::send_timeout_now(server_id id) {
logger.trace("send_timeout_now[{}] send timeout_now to {}", _my_id, id);
send_to(id, timeout_now{_current_term});
leader_state().timeout_now_sent = id;
if (leader_state().tracker.find(_my_id) == nullptr) {
auto me = leader_state().tracker.find(_my_id);
if (me == nullptr || !me->can_vote) {
logger.trace("send_timeout_now[{}] become follower", _my_id);
become_follower({});
}
Expand Down

0 comments on commit 814dea3

Please sign in to comment.