Bug #84101 inconsistent behavior for auto increment column when reaching max limit
Submitted: 8 Dec 2016 6:46 Modified: 8 Dec 2016 10:34
Reporter: 帅 Bang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.5/5.6/5.7/8.0 OS:Linux
Assigned to: CPU Architecture:Any

[8 Dec 2016 6:46] 帅 Bang
Description:
mysql> create table t2(c1 int unsigned primary key auto_increment);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into t2 values (4294967295); // yeah, 4294967295  = UINT32_MAX - 1

Query OK, 1 row affected (0.00 sec)
mysql> insert into t2 values (0);
ERROR 1062 (23000): Duplicate entry '4294967295' for key 'PRIMARY'

OK, let us see what will happen when it comes to bigint unsigned

mysql> drop table t2;
Query OK, 0 rows affected (0.00 sec)

mysql> create table t2(c1 bigint unsigned primary key auto_increment);
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t2 values (18446744073709551614);// yeah, UINT64_MAX - 1
Query OK, 1 row affected (0.00 sec)
mysql> insert into t2 values (0);
ERROR 1467 (HY000): Failed to read auto-increment value from storage engine

How to repeat:
create table t2(c1 int unsigned primary key auto_increment);
insert into t2 values (4294967295);
insert into t2 values (0);

drop table t2;

create table t2(c1 bigint unsigned primary key auto_increment);
insert into t2 values (18446744073709551614);
insert into t2 values (0);

Suggested fix:
both failed with same error message and error code 

or

both succeed  and UINT32_MAX and UINT64_MAX are generated , respectively.  (high recommended)
[8 Dec 2016 7:28] 帅 Bang
add version info
[8 Dec 2016 10:34] MySQL Verification Team
Thank you for the bug report. Verified as described.