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

Modify some log level. #1351

Merged
merged 5 commits into from
Dec 3, 2019
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 src/kvstore/Part.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ std::pair<LogID, TermID> Part::lastCommittedLogId() {
std::string val;
ResultCode res = engine_->get(NebulaKeyUtils::systemCommitKey(partId_), &val);
if (res != ResultCode::SUCCEEDED) {
LOG(ERROR) << "Cannot fetch the last committed log id from the storage engine";
LOG(INFO) << idStr_ << "Cannot fetch the last committed log id from the storage engine";
return std::make_pair(0, 0);
}
CHECK_EQ(val.size(), sizeof(LogID) + sizeof(TermID));
Expand Down
3 changes: 2 additions & 1 deletion src/kvstore/raftex/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ Host::prepareAppendLogRequest() {
self->sendingSnapshot_ = false;
});
} else {
LOG(INFO) << idStr_ << "The snapshot req is in queue, please wait for a moment";
PLOG_EVERY_N(INFO, 30) << idStr_
<< "The snapshot req is in queue, please wait for a moment";
}
}

Expand Down
16 changes: 6 additions & 10 deletions src/kvstore/raftex/RaftPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ AppendLogResult RaftPart::canAppendLogs() {
return AppendLogResult::E_STOPPED;
}
if (role_ != Role::LEADER) {
LOG(ERROR) << idStr_ << "The partition is not a leader";
PLOG_EVERY_N(ERROR, 100) << idStr_ << "The partition is not a leader";
return AppendLogResult::E_NOT_A_LEADER;
}

Expand Down Expand Up @@ -613,8 +613,8 @@ folly::Future<AppendLogResult> RaftPart::appendLogAsync(ClusterID source,
}

if (!checkAppendLogResult(res)) {
LOG(ERROR) << idStr_
<< "Cannot append logs, clean the buffer";
// Mosy likely failed because the parttion is not leader
PLOG_EVERY_N(ERROR, 100) << idStr_ << "Cannot append logs, clean the buffer";
critical27 marked this conversation as resolved.
Show resolved Hide resolved
return res;
}
// Replicate buffered logs to all followers
Expand Down Expand Up @@ -952,16 +952,13 @@ bool RaftPart::needToStartElection() {
std::lock_guard<std::mutex> g(raftLock_);
if (status_ == Status::RUNNING &&
role_ == Role::FOLLOWER &&
(lastMsgRecvDur_.elapsedInSec() >= weight_ * FLAGS_raft_heartbeat_interval_secs ||
(lastMsgRecvDur_.elapsedInMSec() >= weight_ * FLAGS_raft_heartbeat_interval_secs * 1000 ||
critical27 marked this conversation as resolved.
Show resolved Hide resolved
term_ == 0)) {
LOG(INFO) << idStr_ << "Start leader election, reason: lastMsgDur "
<< lastMsgRecvDur_.elapsedInSec()
<< lastMsgRecvDur_.elapsedInMSec()
<< ", term " << term_;
role_ = Role::CANDIDATE;
leader_ = HostAddr(0, 0);
LOG(INFO) << idStr_
<< "needToStartElection: lastMsgRecvDur " << lastMsgRecvDur_.elapsedInSec()
<< ", term_ " << term_;
}

return role_ == Role::CANDIDATE;
Expand Down Expand Up @@ -1083,7 +1080,7 @@ bool RaftPart::leaderElection() {
// Result evaluator
[hosts, this](size_t idx, cpp2::AskForVoteResponse& resp) {
if (resp.get_error_code() == cpp2::ErrorCode::E_LOG_STALE) {
LOG(INFO) << idStr_ << "My last log id is less than " << hosts[idx]
LOG(INFO) << idStr_ << "My last log id is less than " << hosts[idx]->address()
<< ", double my election interval.";
uint64_t curWeight = weight_.load();
weight_.store(curWeight * 2);
Expand Down Expand Up @@ -1148,7 +1145,6 @@ bool RaftPart::leaderElection() {
void RaftPart::statusPolling() {
size_t delay = FLAGS_raft_heartbeat_interval_secs * 1000 / 3;
if (needToStartElection()) {
LOG(INFO) << idStr_ << "Need to start leader election";
if (leaderElection()) {
VLOG(2) << idStr_ << "Stop the election";
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/kvstore/raftex/RaftexService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ std::shared_ptr<RaftPart> RaftexService::findPart(
auto it = parts_.find(std::make_pair(spaceId, partId));
if (it == parts_.end()) {
// Part not found
LOG(ERROR) << "Cannot find the part " << partId
<< " in the graph space " << spaceId;
LOG(WARNING) << "Cannot find the part " << partId
<< " in the graph space " << spaceId;
return std::shared_ptr<RaftPart>();
}

Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/raftex/test/RaftexTestBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void waitUntilLeaderElected(
});

// Sleep some time to wait until resp of heartbeat has come back when elected as leader
usleep(30000);
usleep(50000);

bool sameLeader = true;
int32_t index = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/kvstore/wal/FileBasedWal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ FileBasedWal::FileBasedWal(const folly::StringPiece dir,
lastLogId_ = info->lastId();
lastLogTerm_ = info->lastTerm();
LOG(INFO) << idStr_ << "lastLogId in wal is " << lastLogId_
<< ", lastLogTerm is " << lastLogTerm_;
<< ", lastLogTerm is " << lastLogTerm_
<< ", path is " << info->path();
currFd_ = open(info->path(), O_WRONLY | O_APPEND);
currInfo_ = info;
CHECK_GE(currFd_, 0);
Expand Down Expand Up @@ -456,7 +457,6 @@ void FileBasedWal::scanLastWal(WalFileInfoPtr info, LogID firstId) {

++curLogId;
}
LOG(INFO) << idStr_ << "Scan last wal " << path << ", last wal id is " << id;

if (0 < pos && pos < FileUtils::fileSize(path)) {
LOG(WARNING) << "Invalid wal " << path << ", truncate from offset " << pos;
Expand Down
12 changes: 6 additions & 6 deletions src/meta/client/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ bool MetaClient::loadData() {
}
diff(oldCache, localCache_);
ready_ = true;
LOG(INFO) << "Load data completed!";
critical27 marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

void MetaClient::addLoadDataTask() {
size_t delayMS = FLAGS_load_data_interval_secs * 1000 + folly::Random::rand32(900);
bgThread_->addDelayTask(delayMS, &MetaClient::loadDataThreadFunc, this);
LOG(INFO) << "Load data completed, call after " << delayMS << " ms";
}


Expand Down Expand Up @@ -315,9 +315,9 @@ void MetaClient::getResponse(Request req,
respGen = std::move(respGen), pro = std::move(pro),
toLeader, retry, retryLimit, duration, this] () mutable {
auto client = clientsMan_->client(host, evb);
LOG(INFO) << "Send request to meta " << host;
VLOG(1) << "Send request to meta " << host;
remoteFunc(client, req).via(evb)
.then([req = std::move(req), remoteFunc = std::move(remoteFunc),
.then([host, req = std::move(req), remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen), pro = std::move(pro), toLeader, retry,
retryLimit, evb, duration, this] (folly::Try<RpcResponse>&& t) mutable {
// exception occurred during RPC
Expand All @@ -341,7 +341,7 @@ void MetaClient::getResponse(Request req,
}, FLAGS_meta_client_retry_interval_secs * 1000);
return;
} else {
LOG(INFO) << "Exceed retry limit";
LOG(ERROR) << "Send request to " << host << ", exceed retry limit";
pro.setValue(Status::Error(folly::stringPrintf("RPC failure in MetaClient: %s",
t.exception().what().c_str())));
stats::Stats::addStatsValue(stats_, false, duration.elapsedInUSec());
Expand Down Expand Up @@ -1157,7 +1157,7 @@ folly::Future<StatusOr<bool>> MetaClient::heartbeat() {
req.set_cluster_id(clusterId_.load());
folly::Promise<StatusOr<bool>> promise;
auto future = promise.getFuture();
LOG(INFO) << "Send heartbeat to " << leader_ << ", clusterId " << req.get_cluster_id();
VLOG(1) << "Send heartbeat to " << leader_ << ", clusterId " << req.get_cluster_id();
getResponse(std::move(req), [] (auto client, auto request) {
return client->future_heartBeat(request);
}, [this] (cpp2::HBResp&& resp) -> bool {
Expand Down Expand Up @@ -1396,7 +1396,7 @@ void MetaClient::loadCfg() {
}
}
} else {
LOG(INFO) << "Load configs failed: " << ret.status();
LOG(ERROR) << "Load configs failed: " << ret.status();
return;
}
}
Expand Down