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

add more specific error type in ErrorHeaderKind #14809

Merged
merged 2 commits into from
May 25, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/server/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,13 @@ make_auto_flush_static_metric! {
err_store_not_match,
err_raft_entry_too_large,
err_leader_memory_lock_check,
err_read_index_not_ready,
err_proposal_in_merging_mode,
err_data_is_not_ready,
err_region_not_initialized,
err_disk_full,
err_recovery_in_progress,
err_flashback_in_progress,
}

pub label_enum RequestTypeKind {
Expand Down Expand Up @@ -497,6 +504,13 @@ impl From<ErrorHeaderKind> for RequestStatusKind {
ErrorHeaderKind::StaleCommand => RequestStatusKind::err_stale_command,
ErrorHeaderKind::StoreNotMatch => RequestStatusKind::err_store_not_match,
ErrorHeaderKind::RaftEntryTooLarge => RequestStatusKind::err_raft_entry_too_large,
ErrorHeaderKind::ReadIndexNotReady => RequestStatusKind::err_read_index_not_ready,
ErrorHeaderKind::ProposalInMergeMode => RequestStatusKind::err_proposal_in_merging_mode,
ErrorHeaderKind::DataNotReady => RequestStatusKind::err_data_is_not_ready,
ErrorHeaderKind::RegionNotInitialized => RequestStatusKind::err_region_not_found,
ErrorHeaderKind::DiskFull => RequestStatusKind::err_disk_full,
ErrorHeaderKind::RecoveryInProgress => RequestStatusKind::err_recovery_in_progress,
ErrorHeaderKind::FlashbackInProgress => RequestStatusKind::err_flashback_in_progress,
ErrorHeaderKind::Other => RequestStatusKind::err_other,
}
}
Expand Down
28 changes: 28 additions & 0 deletions src/storage/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ pub enum ErrorHeaderKind {
StaleCommand,
StoreNotMatch,
RaftEntryTooLarge,
ReadIndexNotReady,
ProposalInMergeMode,
DataNotReady,
RegionNotInitialized,
DiskFull,
RecoveryInProgress,
FlashbackInProgress,
Other,
}

Expand All @@ -193,6 +200,13 @@ impl ErrorHeaderKind {
ErrorHeaderKind::StaleCommand => "stale_command",
ErrorHeaderKind::StoreNotMatch => "store_not_match",
ErrorHeaderKind::RaftEntryTooLarge => "raft_entry_too_large",
ErrorHeaderKind::ReadIndexNotReady => "read_index_not_ready",
ErrorHeaderKind::ProposalInMergeMode => "proposal_in_merge_mode",
ErrorHeaderKind::DataNotReady => "data_not_ready",
ErrorHeaderKind::RegionNotInitialized => "region_not_initialized",
ErrorHeaderKind::DiskFull => "disk_full",
ErrorHeaderKind::RecoveryInProgress => "recovery_in_progress",
ErrorHeaderKind::FlashbackInProgress => "flashback_in_progress",
ErrorHeaderKind::Other => "other",
}
}
Expand Down Expand Up @@ -227,6 +241,20 @@ pub fn get_error_kind_from_header(header: &errorpb::Error) -> ErrorHeaderKind {
ErrorHeaderKind::StoreNotMatch
} else if header.has_raft_entry_too_large() {
ErrorHeaderKind::RaftEntryTooLarge
} else if header.has_read_index_not_ready() {
ErrorHeaderKind::ReadIndexNotReady
} else if header.has_proposal_in_merging_mode() {
ErrorHeaderKind::ProposalInMergeMode
} else if header.has_data_is_not_ready() {
ErrorHeaderKind::DataNotReady
} else if header.has_region_not_initialized() {
ErrorHeaderKind::RegionNotInitialized
} else if header.has_disk_full() {
ErrorHeaderKind::DiskFull
} else if header.has_recovery_in_progress() {
ErrorHeaderKind::RecoveryInProgress
} else if header.has_flashback_in_progress() {
ErrorHeaderKind::FlashbackInProgress
} else {
ErrorHeaderKind::Other
}
Expand Down