Skip to content

Commit

Permalink
remove _conf.contains check in pre_vote && elect_self
Browse files Browse the repository at this point in the history
It is necessary to allow nodes that do not exist in the configuration list to be elected as leaders.
  • Loading branch information
walterzhao committed Dec 25, 2023
1 parent f43c6a3 commit 3953a22
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/braft/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1622,11 +1622,6 @@ void NodeImpl::pre_vote(std::unique_lock<raft_mutex_t>* lck, bool triggered) {
" configuration is possibly out of date";
return;
}
if (!_conf.contains(_server_id)) {
LOG(WARNING) << "node " << _group_id << ':' << _server_id
<< " can't do pre_vote as it is not in " << _conf.conf;
return;
}

int64_t old_term = _current_term;
// get last_log_id outof node mutex
Expand Down Expand Up @@ -1681,11 +1676,6 @@ void NodeImpl::elect_self(std::unique_lock<raft_mutex_t>* lck,
bool old_leader_stepped_down) {
LOG(INFO) << "node " << _group_id << ":" << _server_id
<< " term " << _current_term << " start vote and grant vote self";
if (!_conf.contains(_server_id)) {
LOG(WARNING) << "node " << _group_id << ':' << _server_id
<< " can't do elect_self as it is not in " << _conf.conf;
return;
}
// cancel follower election timer
if (_state == STATE_FOLLOWER) {
BRAFT_VLOG << "node " << _group_id << ":" << _server_id
Expand Down

0 comments on commit 3953a22

Please sign in to comment.