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 metrics for key exceed bound #4255

Merged
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

add metrics for key exceed bound

Signed-off-by: zhangjinpeng1987 <zhangjinpeng@pingcap.com>
  • Loading branch information...
zhangjinpeng1987 committed Feb 22, 2019
commit c262d9bc8c9d81e6842729c9b24982ff7e957df2
@@ -221,4 +221,10 @@ lazy_static! {
&["type"],
exponential_buckets(0.001, 1.59, 20).unwrap() // max 10s
).unwrap();

pub static ref KEY_NOT_IN_REGION: IntCounter = register_int_counter!(

This comment has been minimized.

Copy link
@siddontang

siddontang Feb 23, 2019

Contributor

do we need to add a label so we can locate where it raises?

This comment has been minimized.

Copy link
@breeswish

breeswish Feb 23, 2019

Member

Maybe not a good idea. Constant labels are preferred. Dynamic labels are likely to cause memory never being released because these metric instance need to be kept permanently.

"tikv_key_not_in_region",
"Counter of key not in region"
)
.unwrap();
}
@@ -21,6 +21,8 @@ use crate::raftstore::store::{keys, util, PeerStorage};
use crate::raftstore::Result;
use crate::util::set_panic_mark;

use super::metrics::*;

/// Snapshot of a region.
///
/// Only data within a region can be accessed.
@@ -316,6 +318,7 @@ impl RegionIterator {
#[inline]
pub fn should_seekable(&self, key: &[u8]) -> Result<()> {
if let Err(e) = util::check_key_in_region_inclusive(key, &self.region) {
KEY_NOT_IN_REGION.inc();
if self.panic_when_exceed_bound {
set_panic_mark();
panic!("key exceed bound: {:?}", e);
@@ -142,4 +142,9 @@ lazy_static! {
&["state"]
)
.unwrap();
pub static ref REQUEST_EXCEED_BOUND: IntCounter = register_int_counter!(
"tikv_request_exceed_bound",
"Counter of request exceed bound"
)
.unwrap();
}
@@ -13,6 +13,7 @@

use kvproto::kvrpcpb::IsolationLevel;

use crate::storage::metrics::*;
use crate::storage::mvcc::{
BackwardScanner, BackwardScannerBuilder, ForwardScanner, ForwardScannerBuilder,
};
@@ -159,6 +160,7 @@ impl<S: Snapshot> SnapshotStore<S> {
if let Some(ref l) = lower_bound {
if let Some(b) = self.snapshot.lower_bound() {
if !b.is_empty() && l.as_encoded().as_slice() < b {
REQUEST_EXCEED_BOUND.inc();
return Err(Error::InvalidReqRange {
start: Some(l.as_encoded().clone()),
end: upper_bound.as_ref().map(|ref b| b.as_encoded().clone()),
@@ -171,6 +173,7 @@ impl<S: Snapshot> SnapshotStore<S> {
if let Some(ref u) = upper_bound {
if let Some(b) = self.snapshot.upper_bound() {
if !b.is_empty() && (u.as_encoded().as_slice() > b || u.as_encoded().is_empty()) {
REQUEST_EXCEED_BOUND.inc();
return Err(Error::InvalidReqRange {
start: lower_bound.as_ref().map(|ref b| b.as_encoded().clone()),
end: Some(u.as_encoded().clone()),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.