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

tikv_region_status info of partition table index is not right #38742

Closed
jiyfhust opened this issue Oct 29, 2022 · 1 comment · Fixed by #38743
Closed

tikv_region_status info of partition table index is not right #38742

jiyfhust opened this issue Oct 29, 2022 · 1 comment · Fixed by #38743
Assignees
Labels
severity/moderate sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@jiyfhust
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. mysql> create table test_t1 (a int, b int) partition by range (b) (partition p0 values less than (10), partition p1 values less than (maxvalue));
  2. mysql> alter table test_t1 add index p_a (a);
  3. mysql> select * from information_schema.tikv_region_status where TABLE_NAME = 'test_t1'\G

Create a partitioned table with 2 partitions. every partition is a physical table.
Then create a index,the index is a local index(not global) of the partition.
use tableId、p0_id、p1_id as the physical table id of table test_t1、p0、p1.

partition p0 index key-value, the table id part of index key prefix should include p0_id, not tableId.

for _, index := range table.Indices {

function GetTablesInfoWithKeyRange get error index key range.

the index range of partition table is wrong.

2. What did you expect to see? (Required)

mysql> create table test_t1 (a int, b int) partition by range (b) (partition p0 values less than (10), partition p1 values less than (maxvalue));
Query OK, 0 rows affected (0.12 sec)
mysql> show create table test_t1\G
*************************** 1. row ***************************
Table: test_t1
Create Table: CREATE TABLE test_t1 (
a int(11) DEFAULT NULL,
b int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (b)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN (MAXVALUE))
1 row in set (0.00 sec)
mysql> alter table test_t1 add index p_a (a);
Query OK, 0 rows affected (2.89 sec)
mysql> select * from information_schema.tikv_region_status where TABLE_NAME = 'test_t1'\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: 7480000000000000FFBF00000000000000F8
END_KEY:
TABLE_ID: 189
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 1
INDEX_ID: 1
INDEX_NAME: p_a
EPOCH_CONF_VER: 1
EPOCH_VERSION: 79
WRITTEN_BYTES: 0
READ_BYTES: 4020450
APPROXIMATE_SIZE: 2
APPROXIMATE_KEYS: 7297
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 2. row ***************************
REGION_ID: 2
START_KEY: 7480000000000000FFBF00000000000000F8
END_KEY:
TABLE_ID: 189
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 0
INDEX_ID: NULL
INDEX_NAME: NULL
EPOCH_CONF_VER: 1
EPOCH_VERSION: 79
WRITTEN_BYTES: 0
READ_BYTES: 4020450
APPROXIMATE_SIZE: 2
APPROXIMATE_KEYS: 7297
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 3. row ***************************
REGION_ID: 5019
START_KEY: 7480000000000000FFBE00000000000000F8
END_KEY: 7480000000000000FFBF00000000000000F8
TABLE_ID: 189
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 1
INDEX_ID: 1
INDEX_NAME: p_a
EPOCH_CONF_VER: 1
EPOCH_VERSION: 79
WRITTEN_BYTES: 39
READ_BYTES: 0
APPROXIMATE_SIZE: 1
APPROXIMATE_KEYS: 0
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 4. row ***************************
REGION_ID: 5019
START_KEY: 7480000000000000FFBE00000000000000F8
END_KEY: 7480000000000000FFBF00000000000000F8
TABLE_ID: 189
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 0
INDEX_ID: NULL
INDEX_NAME: NULL
EPOCH_CONF_VER: 1
EPOCH_VERSION: 79
WRITTEN_BYTES: 39
READ_BYTES: 0
APPROXIMATE_SIZE: 1
APPROXIMATE_KEYS: 0
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
4 rows in set (0.01 sec)

3. What did you see instead (Required)

mysql> create table test_t1 (a int, b int) partition by range (b) (partition p0 values less than (10), partition p1 values less than (maxvalue));
Query OK, 0 rows affected (0.12 sec)
mysql> show create table test_t1\G
*************************** 1. row ***************************
Table: test_t1
Create Table: CREATE TABLE test_t1 (
a int(11) DEFAULT NULL,
b int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (b)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN (MAXVALUE))
1 row in set (0.00 sec)
mysql> alter table test_t1 add index p_a (a);
Query OK, 0 rows affected (2.85 sec)
mysql> select * from information_schema.tikv_region_status where TABLE_NAME = 'test_t1'\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: 7480000000000000FFCB00000000000000F8
END_KEY:
TABLE_ID: 201
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 0
INDEX_ID: NULL
INDEX_NAME: NULL
EPOCH_CONF_VER: 1
EPOCH_VERSION: 83
WRITTEN_BYTES: 219
READ_BYTES: 3572525
APPROXIMATE_SIZE: 2
APPROXIMATE_KEYS: 7929
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 2. row ***************************
REGION_ID: 5027
START_KEY: 7480000000000000FFCA00000000000000F8
END_KEY: 7480000000000000FFCB00000000000000F8
TABLE_ID: 201
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 0
INDEX_ID: NULL
INDEX_NAME: NULL
EPOCH_CONF_VER: 1
EPOCH_VERSION: 83
WRITTEN_BYTES: 39
READ_BYTES: 0
APPROXIMATE_SIZE: 1
APPROXIMATE_KEYS: 0
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 3. row ***************************
REGION_ID: 5025
START_KEY: 7480000000000000FFC500000000000000F8
END_KEY: 7480000000000000FFCA00000000000000F8
TABLE_ID: 201
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 1
INDEX_ID: 1
INDEX_NAME: p_a
EPOCH_CONF_VER: 1
EPOCH_VERSION: 82
WRITTEN_BYTES: 39
READ_BYTES: 0
APPROXIMATE_SIZE: 1
APPROXIMATE_KEYS: 0
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
3 rows in set (0.01 sec)

4. What is your TiDB version? (Required)

mysql> SELECT tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.5.0-alpha-2416-g6d6e9c4-dirty
Edition: Community
Git Commit Hash: 6d6e9c4
Git Branch: master
UTC Build Time: 2022-10-29 12:44:07
GoVersion: go1.19.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.07 sec)

@jiyfhust jiyfhust added the type/bug The issue is confirmed as a bug. label Oct 29, 2022
@jiyfhust
Copy link
Contributor Author

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants