Skip to content

Commit

Permalink
[Update PR] Add comments and put more set_recovered() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
greensky00 committed Jul 18, 2024
1 parent b2d0b07 commit e45952a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion include/libnuraft/peer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public:
, reconn_backoff_(0)
, suppress_following_error_(false)
, abandoned_(false)
, lost_by_leader_(false)
, rsv_msg_(nullptr)
, rsv_msg_handler_(nullptr)
, l_(logger)
Expand Down Expand Up @@ -502,7 +503,11 @@ private:
*/
std::atomic<bool> abandoned_;

std::atomic<bool> lost_by_leader_ {false};
/**
* If `true`, this peer is considered unresponsive
* and treated as if it has been lost.
*/
std::atomic<bool> lost_by_leader_;

/**
* Reserved message that should be sent next time.
Expand Down
3 changes: 2 additions & 1 deletion src/raft_server.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,10 @@ void raft_server::handle_peer_resp(ptr<resp_msg>& resp, ptr<rpc_exception>& err)
peer* pp = entry->second.get();
int rpc_errs = pp->get_rpc_errs();
if (rpc_errs >= raft_server::raft_limits_.warning_limit_) {
pp->set_recovered();
p_wn("recovered from RPC failure from peer %d, %d errors",
resp->get_src(), rpc_errs);
}
pp->set_recovered();
pp->reset_rpc_errs();
pp->reset_resp_timer();
}
Expand Down Expand Up @@ -1044,6 +1044,7 @@ void raft_server::become_leader() {

pp->set_next_log_idx(log_store_->next_slot());
enable_hb_for_peer(*pp);
pp->set_recovered();
}

// If there are uncommitted logs, search if conf log exists.
Expand Down

0 comments on commit e45952a

Please sign in to comment.