Skip to content

Commit

Permalink
Merge pull request #132 from DongbinCheng/ISSUE-132
Browse files Browse the repository at this point in the history
ISSUE-132: becomeCandidate don't count learners' prevote
  • Loading branch information
DongbinCheng authored Jun 5, 2024
2 parents 7add958 + a7214d6 commit af067b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/infra/raft/v2/RaftCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,12 +923,15 @@ void RaftCore::becomeCandidate() {

for (const auto &p : mPeers) {
auto &peer = p.second;
if (mLearners.find(peer.mId) != mLearners.end()) {
continue;
}
if (peer.mHaveVote) {
++voteNum;
}
}

auto quorumNum = getMajorityNumber(mPeers.size() + 1);
auto quorumNum = getMajorityNumber(mPeers.size() + 1 - mLearners.size());
if (voteNum < quorumNum) {
return;
}
Expand Down

0 comments on commit af067b7

Please sign in to comment.