Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix get peer info of removed member #108

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class NuRaftMesgConan(ConanFile):
name = "nuraft_mesg"
version = "3.6.3"
version = "3.6.4"

homepage = "https://github.com/eBay/nuraft_mesg"
description = "A gRPC service for NuRAFT"
Expand Down
18 changes: 12 additions & 6 deletions src/lib/repl_service_ctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,22 @@ std::vector< peer_info > repl_service_ctx::get_raft_status() const {
LOGW("do not find peer id {} in the conifg of leader", pinfo.id_);
continue;
}
peers.emplace_back(peer_info{std::string(peer_id), pinfo.last_log_idx_, pinfo.last_succ_resp_us_});

peers.emplace_back(std::string(peer_id), pinfo.last_log_idx_, pinfo.last_succ_resp_us_);
}
}

auto my_id = _server->get_id();
auto my_peer_id = _server->get_srv_config(my_id)->get_endpoint();
auto my_config = _server->get_srv_config(_server->get_id());

// if I am the removed memeber, I can not find myself in the configuration. this will happen when a removed member
// tries to get the raft status
if (my_config) {
auto my_peer_id = my_config->get_endpoint();

// add the peer info of itself(leader or follower) , which is useful for upper layer
// from the view a node itself, last_succ_resp_us_ make no sense, so set it to 0
peers.emplace_back(my_peer_id, _server->get_last_log_idx(), 0);
// add the peer info of itself(leader or follower) , which is useful for upper layer
// from the view of a node itself, last_succ_resp_us_ make no sense, so set it to 0
peers.emplace_back(my_peer_id, _server->get_last_log_idx(), 0);
}

return peers;
}
Expand Down
Loading