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

Monitor learner read failures #8865

Merged
merged 2 commits into from
Mar 22, 2024
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
13 changes: 13 additions & 0 deletions dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,19 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva
"Bucketed snapshot total size", \
Histogram, \
F(type_approx_raft_snapshot, {{"type", "approx_raft_snapshot"}}, ExpBuckets{1024, 2, 24})) /* 16G */ \
M(tiflash_raft_learner_read_failures_count, \
"Raft learner read failure reason counter", \
Counter, \
F(type_not_found_tiflash, {{"type", "not_found_tiflash"}}), \
F(type_epoch_not_match, {{"type", "epoch_not_match"}}), \
F(type_not_leader, {{"type", "not_leader"}}), \
F(type_not_found_tikv, {{"type", "not_found_tikv"}}), \
F(type_bucket_epoch_not_match, {{"type", "bucket_epoch_not_match"}}), \
F(type_flashback, {{"type", "flashback"}}), \
F(type_key_not_in_region, {{"type", "key_not_in_region"}}), \
F(type_tikv_server_issue, {{"type", "tikv_server_issue"}}), \
F(type_tikv_lock, {{"type", "tikv_lock"}}), \
F(type_other, {{"type", "write"}})) \
/* required by DBaaS */ \
M(tiflash_server_info, \
"Indicate the tiflash server info, and the value is the start timestamp (s).", \
Expand Down
13 changes: 13 additions & 0 deletions dbms/src/Storages/KVStore/Read/LearnerReadWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,28 @@ void LearnerReadWorker::recordReadIndexError(
{
extra_msg = fmt::format("read_index_resp error, region_id={} not found in snapshot", region_id);
}
GET_METRIC(tiflash_raft_learner_read_failures_count, type_epoch_not_match).Increment();
region_status = RegionException::RegionReadStatus::EPOCH_NOT_MATCH;
}
else if (region_error.has_not_leader())
{
GET_METRIC(tiflash_raft_learner_read_failures_count, type_not_leader).Increment();
region_status = RegionException::RegionReadStatus::NOT_LEADER;
}
else if (region_error.has_region_not_found())
{
GET_METRIC(tiflash_raft_learner_read_failures_count, type_not_found_tikv).Increment();
region_status = RegionException::RegionReadStatus::NOT_FOUND_TIKV;
}
// Below errors seldomly happens in raftstore-v1, however, we are not sure if they will happen in v2.
else if (region_error.has_flashbackinprogress() || region_error.has_flashbacknotprepared())
{
GET_METRIC(tiflash_raft_learner_read_failures_count, type_flashback).Increment();
region_status = RegionException::RegionReadStatus::FLASHBACK;
}
else if (region_error.has_bucket_version_not_match())
{
GET_METRIC(tiflash_raft_learner_read_failures_count, type_bucket_epoch_not_match).Increment();
LOG_DEBUG(
log,
"meet abnormal region error {}, [region_id={}]",
Expand All @@ -239,6 +248,7 @@ void LearnerReadWorker::recordReadIndexError(
}
else if (region_error.has_key_not_in_region())
{
GET_METRIC(tiflash_raft_learner_read_failures_count, type_key_not_in_region).Increment();
LOG_DEBUG(
log,
"meet abnormal region error {}, [region_id={}]",
Expand All @@ -251,6 +261,7 @@ void LearnerReadWorker::recordReadIndexError(
|| region_error.has_region_not_initialized() || region_error.has_disk_full()
|| region_error.has_read_index_not_ready() || region_error.has_proposal_in_merging_mode())
{
GET_METRIC(tiflash_raft_learner_read_failures_count, type_tikv_server_issue).Increment();
LOG_DEBUG(
log,
"meet abnormal region error {}, [region_id={}]",
Expand All @@ -260,6 +271,7 @@ void LearnerReadWorker::recordReadIndexError(
}
else
{
GET_METRIC(tiflash_raft_learner_read_failures_count, type_other).Increment();
LOG_DEBUG(
log,
"meet abnormal region error {}, [region_id={}]",
Expand All @@ -270,6 +282,7 @@ void LearnerReadWorker::recordReadIndexError(
}
else if (resp.has_locked())
{
GET_METRIC(tiflash_raft_learner_read_failures_count, type_tikv_lock).Increment();
unavailable_regions.addRegionLock(region_id, LockInfoPtr(resp.release_locked()));
}
else
Expand Down
Loading