Two table ids are allocated when creating a table, but only one is used.
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```
tidb> create table t1 (a int);
Query OK, 0 rows affected (0.09 sec)
tidb> create table t2 (a int);
Query OK, 0 rows affected (0.08 sec)
tidb> SELECT TABLE_NAME, START_KEY, END_KEY FROM information_schema.TIKV_REGION_STATUS WHERE TABLE_NAME IN ('t1', 't2');
+------------+--------------------------------------+--------------------------------------+
| TABLE_NAME | START_KEY | END_KEY |
+------------+--------------------------------------+--------------------------------------+
| t1 | 7480000000000000FF6600000000000000F8 | 7480000000000000FF6800000000000000F8 |
| t2 | 7480000000000000FF6800000000000000F8 | 748000FFFFFFFFFFFFF900000000000000F8 |
+------------+--------------------------------------+--------------------------------------+
2 rows in set (0.00 sec)
tidb> select table_name, tidb_table_id from information_schema.tables where table_name in ('t1', 't2');
+------------+---------------+
| table_name | tidb_table_id |
+------------+---------------+
| t1 | 102 |
| t2 | 104 |
+------------+---------------+
2 rows in set (0.01 sec)
```
### 2. What did you expect to see? (Required)
Consecutive table ids, not a gap of one id (wasted one table id).
### 3. What did you see instead (Required)
Two table ids used when creating a single table.
Also the region end key is table_id + 2, what can be between table_id +1 .. table_id +2?
### 4. What is your TiDB version? (Required)
```
tidb_version(): Release Version: v7.6.0-alpha
Edition: Community
Git Commit Hash: 3f94666b4bafd903886b89206ac603d26d9a9e87
Git Branch: heads/refs/tags/v7.6.0-alpha
UTC Build Time: 2023-11-18 14:26:36
GoVersion: go1.21.3
Race Enabled: false
Check Table Before Drop: false
Store: tikv
```
Contributor guide
Assessment
This issue has not been assessed yet.