pingcap / pingcap/tidb

Unexpected side-effects of setting auto_increment

Open
#34,142 7 comments 0 reactions 1 assignee Claimed by @CbcWestwolf View on GitHub
severity/moderate sig/sql-infra type/bug
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)
```sql
create table test1(
a bigint(20) auto_increment,
b int,
primary key(a));

alter table test1 auto_increment=9223372036854775800;

insert into test1(b) values(1);

insert into test1(b) values(2);

insert into test1(b) values(3);

alter table test1 auto_increment=9223372036854775807;

alter table test1 auto_increment=9223372036854775803;

insert into test1(b) values(4);
```

### 2. What did you expect to see? (Required)
Successfully inserting `(9223372036854775803, 4)`

Same sql done in MySQL:
```
mysql> select * from test1;
+---------------------+------+
| a | b |
+---------------------+------+
| 9223372036854775800 | 1 |
| 9223372036854775801 | 2 |
| 9223372036854775802 | 3 |
| 9223372036854775803 | 4 |
| 9223372036854775804 | 5 |
| 9223372036854775805 | 6 |
+---------------------+------+
```
### 3. What did you see instead (Required)
tidb reports error:
```
ERROR 1467 (HY000): Failed to read auto-increment value from storage engine
```
Additionally, `9223372036854775807` is within the range of BIGINT and thus, TiDB has no reason to report an error.
### 4. What is your TiDB version? (Required)
ebdc78463a6ff52262183b67aec6c905e921be9a

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.