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

The region statistics maybe not correct #5306

shafreeck opened this issue Aug 21, 2019 · 1 comment


Copy link

@shafreeck shafreeck commented Aug 21, 2019

Bug Report

What version of TiKV are you using?


What operating system and CPU are you using?


Steps to reproduce


What did you expect?

correct and normal region stats

What is happened?

The approximate_size is 1MB, and the approximate_keys is 2662654. It should have some mistake

  "id": 46253,
  "start_key": "7480000000000002FF3400000000000000F8",
  "end_key": "7480000000000002FF3C00000000000000F8",
  "epoch": {
    "conf_ver": 5,
    "version": 3175
  "peers": [
      "id": 46254,
      "store_id": 1
      "id": 46255,
      "store_id": 4
      "id": 46256,
      "store_id": 5
  "leader": {
    "id": 46254,
    "store_id": 1
  "written_bytes": 337,
  "approximate_size": 1,
  "approximate_keys": 2662654

This comment has been minimized.

Copy link

@AndreMouche AndreMouche commented Sep 3, 2019
in the following function

pub fn get_region_approximate_keys(db: &DB, region: &metapb::Region) -> Result<u64> {
    // try to get from RangeProperties first.
    match get_region_approximate_keys_cf(db, CF_WRITE, region) {
        Ok(v) => if v > 0 { // we should return Ok(v) directly.
            return Ok(v);
        Err(e) => debug!(
            "old_version:get keys from RangeProperties failed with err:{:?}",

    let cf = rocksdb_util::get_cf_handle(db, CF_WRITE)?;
    let start = keys::enc_start_key(region);
    let end = keys::enc_end_key(region);
    let (_, keys) = get_range_entries_and_versions(db, cf, &start, &end).unwrap_or_default();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.