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

skip heartbeat when role in meta client is not set #3855

Merged
merged 1 commit into from
Feb 8, 2022
Merged
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
skip heartbeat when role in meta client is not set
critical27 committed Feb 7, 2022
commit bbd1b92fd0609d7dce0799f07e2696f40e2fbd3f
22 changes: 13 additions & 9 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
@@ -94,15 +94,19 @@ MetaClient::~MetaClient() {
}

bool MetaClient::isMetadReady() {
auto ret = heartbeat().get();
if (!ret.ok()) {
LOG(ERROR) << "Heartbeat failed, status:" << ret.status();
return ready_;
} else if (options_.role_ == cpp2::HostRole::STORAGE &&
metaServerVersion_ != EXPECT_META_VERSION) {
LOG(ERROR) << "Expect meta version is " << EXPECT_META_VERSION << ", but actual is "
<< metaServerVersion_;
return ready_;
// UNKNOWN is reserved for tools such as upgrader, in that case the ip/port is not set. We do
// not send heartbeat to meta to avoid writing error host info (e.g. Host("", 0))
if (options_.role_ != cpp2::HostRole::UNKNOWN) {
auto ret = heartbeat().get();
if (!ret.ok()) {
LOG(ERROR) << "Heartbeat failed, status:" << ret.status();
return ready_;
} else if (options_.role_ == cpp2::HostRole::STORAGE &&
metaServerVersion_ != EXPECT_META_VERSION) {
LOG(ERROR) << "Expect meta version is " << EXPECT_META_VERSION << ", but actual is "
<< metaServerVersion_;
return ready_;
}
}

// ready_ will be set in loadData
6 changes: 2 additions & 4 deletions src/clients/meta/MetaClient.h
Original file line number Diff line number Diff line change
@@ -185,7 +185,6 @@ struct MetaClientOptions {
MetaClientOptions(const MetaClientOptions& opt)
: localHost_(opt.localHost_),
clusterId_(opt.clusterId_.load()),
inStoraged_(opt.inStoraged_),
serviceName_(opt.serviceName_),
skipConfig_(opt.skipConfig_),
role_(opt.role_),
@@ -197,13 +196,12 @@ struct MetaClientOptions {
HostAddr localHost_{"", 0};
// Current cluster Id, it is required by storaged only.
std::atomic<ClusterID> clusterId_{0};
// If current client being used in storaged.
bool inStoraged_ = false;
// Current service name, used in StatsManager
std::string serviceName_ = "";
// Whether to skip the config manager
bool skipConfig_ = false;
// Host role(graph/meta/storage) using this client
// Host role(graph/meta/storage) using this client, and UNKNOWN role will not send heartbeat, used
// for tools such as upgrader
cpp2::HostRole role_ = cpp2::HostRole::UNKNOWN;
// gitInfoSHA of Host using this client
std::string gitInfoSHA_{""};