pingcap / pingcap/tidb

ID sequence getting missed even after adding Auto_id_cache=1 while creating the table

Open
#59,261 3 comments 0 reactions 1 assignee Claimed by @tiancaiamao View on GitHub
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)

Create table with init as primary key with auto_id_cache=1;

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

```
mysql> select id from emp order by id;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+------+
```

### 3. What did you see instead (Required)

```
mysql> select id from emp order by id;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4001 |
| 4002 |
+------+
5 rows in set (0.01 sec)
```

### 4. What is your TiDB version? (Required)

```
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.1.1
Edition: Community
Git Commit Hash: a7df4f9845d5d6a590c5d45dad0dcc9f21aa8765
Git Branch: HEAD
UTC Build Time: 2024-08-22 05:49:03
GoVersion: go1.21.13
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

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.