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

planner,executor,infoschema: add system tables tiflash_tables and tiflash_segments (#18092) #18536

Merged
merged 10 commits into from
Jul 15, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #18092 to release-4.0


What problem does this PR solve?

we can read tiflash storage stat from tidb for the ease of debug.

What is changed and how it works?

What's Changed: add two new system tables tiflash_tables and tiflash_segments.

How it Works: it uses etcd client to get http port of tiflash nodes, and then get data from corresponding tiflash system tables through the http port.

mysql> select tidb_table,table_id,segment_count,tiflash_instance from tiflash_tables where tidb_database = 'test';
+------------+----------+---------------+------------------+
| tidb_table | table_id | segment_count | tiflash_instance |
+------------+----------+---------------+------------------+
| t          |       45 |             1 | 127.0.0.1:9500   |
| t2         |       47 |             1 | 127.0.0.1:9500   |
+------------+----------+---------------+------------------+
2 rows in set (0.01 sec)

mysql> select count(*) from tiflash_tables;
+----------+
| count(*) |
+----------+
|       22 |
+----------+
1 row in set (0.02 sec)

mysql> select tidb_table,table_id from tiflash_tables where tiflash_instance='127.0.0.1:9500' limit 5;
+------------------+----------+
| tidb_table       | table_id |
+------------------+----------+
| t                |       45 |
| t2               |       47 |
| tables_priv      |       11 |
| columns_priv     |       13 |
| global_variables |       15 |
+------------------+----------+
5 rows in set (0.02 sec)

mysql> select `tidb_table`,`segment_id`,`range`,`rows` from tiflash_segments where tidb_database='test';
+------------+------------+--------------------------------------------+------+
| tidb_table | segment_id | range                                      | rows |
+------------+------------+--------------------------------------------+------+
| t          |          1 | [-9223372036854775808,9223372036854775807) |    0 |
| t2         |          1 | [-9223372036854775808,9223372036854775807) |    0 |
+------------+------------+--------------------------------------------+------+
2 rows in set (0.01 sec)

mysql> select count(*) from tiflash_segments;
+----------+
| count(*) |
+----------+
|       22 |
+----------+
1 row in set (0.01 sec)

mysql> select `tidb_table`,`segment_id`,`range`,`rows` from tiflash_segments where tiflash_instance='127.0.0.1:9500' limit 5;
+------------------+------------+--------------------------------------------+------+
| tidb_table       | segment_id | range                                      | rows |
+------------------+------------+--------------------------------------------+------+
| t                |          1 | [-9223372036854775808,9223372036854775807) |   64 |
| t2               |          1 | [-9223372036854775808,9223372036854775807) |    0 |
| tables_priv      |          1 | [-9223372036854775808,9223372036854775807) |    0 |
| columns_priv     |          1 | [-9223372036854775808,9223372036854775807) |    0 |
| global_variables |          1 | [-9223372036854775808,9223372036854775807) |    0 |
+------------------+------------+--------------------------------------------+------+
5 rows in set (0.01 sec)

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Manual test: create a tidb cluster with three tiflash nodes, create 100000 tables in tidb,and then select from the two new added system tables to see whether the results meet expectation.

Release note

  • Add system tables tiflash_tables and tiflash_segments

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@lidezhu please accept the invitation then you can push to the cherry-pick pull requests.
https://github.com/ti-srebot/tidb/invitations

@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

/run-all-tests

@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

/run-all-tests

@lidezhu lidezhu removed their assignment Jul 14, 2020
Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 14, 2020
@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

/run-all-tests

3 similar comments
@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

/run-all-tests

@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

/run-all-tests

@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

/run-all-tests

@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

/run-all-tests

@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

/run-all-tests

@lidezhu
Copy link
Contributor

lidezhu commented Jul 14, 2020

@crazycs520 PTAL

tangenta
tangenta previously approved these changes Jul 14, 2020
Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Jul 14, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Jul 14, 2020
Signed-off-by: crazycs520 <crazycs520@gmail.com>
@crazycs520
Copy link
Contributor

/run-all-tests

@zimulala zimulala added the status/can-merge Indicates a PR has been approved by a committer. label Jul 15, 2020
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot added status/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Jul 15, 2020
@zimulala zimulala merged commit 667c4df into pingcap:release-4.0 Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. status/LGT3 The PR has already had 3 LGTM. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants