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

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


Just for now


add metrics for key exceed bound

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

pub static ref KEY_NOT_IN_REGION: IntCounter = register_int_counter!(

This comment has been minimized.

Copy link

siddontang Feb 23, 2019


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

This comment has been minimized.

Copy link

breeswish Feb 23, 2019


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.

"Counter of key not in region"
@@ -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 {
pub fn should_seekable(&self, key: &[u8]) -> Result<()> {
if let Err(e) = util::check_key_in_region_inclusive(key, &self.region) {;
if self.panic_when_exceed_bound {
panic!("key exceed bound: {:?}", e);
@@ -142,4 +142,9 @@ lazy_static! {
pub static ref REQUEST_EXCEED_BOUND: IntCounter = register_int_counter!(
"Counter of request exceed bound"
@@ -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 {;
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()) {;
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.