Skip to content

Commit

Permalink
fix ha re election
Browse files Browse the repository at this point in the history
  • Loading branch information
LLiuJJ committed Aug 16, 2024
1 parent dcb6096 commit 27fa0f5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion raftcore/src/raft_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ EStatus RaftServer::RunCycle() {
while (true) {
SPDLOG_INFO("heartbeat_tick_count_ " +
std::to_string(heartbeat_tick_count_));
SPDLOG_INFO("election_tick_count_ " +
std::to_string(election_tick_count_));
SPDLOG_INFO("election_timeout_ " + std::to_string(election_timeout_));
SPDLOG_INFO("node role " + NodeRoleToStr(role_));
SPDLOG_INFO("commit idx {} applied idx {}",
this->commit_idx_,
Expand All @@ -185,10 +188,11 @@ EStatus RaftServer::RunCycle() {
if (this->role_ == NodeRaftRoleEnum::Leader) {
SPDLOG_INFO("heartbeat timeout");
this->SendHeartBeat();
this->ResetRandomElectionTimeout();
heartbeat_tick_count_ = 0;
}
}
if (election_tick_count_ >= election_timeout_ && election_running_) {
if (election_tick_count_ >= election_timeout_) {
switch (this->role_) {
case NodeRaftRoleEnum::Follower: {
SPDLOG_INFO("start pre election in term {} ", current_term_);
Expand Down

0 comments on commit 27fa0f5

Please sign in to comment.