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

alter table t auto_increment=xxx doesn't work properly #17460

Open
cyliu0 opened this issue May 27, 2020 · 1 comment
Open

alter table t auto_increment=xxx doesn't work properly #17460

cyliu0 opened this issue May 27, 2020 · 1 comment
Assignees
Labels
severity/minor sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@cyliu0
Copy link
Contributor

cyliu0 commented May 27, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Reproduced on pd/tikv/tidb (3/3/3) cluster

> drop table if exists t;
> create table t (a int) shard_row_id_bits = 5;
> alter table t auto_increment = 72057594037927936;   
> insert into t set a=1;
> alter table t shard_row_id_bits = 10;
Error 1467: shard_row_id_bits 10 will cause next global auto ID 72057594039457405 overflow"
-- The error information should show 72057594037927936

mysql root@172.16.4.61:test> create table t1 (a int auto_increment primary key);
Query OK, 0 rows affected
Time: 0.563s
mysql root@172.16.4.61:test> insert into t1 values()
Query OK, 1 row affected
Time: 0.060s
mysql root@172.16.4.61:test> alter table t1 auto_increment = 10000
You're about to run a destructive command.
Do you want to proceed? (y/n): y
Your call!
Query OK, 0 rows affected
Time: 1.059s
mysql root@172.16.4.61:test> insert into t1 values()
Query OK, 1 row affected
Time: 0.057s
mysql root@172.16.4.61:test> select * from t1
+-------+
| a     |
+-------+
| 1     |
| 93497 |
+-------+
2 rows in set
Time: 0.063s

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

> alter table t shard_row_id_bits = 10;
Error 1467: shard_row_id_bits 10 will cause next global auto ID 72057594039457405 overflow"

> select * from t1;
+-------+
| a     |
+-------+
| 1     |
| 10000 |
+-------+

3. What did you see instead (Required)

> alter table t shard_row_id_bits = 10;
Error 1467: shard_row_id_bits 10 will cause next global auto ID 72057594037927936 overflow"

> select * from t1;
+-------+
| a     |
+-------+
| 1     |
| 93497 |
+-------+

4. Affected version (Required)

mysql root@172.16.4.103:(none)> select tidb_version()
+-------------------------------------------------------------------+
| tidb_version()                                                    |
+-------------------------------------------------------------------+
| Release Version: v4.0.0-rc.2-41-g689a6b6                          |
| Edition: Community                                                |
| Git Commit Hash: 689a6b6439ae7835947fcaccf329a3fc303986cb         |
| Git Branch: release-4.0                                           |
| UTC Build Time: 2020-05-27 11:07:16                               |
| GoVersion: go1.13.10                                              |
| Race Enabled: false                                               |
| TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306 |
| Check Table Before Drop: false                                    |
+-------------------------------------------------------------------+

5. Root Cause Analysis

@cyliu0 cyliu0 added the type/bug The issue is confirmed as a bug. label May 27, 2020
@gengliqi gengliqi added the sig/sql-infra SIG: SQL Infra label Jun 1, 2020
@bb7133
Copy link
Member

bb7133 commented Aug 27, 2020

> select * from t1;
+-------+
| a     |
+-------+
| 1     |
| 93497 |
+-------+

The value is expected because of the cache: https://docs.pingcap.com/tidb/stable/auto-increment#concept

Error 1467: shard_row_id_bits 10 will cause next global auto ID 72057594037927936 overflow"

Looks that the error message should be refined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/minor sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

5 participants