I am filing this bug with MariaDB, just for the sake of completeness, as it was already filed with MySQL/InnoDB here (by someone else):
http://bugs.mysql.com/bug.php?id=76872
"InnoDB AUTO_INCREMENT produces same value twice"
"When more than one INSERT is executed concurrently on a non-empty InnoDB table with an AUTO_INCREMENT PK immediately after MySQL start up (before any other INSERTs on the same table) one will often fail with the message like "Duplicate entry '123' for key 'PRIMARY'". This will only happen if innodb_autoinc_lock_mode is 1 or 2 and auto_increment_increment > 1."
There is much more in the actual bug report, but I didn't want to copy/paste the entire report.
- relates to
-
MDEV-20927
Duplicate key with auto increment
-
-
Closed
- links to
-
-
{"report":{"fcp":5070.800000190735,"ttfb":643.4000000953674,"pageVisibility":"visible","entityId":53311,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0,"journeyId":"c2a3bff8-fc5f-4d6d-bded-5c296e515b65","navigationType":0,"readyForUser":4674.700000286102,"redirectCount":0,"resourceLoadedEnd":4572.800000190735,"resourceLoadedStart":735.2000002861023,"resourceTiming":[{"duration":845.2999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":735.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":735.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1580.5,"responseStart":0,"secureConnectionStart":0},{"duration":845.4000000953674,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":735.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":735.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1580.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":3373.800000190735,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":735.5,"connectEnd":735.5,"connectStart":735.5,"domainLookupEnd":735.5,"domainLookupStart":735.5,"fetchStart":735.5,"redirectEnd":0,"redirectStart":0,"requestStart":1778.5999999046326,"responseEnd":4109.300000190735,"responseStart":2043.5999999046326,"secureConnectionStart":735.5},{"duration":3436.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":735.8000001907349,"connectEnd":735.8000001907349,"connectStart":735.8000001907349,"domainLookupEnd":735.8000001907349,"domainLookupStart":735.8000001907349,"fetchStart":735.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1778.4000000953674,"responseEnd":4172.200000286102,"responseStart":2039.3000001907349,"secureConnectionStart":735.8000001907349},{"duration":1797.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":736.0999999046326,"connectEnd":736.0999999046326,"connectStart":736.0999999046326,"domainLookupEnd":736.0999999046326,"domainLookupStart":736.0999999046326,"fetchStart":736.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1778.5999999046326,"responseEnd":2533.5,"responseStart":2045.5,"secureConnectionStart":736.0999999046326},{"duration":1798.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":736.2000002861023,"connectEnd":736.2000002861023,"connectStart":736.2000002861023,"domainLookupEnd":736.2000002861023,"domainLookupStart":736.2000002861023,"fetchStart":736.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":1778.9000000953674,"responseEnd":2534.800000190735,"responseStart":2273.5999999046326,"secureConnectionStart":736.2000002861023},{"duration":1797.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":736.5,"connectEnd":736.5,"connectStart":736.5,"domainLookupEnd":736.5,"domainLookupStart":736.5,"fetchStart":736.5,"redirectEnd":0,"redirectStart":0,"requestStart":1778.7000002861023,"responseEnd":2533.800000190735,"responseStart":2174,"secureConnectionStart":736.5},{"duration":844.8000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":736.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":736.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1581.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":1798.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":736.8000001907349,"connectEnd":736.8000001907349,"connectStart":736.8000001907349,"domainLookupEnd":736.8000001907349,"domainLookupStart":736.8000001907349,"fetchStart":736.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1779,"responseEnd":2534.9000000953674,"responseStart":2275,"secureConnectionStart":736.8000001907349},{"duration":845,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":736.9000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":736.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1581.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":2884,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":737.2000002861023,"connectEnd":737.2000002861023,"connectStart":737.2000002861023,"domainLookupEnd":737.2000002861023,"domainLookupStart":737.2000002861023,"fetchStart":737.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":1779.0999999046326,"responseEnd":3621.2000002861023,"responseStart":2470.2000002861023,"secureConnectionStart":737.2000002861023},{"duration":3833.300000190735,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":738.5,"connectEnd":738.5,"connectStart":738.5,"domainLookupEnd":738.5,"domainLookupStart":738.5,"fetchStart":738.5,"redirectEnd":0,"redirectStart":0,"requestStart":1958.2000002861023,"responseEnd":4571.800000190735,"responseStart":4269.300000190735,"secureConnectionStart":738.5},{"duration":3834.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":738.5999999046326,"connectEnd":738.5999999046326,"connectStart":738.5999999046326,"domainLookupEnd":738.5999999046326,"domainLookupStart":738.5999999046326,"fetchStart":738.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":2534.5999999046326,"responseEnd":4572.800000190735,"responseStart":4438.300000190735,"secureConnectionStart":738.5999999046326},{"duration":478.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":4275.300000190735,"connectEnd":4275.300000190735,"connectStart":4275.300000190735,"domainLookupEnd":4275.300000190735,"domainLookupStart":4275.300000190735,"fetchStart":4275.300000190735,"redirectEnd":0,"redirectStart":0,"requestStart":4275.300000190735,"responseEnd":4754.200000286102,"responseStart":4754.200000286102,"secureConnectionStart":4275.300000190735}],"fetchStart":0,"domainLookupStart":346,"domainLookupEnd":367,"connectStart":367,"connectEnd":386,"secureConnectionStart":376,"requestStart":387,"responseStart":643,"responseEnd":768,"domLoading":649,"domInteractive":4773,"domContentLoadedEventStart":4773,"domContentLoadedEventEnd":4818,"domComplete":5713,"loadEventStart":5713,"loadEventEnd":5715,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":4716.900000095367},{"name":"bigPipe.sidebar-id.end","time":4717.700000286102},{"name":"bigPipe.activity-panel-pipe-id.start","time":4717.900000095367},{"name":"bigPipe.activity-panel-pipe-id.end","time":4720.200000286102},{"name":"activityTabFullyLoaded","time":4830.800000190735}],"measures":[],"correlationId":"b988676da24279","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":118,"dbReadsTimeInMs":11,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Non-deterministic test case by Laurynas Biveinis from the upstream report (run with --repeat=N):
--source include/have_innodb.inc
# Should be != 0
SELECT @@innodb_autoinc_lock_mode;
CREATE TABLE `test` (
`test_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`testcol` varchar(256)
) ENGINE=InnoDB;
INSERT INTO `test` (`testcol`) VALUES ('aldsldjfhasjk');
SET SESSION auto_increment_increment = 2;
send INSERT INTO `test` (`testcol`) VALUES ('aldsldjfhasjk');
--connect(con1,localhost,root,,)
--connection con1
SET SESSION auto_increment_increment = 2;
send INSERT INTO `test` (`testcol`) VALUES ('aldsldjfhasjk');
# --error 0,1062
reap;
--disconnect con1
--connection default
# --error 0,1062
reap;
SELECT * FROM test;
DROP TABLE test;