-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 issue 4274 #4627
fix issue 4274 #4627
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -876,7 +876,8 @@ void RaftPart::appendLogsInternal(AppendLogsIterator iter, TermID termId) { | |
committed = committedLogId_; | ||
// Step 1: Write WAL | ||
{ | ||
SCOPED_TIMER(&execTime_); | ||
SCOPED_TIMER( | ||
[](uint64_t execTime) { stats::StatsManager::addValue(kAppendWalLatencyUs, execTime); }); | ||
if (!wal_->appendLogs(iter)) { | ||
VLOG_EVERY_N(2, 1000) << idStr_ << "Failed to write into WAL"; | ||
res = nebula::cpp2::ErrorCode::E_RAFT_WAL_FAIL; | ||
|
@@ -885,7 +886,6 @@ void RaftPart::appendLogsInternal(AppendLogsIterator iter, TermID termId) { | |
break; | ||
} | ||
} | ||
stats::StatsManager::addValue(kAppendWalLatencyUs, execTime_); | ||
lastId = wal_->lastLogId(); | ||
VLOG(4) << idStr_ << "Succeeded writing logs [" << iter.firstLogId() << ", " << lastId | ||
<< "] to WAL"; | ||
|
@@ -1063,7 +1063,6 @@ void RaftPart::processAppendLogResponses(const AppendLogResponses& resps, | |
*/ | ||
auto [code, lastCommitId, lastCommitTerm] = commitLogs(std::move(walIt), true, true); | ||
if (code == nebula::cpp2::ErrorCode::SUCCEEDED) { | ||
stats::StatsManager::addValue(kCommitLogLatencyUs, execTime_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two places that will call commitlogs, so if you only add it to the place you said, then the commit latency will record less data. If you add it to both places, then the meaning of this metric will be unclear There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about add it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this PR, it is modified in this way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 my bad... |
||
std::lock_guard<std::mutex> g(raftLock_); | ||
CHECK_EQ(lastLogId, lastCommitId); | ||
committedLogId_ = lastCommitId; | ||
|
@@ -1744,10 +1743,11 @@ void RaftPart::processAppendLogRequest(const cpp2::AppendLogRequest& req, | |
if (hasLogsToAppend) { | ||
bool result = false; | ||
{ | ||
SCOPED_TIMER(&execTime_); | ||
SCOPED_TIMER([](uint64_t execTime) { | ||
stats::StatsManager::addValue(kAppendWalLatencyUs, execTime); | ||
}); | ||
result = wal_->appendLogs(logIter); | ||
} | ||
stats::StatsManager::addValue(kAppendWalLatencyUs, execTime_); | ||
if (result) { | ||
CHECK_EQ(lastId, wal_->lastLogId()); | ||
lastLogId_ = wal_->lastLogId(); | ||
|
@@ -1776,7 +1776,6 @@ void RaftPart::processAppendLogRequest(const cpp2::AppendLogRequest& req, | |
// raftLock_ has been acquired, so the third parameter is false as well. | ||
auto [code, lastCommitId, lastCommitTerm] = commitLogs(std::move(walIt), false, false); | ||
if (code == nebula::cpp2::ErrorCode::SUCCEEDED) { | ||
stats::StatsManager::addValue(kCommitLogLatencyUs, execTime_); | ||
VLOG(4) << idStr_ << "Follower succeeded committing log " << committedLogId_ + 1 << " to " | ||
<< lastLogIdCanCommit; | ||
CHECK_EQ(lastLogIdCanCommit, lastCommitId); | ||
|
@@ -1993,7 +1992,6 @@ void RaftPart::processSendSnapshotRequest(const cpp2::SendSnapshotRequest& req, | |
resp.error_code_ref() = nebula::cpp2::ErrorCode::E_RAFT_PERSIST_SNAPSHOT_FAILED; | ||
return; | ||
} | ||
stats::StatsManager::addValue(kCommitSnapshotLatencyUs, execTime_); | ||
lastTotalCount_ += std::get<1>(ret); | ||
lastTotalSize_ += std::get<2>(ret); | ||
if (lastTotalCount_ != req.get_total_count() || lastTotalSize_ != req.get_total_size()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good