Bug #107961 | AUTOINC counter resets to 1 after ALTER TABLE following by restart | ||
---|---|---|---|
Submitted: | 25 Jul 2022 9:59 | Modified: | 29 Jul 2022 8:12 |
Reporter: | Rahul Sisondia | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | auto increment |
[25 Jul 2022 9:59]
Rahul Sisondia
[25 Jul 2022 10:16]
Rahul Sisondia
Changing the ALGORITHM to COPY in the alter table statement does not make any difference.
[25 Jul 2022 12:48]
MySQL Verification Team
Hi Mr. Sisondia, Thank you very much for your bug report. We have managed to repeat it fully. We did a proper shutdown and INSERT that should have worked properly, now returns the same error on the duplicate key. Hence, this is truly a bug. Verified as reported.
[29 Jul 2022 3:04]
huahua xu
The innodb does not persistent dynamic metadata for autoinc counter by writing MLOG_TABLE_DYNAMIC_META redo log. Your ddl is required for copying data and skip the undo log for insertion of row in the table during copy alter operation.
[29 Jul 2022 8:12]
Rahul Sisondia
Thanks @huahua xu, I am not clear though. Are you explaining why does this happen ? or Are you saying that it is by design so will not be fixed ?
[1 Aug 2022 7:29]
huahua xu
Hi Rahul Sisondia, I just explained the cause of the bug.
[6 Sep 2022 18:15]
Gabor Buella
Posted by developer: Some of the findings so far: It seems this bug was introduced by the commit 6ff88b3430fb1ae91d9e5175b1e95d5079675c56 "WL#9536: Add a 'version' field to innodb_dynamic_metadata" in 2017 The strange behaviour seen, where issuing the alter command twice in a row "fixes" the problem, seems to be pointing to the fact that the first alter command makes a copy of the table, then replaces the original table by a rename -- while the second alter command results in a an inplace alter, which then seems to persist the autoinc counter.
[19 Sep 2022 11:14]
MySQL Verification Team
Thank you, Mr. Buella.
[31 Oct 2022 16:49]
Jakub Lopuszanski
Posted by developer: I've reported the issue I've described above as a separate Bug #34752625 Persistent Table Metadata from various versions is not aggregated properly
[1 Nov 2022 13:10]
MySQL Verification Team
Thank you, Mr. Lopuszanski .....