Bug #100965 | import table has auto increment, after restart,report Duplicate entry error | ||
---|---|---|---|
Submitted: | 27 Sep 2020 1:20 | Modified: | 28 Sep 2020 14:38 |
Reporter: | aceking king | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Data Dictionary | Severity: | S3 (Non-critical) |
Version: | 8.0.21 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[27 Sep 2020 1:20]
aceking king
[28 Sep 2020 14:38]
MySQL Verification Team
Hi, Verified as described. Thanks for the report Bogdan
[25 Mar 2021 1:20]
Jigar Patel
Is there a workaround to this issue? Any command I can execute on the table to fix the issue post importing the tablespace? Auto increment is the fundamental part of the RDBMS and it is surprising to me that it breaks with the tablespace import after the restart.
[25 Mar 2021 1:32]
Jigar Patel
I think I figured out the workaround. After reboot, I can set the AUTO_INCREMENT value on the table and then it works fine. Get current AUTO_INCREMENT VALUE; SELECT AUTO_INCREMENT as auto_increment from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '<schema>' AND TABLE_NAME = '<table>' Set AUTO_INCREMENT on table with imported tablespace ALTER TABLE t2 AUTO_INCREMENT = <number>; For those who run into this issue, I hope this helps until the official fix rolls out with future MySQL release. This is a crude workaround, but it works.
[1 Apr 2021 0:40]
Jigar Patel
Even better solution is to reset the AUTO_INCREMENT and let MySQL handle the rest after the restart. ALTER TABLE <table_name> AUTO_INCREMENT = 0;