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

store/helper: fill data in the information.tidb_hot_table for partitioned table (#14331) #16726

Merged
merged 1 commit into from
Apr 22, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Apr 22, 2020

cherry-pick #14331 to release-3.0


What problem does this PR solve?

INFORMATION.TIDB_HOT_TABLE should take the partitioned table into consideration.

What is changed and how it works?

A partitioned table is not handled properly in tidb_hot_table.
After this change, we can get the correct information:

mysql> select * from tidb_hot_regions;
+----------+----------+---------+------------------+------------+-----------+-------+----------------+--------------+------------+
| TABLE_ID | INDEX_ID | DB_NAME | TABLE_NAME       | INDEX_NAME | REGION_ID | TYPE  | MAX_HOT_DEGREE | REGION_COUNT | FLOW_BYTES |
+----------+----------+---------+------------------+------------+-----------+-------+----------------+--------------+------------+
|       23 |     NULL | mysql   | stats_histograms | NULL       |        48 | read  |              3 |            0 |     211478 |
|       25 |     NULL | mysql   | stats_buckets    | NULL       |        52 | write |              3 |            0 |      93013 |
|      151 |     NULL | test    | sbtest3(p1)      | NULL       |      1156 | write |              3 |            0 |      93013 |
|      150 |     NULL | test    | sbtest3(p0)      | NULL       |      1152 | write |              3 |            0 |      93013 |
+----------+----------+---------+------------------+------------+-----------+-------+----------------+--------------+------------+
4 rows in set (0.08 sec)

Note, 151 and 150 are both belong to sbtest3, and the table name column is displayed as sbtest3(p1) and sbtest3(p0) to indicate they are partitions.

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Mock the data is hard, the old code is not really unit tested.
I use a real tikv cluster and check the result.
B.T.W, a bug is fixed, pd returns something like this:

{
  "as_peer": {
    "1": {
      "total_flow_bytes": 190434.14973961416,
      "regions_count": 3,
      "statistics": [
        {
          "store_id": 1,
          "region_id": 1156,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 50956.69507956832,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:54.147084771+08:00",
          "Version": 127
        },
        {
          "store_id": 1,
          "region_id": 1152,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 93013.72966004584,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:51.146018185+08:00",
          "Version": 126
        },
        {
          "store_id": 1,
          "region_id": 52,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 46463.725,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:48.507062772+08:00",
          "Version": 13
        }
      ]
    },
    "4": {
      "total_flow_bytes": 190434.14973961416,
      "regions_count": 3,
      "statistics": [
        {
          "store_id": 4,
          "region_id": 1156,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 50956.69507956832,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:54.147078479+08:00",
          "Version": 127
        },
        {
          "store_id": 4,
          "region_id": 1152,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 93013.72966004584,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:51.146019774+08:00",
          "Version": 126
        },
        {
          "store_id": 4,
          "region_id": 52,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 46463.725,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:48.507064672+08:00",
          "Version": 13
        }
      ]
    },
    "5": {
      "total_flow_bytes": 190434.14973961416,
      "regions_count": 3,
      "statistics": [
        {
          "store_id": 5,
          "region_id": 1156,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 50956.69507956832,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:54.147083702+08:00",
          "Version": 127
        },
        {
          "store_id": 5,
          "region_id": 1152,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 93013.72966004584,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:51.146020767+08:00",
          "Version": 126
        },
        {
          "store_id": 5,
          "region_id": 52,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 46463.725,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:48.507065709+08:00",
          "Version": 13
        }
      ]
    }
  },
  "as_leader": {
    "1": {
      "total_flow_bytes": 0,
      "regions_count": 0,
      "statistics": []
    },
    "4": {
      "total_flow_bytes": 143970.42473961416,
      "regions_count": 2,
      "statistics": [
        {
          "store_id": 4,
          "region_id": 1156,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 50956.69507956832,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:54.147078479+08:00",
          "Version": 127
        },
        {
          "store_id": 4,
          "region_id": 1152,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 93013.72966004584,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:51.146019774+08:00",
          "Version": 126
        }
      ]
    },
    "5": {
      "total_flow_bytes": 46463.725,
      "regions_count": 1,
      "statistics": [
        {
          "store_id": 5,
          "region_id": 52,
          "hot_degree": 3,
          "AntiCount": 1,
          "kind": 0,
          "flow_bytes": 46463.725,
          "flow_keys": 0,
          "RollingBytesRate": null,
          "last_update_time": "2020-01-03T16:10:48.507065709+08:00",
          "Version": 13
        }
      ]
    }
  }
}

From the PD result we can see flow_bytes is a float, not uint. @disksing @nolouch

"flow_bytes": 50956.69507956832

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Write release note for bug-fix or new feature.

@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 22, 2020

/run-all-tests

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason merged commit c015874 into pingcap:release-3.0 Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants