Bug #67526 | Duplicate key error on auto-inc PK with mixed auto_increment_increment clients | ||
---|---|---|---|
Submitted: | 8 Nov 2012 18:51 | Modified: | 7 May 2019 21:37 |
Reporter: | Rob Lineweaver | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 5.5.28, 5.5.29, 5.7.0 | OS: | Linux (Debian/AMD64 6.0.5) |
Assigned to: | CPU Architecture: | Any | |
Tags: | auto_increment_increment, regression |
[8 Nov 2012 18:51]
Rob Lineweaver
[8 Nov 2012 20:18]
Sveta Smirnova
Thank you for the report. Verified as described. Test case for MTR: --source include/have_innodb.inc create table test_items (id int(11) auto_increment primary key) engine=innodb; set auto_increment_increment=1; delimiter |; create procedure bug67526(iterations int) begin while iterations > 0 do set iterations = iterations -1; insert into `test_items` values (DEFAULT); end while; end;| delimiter ;| connect(con1, localhost, root,,); connection con1; set auto_increment_increment=2; connection default; --send call bug67526(10000); connection con1; call bug67526(10000); connection default; --reap select max(id) from test_items;
[8 Nov 2012 21:01]
Rob Lineweaver
fixing typo in tag
[19 Nov 2013 12:08]
Sam Butler
We're seeing the same bug reproduced on 5.5.33 (Linux) with two replicating servers that have the same auto_increment_increment value, but a different offset. A single client is connected and trying to insert into the table that throws the duplicate PK error on an auto inc field.
[20 Aug 2015 12:49]
Rolf Martin-Hoster
As noticed by Sam this is occurring with same auto_increment_increment and is similar if not the same as http://bugs.mysql.com/bug.php?id=76872
[8 Apr 2019 8:47]
Pavel Katiushyn
I had the same issue on 5.7.25.
[7 May 2019 21:13]
Daniel Price
Posted by developer: Bug#15851528 DUPLICATE KEY ERROR ON AUTO-INC PK WITH MIXED AUTO_INCREMENT_INCREMENT CLIENTS Problem: Clients running different values for auto_increment_increment and doing concurrent inserts leads to "Duplicate key error" in one of them. Analysis: When Autoinc_increment value is reduced in a session, InnoDB uses last autoinc_increment value to recalculate the autoinc value. In case, some other session has inserted a value with different autoinc_increment, InnoDB recalculate autoinc values based on current session previous autoinc_increment instead of considering the autoinc_increment used for last insert across all session Fix: revert 1d4494d93c2f as it causing the current bug.
[7 May 2019 21:37]
Daniel Price
Posted by developer: Fixed as of the upcoming 5.5.65, 5.6.45, 5.7.27, 8.0.17 releases, and here's the changelog entry: Client sessions using different auto_increment_increment values while performing concurrent insert operations could cause a duplicate key error.