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

select * from TIKV_REGION_STATUS where table_id=xx; show wrong result #37436

Closed
yilongrong opened this issue Aug 29, 2022 · 2 comments · Fixed by #37498
Closed

select * from TIKV_REGION_STATUS where table_id=xx; show wrong result #37436

yilongrong opened this issue Aug 29, 2022 · 2 comments · Fixed by #37498
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@yilongrong
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE employees (
    id INT NOT NULL,
    fname VARCHAR(30),
    lname VARCHAR(30),
    hired DATE NOT NULL DEFAULT '1970-01-01',
    separated DATE DEFAULT '9999-12-31',
    job_code INT,
    store_id INT NOT NULL
)

PARTITION BY RANGE (store_id) (
    PARTITION p0 VALUES LESS THAN (6),
    PARTITION p1 VALUES LESS THAN (11),
    PARTITION p2 VALUES LESS THAN (16),
    PARTITION p3 VALUES LESS THAN (21)
);

get employees table id is 69

select * from tables where table_name = 'employees'\G;
*************************** 1. row ***************************
             TABLE_CATALOG: def
              TABLE_SCHEMA: test
                TABLE_NAME: employees
                TABLE_TYPE: BASE TABLE
                    ENGINE: InnoDB
                   VERSION: 10
                ROW_FORMAT: Compact
                TABLE_ROWS: 0
            AVG_ROW_LENGTH: 0
               DATA_LENGTH: 0
           MAX_DATA_LENGTH: 0
              INDEX_LENGTH: 0
                 DATA_FREE: 0
            AUTO_INCREMENT: NULL
               CREATE_TIME: 2022-08-29 13:56:28
               UPDATE_TIME: NULL
                CHECK_TIME: NULL
           TABLE_COLLATION: utf8mb4_bin
                  CHECKSUM: NULL
            CREATE_OPTIONS: partitioned
             TABLE_COMMENT: 
             TIDB_TABLE_ID: 69
 TIDB_ROW_ID_SHARDING_INFO: NOT_SHARDED
              TIDB_PK_TYPE: NONCLUSTERED
TIDB_PLACEMENT_POLICY_NAME: NULL
1 row in set (0.02 sec)

select * from TIKV_REGION_STATUS where table_id=69\G

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

mysql> select * from TIKV_REGION_STATUS where table_name='employees';
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
| REGION_ID | START_KEY                            | END_KEY                              | TABLE_ID | DB_NAME | TABLE_NAME | IS_INDEX | INDEX_ID | INDEX_NAME | EPOCH_CONF_VER | EPOCH_VERSION | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE | APPROXIMATE_KEYS | REPLICATIONSTATUS_STATE | REPLICATIONSTATUS_STATEID |
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
|         2 | 7480000000000000FF4900000000000000F8 |                                      |       69 | test    | employees  |        0 |     NULL | NULL       |              5 |            37 |             0 |          0 |                1 |                0 | NULL                    |                      NULL |
|       144 | 7480000000000000FF4700000000000000F8 | 7480000000000000FF4800000000000000F8 |       69 | test    | employees  |        0 |     NULL | NULL       |              5 |            36 |            39 |          0 |                1 |                0 | NULL                    |                      NULL |
|       140 | 7480000000000000FF4600000000000000F8 | 7480000000000000FF4700000000000000F8 |       69 | test    | employees  |        0 |     NULL | NULL       |              5 |            35 |             0 |          0 |                1 |                0 | NULL                    |                      NULL |
|       148 | 7480000000000000FF4800000000000000F8 | 7480000000000000FF4900000000000000F8 |       69 | test    | employees  |        0 |     NULL | NULL       |              5 |            37 |            27 |          0 |                1 |                0 | NULL                    |                      NULL |
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
4 rows in set (0.01 sec)

3. What did you see instead (Required)

mysql> select * from TIKV_REGION_STATUS where table_id=69\G
*************************** 1. row ***************************
                REGION_ID: 136
                START_KEY: 7480000000000000FF4300000000000000F8
                  END_KEY: 7480000000000000FF4600000000000000F8
                 TABLE_ID: 67
                  DB_NAME: mysql
               TABLE_NAME: advisory_locks
                 IS_INDEX: 1
                 INDEX_ID: 1
               INDEX_NAME: PRIMARY
           EPOCH_CONF_VER: 5
            EPOCH_VERSION: 34
            WRITTEN_BYTES: 27
               READ_BYTES: 0
         APPROXIMATE_SIZE: 1
         APPROXIMATE_KEYS: 0
  REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 2. row ***************************
                REGION_ID: 136
                START_KEY: 7480000000000000FF4300000000000000F8
                  END_KEY: 7480000000000000FF4600000000000000F8
                 TABLE_ID: 67
                  DB_NAME: mysql
               TABLE_NAME: advisory_locks
                 IS_INDEX: 0
                 INDEX_ID: NULL
               INDEX_NAME: NULL
           EPOCH_CONF_VER: 5
            EPOCH_VERSION: 34
            WRITTEN_BYTES: 27
               READ_BYTES: 0
         APPROXIMATE_SIZE: 1
         APPROXIMATE_KEYS: 0
  REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
2 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

6.1.0

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.1.0
Edition: Community
Git Commit Hash: 1a89dec
Git Branch: heads/refs/tags/v6.1.0
UTC Build Time: 2022-06-05 05:15:11
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

@yilongrong yilongrong added the type/bug The issue is confirmed as a bug. label Aug 29, 2022
@xuyifangreeneyes
Copy link
Contributor

It can be reproduced on master:

mysql> select * from tables where table_name = 'employees'\G
*************************** 1. row ***************************
             TABLE_CATALOG: def
              TABLE_SCHEMA: test
                TABLE_NAME: employees
                TABLE_TYPE: BASE TABLE
                    ENGINE: InnoDB
                   VERSION: 10
                ROW_FORMAT: Compact
                TABLE_ROWS: 0
            AVG_ROW_LENGTH: 0
               DATA_LENGTH: 0
           MAX_DATA_LENGTH: 0
              INDEX_LENGTH: 0
                 DATA_FREE: 0
            AUTO_INCREMENT: NULL
               CREATE_TIME: 2022-08-29 14:23:28
               UPDATE_TIME: NULL
                CHECK_TIME: NULL
           TABLE_COLLATION: utf8mb4_bin
                  CHECKSUM: NULL
            CREATE_OPTIONS: partitioned
             TABLE_COMMENT:
             TIDB_TABLE_ID: 68
 TIDB_ROW_ID_SHARDING_INFO: NOT_SHARDED
              TIDB_PK_TYPE: NONCLUSTERED
TIDB_PLACEMENT_POLICY_NAME: NULL
1 row in set (0.01 sec)

mysql> select * from TIKV_REGION_STATUS where table_id=68\G
*************************** 1. row ***************************
                REGION_ID: 138
                START_KEY: 7480000000000000FF4200000000000000F8
                  END_KEY: 7480000000000000FF4500000000000000F8
                 TABLE_ID: 66
                  DB_NAME: mysql
               TABLE_NAME: advisory_locks
                 IS_INDEX: 1
                 INDEX_ID: 1
               INDEX_NAME: PRIMARY
           EPOCH_CONF_VER: 5
            EPOCH_VERSION: 34
            WRITTEN_BYTES: 0
               READ_BYTES: 0
         APPROXIMATE_SIZE: 1
         APPROXIMATE_KEYS: 186
  REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 2. row ***************************
                REGION_ID: 138
                START_KEY: 7480000000000000FF4200000000000000F8
                  END_KEY: 7480000000000000FF4500000000000000F8
                 TABLE_ID: 66
                  DB_NAME: mysql
               TABLE_NAME: advisory_locks
                 IS_INDEX: 0
                 INDEX_ID: NULL
               INDEX_NAME: NULL
           EPOCH_CONF_VER: 5
            EPOCH_VERSION: 34
            WRITTEN_BYTES: 0
               READ_BYTES: 0
         APPROXIMATE_SIZE: 1
         APPROXIMATE_KEYS: 186
  REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
2 rows in set (0.00 sec)

mysql> select * from TIKV_REGION_STATUS where table_name='employees'\G
*************************** 1. row ***************************
                REGION_ID: 3
                START_KEY: 7480000000000000FF4800000000000000F8
                  END_KEY:
                 TABLE_ID: 68
                  DB_NAME: test
               TABLE_NAME: employees
                 IS_INDEX: 0
                 INDEX_ID: NULL
               INDEX_NAME: NULL
           EPOCH_CONF_VER: 5
            EPOCH_VERSION: 37
            WRITTEN_BYTES: 257
               READ_BYTES: 1084566
         APPROXIMATE_SIZE: 1
         APPROXIMATE_KEYS: 1544
  REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 2. row ***************************
                REGION_ID: 142
                START_KEY: 7480000000000000FF4500000000000000F8
                  END_KEY: 7480000000000000FF4600000000000000F8
                 TABLE_ID: 68
                  DB_NAME: test
               TABLE_NAME: employees
                 IS_INDEX: 0
                 INDEX_ID: NULL
               INDEX_NAME: NULL
           EPOCH_CONF_VER: 5
            EPOCH_VERSION: 35
            WRITTEN_BYTES: 0
               READ_BYTES: 0
         APPROXIMATE_SIZE: 1
         APPROXIMATE_KEYS: 0
  REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 3. row ***************************
                REGION_ID: 146
                START_KEY: 7480000000000000FF4600000000000000F8
                  END_KEY: 7480000000000000FF4700000000000000F8
                 TABLE_ID: 68
                  DB_NAME: test
               TABLE_NAME: employees
                 IS_INDEX: 0
                 INDEX_ID: NULL
               INDEX_NAME: NULL
           EPOCH_CONF_VER: 5
            EPOCH_VERSION: 36
            WRITTEN_BYTES: 0
               READ_BYTES: 0
         APPROXIMATE_SIZE: 1
         APPROXIMATE_KEYS: 0
  REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 4. row ***************************
                REGION_ID: 150
                START_KEY: 7480000000000000FF4700000000000000F8
                  END_KEY: 7480000000000000FF4800000000000000F8
                 TABLE_ID: 68
                  DB_NAME: test
               TABLE_NAME: employees
                 IS_INDEX: 0
                 INDEX_ID: NULL
               INDEX_NAME: NULL
           EPOCH_CONF_VER: 5
            EPOCH_VERSION: 37
            WRITTEN_BYTES: 39
               READ_BYTES: 0
         APPROXIMATE_SIZE: 1
         APPROXIMATE_KEYS: 0
  REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
4 rows in set (0.00 sec)

@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 labels Aug 30, 2022
@zimulala zimulala self-assigned this Aug 30, 2022
@zimulala zimulala removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 labels Sep 2, 2022
@zimulala
Copy link
Contributor

zimulala commented Sep 2, 2022

This issue does have an impact on 4.0 and later versions, but there is no need to cherry-pick, so I will remove these labels

ti-chi-bot pushed a commit that referenced this issue Sep 2, 2022
@zimulala zimulala added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. labels Sep 6, 2022
@zimulala zimulala added affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 labels Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
5 participants