-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Closed
Copy link
Labels
affects-6.4affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-6.6affects-7.0affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.affects-7.2affects-7.3component/brThis issue is related to BR of TiDB.This issue is related to BR of TiDB.fixes-6.5.5severity/criticalsig/sql-infraSIG: SQL InfraSIG: SQL Infratype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
- prepare
use test;
create table t (a int primary key nonclustered auto_increment, b int) auto_id_cache = 1;
insert into t (b) values (1), (2), (3);
show table t next_row_id;
-- _TIDB_ROWID = 30001, AUTO_INCREMENT = 4
- backup & restore
backup table t to 'local:///tmp/br';
drop table t;
restore table t from 'local:///tmp/br';
2. What did you expect to see? (Required)
(explained below)
3. What did you see instead (Required)
- the next_row_id are wrong
show table t next_row_id;
-- _TIDB_ROWID = 1, AUTO_INCREMENT = 4001
- try insert more rows, result in duplicate keys of
_tidb_rowid
insert into t (b) values (4), (5), (6);
-- ERROR 1062 (23000): Duplicate entry '1' for key 't.PRIMARY'
- after
_tidb_rowid
increases to the available zone, we see the primary key's auto-inc values have a gap
insert into t (b) values (7), (8), (9);
select * from t;
+------+------+
| a | b |
+------+------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4004 | 7 |
| 4005 | 8 |
| 4006 | 9 |
+------+------+
4. What is your TiDB version? (Required)
Release Version: v7.1.1
Edition: Community
Git Commit Hash: cf441574864be63938524e7dfcf7cc659edc3dd8
Git Branch: heads/refs/tags/v7.1.1
UTC Build Time: 2023-07-19 10:20:53
GoVersion: go1.20.6
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
Metadata
Metadata
Assignees
Labels
affects-6.4affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-6.6affects-7.0affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.affects-7.2affects-7.3component/brThis issue is related to BR of TiDB.This issue is related to BR of TiDB.fixes-6.5.5severity/criticalsig/sql-infraSIG: SQL InfraSIG: SQL Infratype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.