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

When the table is latest created, getting the wrong result select * from TIKV_REGION_STATUS where table_id=xx; #37499

Closed
zimulala opened this issue Aug 31, 2022 · 1 comment · Fixed by #38601
Labels
severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@zimulala
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a int);
create table tt(a int);                         // this is latest created table.
select * from information_schema.tables where table_name = 't'\G;
select * from information_schema.tables where table_name = 'tt'\G;
select * from INFORMATION_SCHEMA.TIKV_REGION_STATUS where table_id=88;

select * from INFORMATION_SCHEMA.TIKV_REGION_STATUS where table_id=90 limit 5;

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

tidb> create table t(a int);
Query OK, 0 rows affected (0.51 sec)

tidb> create table tt(a int);
Query OK, 0 rows affected (0.51 sec)

tidb> select * from information_schema.tables where table_name = 't'\G;
*************************** 1. row ***************************
             TABLE_CATALOG: def
              TABLE_SCHEMA: test
                TABLE_NAME: t
                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-31 14:20:55
               UPDATE_TIME: NULL
                CHECK_TIME: NULL
           TABLE_COLLATION: utf8mb4_bin
                  CHECKSUM: NULL
            CREATE_OPTIONS:
             TABLE_COMMENT:
             TIDB_TABLE_ID: 88
 TIDB_ROW_ID_SHARDING_INFO: NOT_SHARDED
              TIDB_PK_TYPE: NONCLUSTERED
TIDB_PLACEMENT_POLICY_NAME: NULL
1 row in set (0.01 sec)

ERROR:
No query specified

tidb> select * from information_schema.tables where table_name = 'tt'\G;
*************************** 1. row ***************************
             TABLE_CATALOG: def
              TABLE_SCHEMA: test
                TABLE_NAME: tt
                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-31 14:20:58
               UPDATE_TIME: NULL
                CHECK_TIME: NULL
           TABLE_COLLATION: utf8mb4_bin
                  CHECKSUM: NULL
            CREATE_OPTIONS:
             TABLE_COMMENT:
             TIDB_TABLE_ID: 90
 TIDB_ROW_ID_SHARDING_INFO: NOT_SHARDED
              TIDB_PK_TYPE: NONCLUSTERED
TIDB_PLACEMENT_POLICY_NAME: NULL
1 row in set (0.01 sec)

tidb>  select * from INFORMATION_SCHEMA.TIKV_REGION_STATUS where table_id=88;
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
| 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 |
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
|      8033 | 7480000000000000FF5800000000000000F8 | 7480000000000000FF5A00000000000000F8 |       88 | test    | t          |        0 |     NULL | NULL       |              1 |            54 |             0 |          0 |                1 |              159 | NULL                    |                      NULL |
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
1 row in set (4.53 sec)

tidb>  select * from INFORMATION_SCHEMA.TIKV_REGION_STATUS where table_id=90 limit 5;
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
| 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 |
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
|      8035 | 7480000000000000FF5A00000000000000F8 |   |       90 | test    | tt         |        0 |     NULL | NULL       |              1 |            55 |             0 |          0 |                1 |              165 | NULL                    |                      NULL |
+-----------+--------------------------------------+--------------------------------------+----------+---------+------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

+-----------+--------------------------------------+---------+-----------------+---------+------------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
| 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 | 7480000000000000FF5A00000000000000F8 |         |              90 | test    | tt               |        0 |     NULL | NULL       |              1 |            54 |             0 |    1605060 |                1 |              330 | NULL                    |                      NULL |
|         2 | 7480000000000000FF5A00000000000000F8 |         | 281474976710652 | mysql   | tidb_ddl_history |        0 |     NULL | NULL       |              1 |            54 |             0 |    1605060 |                1 |              330 | NULL                    |                      NULL |
|         2 | 7480000000000000FF5A00000000000000F8 |         | 281474976710653 | mysql   | tidb_ddl_reorg   |        1 |        1 | job_id     |              1 |            54 |             0 |    1605060 |                1 |              330 | NULL                    |                      NULL |
|         2 | 7480000000000000FF5A00000000000000F8 |         | 281474976710653 | mysql   | tidb_ddl_reorg   |        0 |     NULL | NULL       |              1 |            54 |             0 |    1605060 |                1 |              330 | NULL                    |                      NULL |
|         2 | 7480000000000000FF5A00000000000000F8 |         | 281474976710654 | mysql   | tidb_ddl_job     |        0 |     NULL | NULL       |              1 |            54 |             0 |    1605060 |                1 |              330 | NULL                    |                      NULL |
+-----------+--------------------------------------+---------+-----------------+---------+------------------+----------+----------+------------+----------------+---------------+---------------+------------+------------------+------------------+-------------------------+---------------------------+
5 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

Release Version: v6.3.0-alpha-18-ged84b0f16
Edition: Community
Git Commit Hash: ed84b0f1614b3a90497f193004b14d1b3eae4740
Git Branch: master
@zimulala zimulala added the type/bug The issue is confirmed as a bug. label Aug 31, 2022
@zimulala
Copy link
Contributor Author

Related #37436.

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