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

Why the leader host is empty in response from candidate meta server #5158

Closed
Nicole00 opened this issue Dec 29, 2022 · 2 comments
Closed

Why the leader host is empty in response from candidate meta server #5158

Nicole00 opened this issue Dec 29, 2022 · 2 comments

Comments

@Nicole00
Copy link
Contributor

General Question

For meta client, it will retry the request when happen leader change error. When retrying, it will obtain the leader information from the response returned by the current server, and to update the connection between the client and the server to resend the request.
But when current server connected by client is CANDIDATE, the leader host in response is Empty. Why? is it by design or a bug.

@Nicole00
Copy link
Contributor Author

related code:

bool RaftPart::needToStartElection() {
std::lock_guard<std::mutex> g(raftLock_);
if (status_ == Status::RUNNING && role_ == Role::FOLLOWER &&
(lastMsgRecvDur_.elapsedInMSec() >= FLAGS_raft_heartbeat_interval_secs * 1000 ||
isBlindFollower_)) {
LOG(INFO) << idStr_ << "Start leader election, reason: lastMsgDur "
<< lastMsgRecvDur_.elapsedInMSec() << ", term " << term_;
role_ = Role::CANDIDATE;
leader_ = HostAddr("", 0);
}
return role_ == Role::CANDIDATE;
}

@HarrisChu
Copy link
Contributor

it is by design, when timeout, should start leader election, and the leader is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants