Skip to content

Commit 3953a22

Browse files
author
walterzhao
committed
remove _conf.contains check in pre_vote && elect_self
It is necessary to allow nodes that do not exist in the configuration list to be elected as leaders.
1 parent f43c6a3 commit 3953a22

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

src/braft/node.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,11 +1622,6 @@ void NodeImpl::pre_vote(std::unique_lock<raft_mutex_t>* lck, bool triggered) {
16221622
" configuration is possibly out of date";
16231623
return;
16241624
}
1625-
if (!_conf.contains(_server_id)) {
1626-
LOG(WARNING) << "node " << _group_id << ':' << _server_id
1627-
<< " can't do pre_vote as it is not in " << _conf.conf;
1628-
return;
1629-
}
16301625

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

0 commit comments

Comments
 (0)