See my question to Experts Exchange for the full details and my workaround
https://www.experts-exchange.com/questions/29245628/BUG-IN-MARIADB-AUTOINC-FUNCTION.html
Short version: On importing blocks of 10000 CSVs using a LOAD DATA script run from a batch file, the first block will be numbered correctly. The first row in the second block will skip exactly 6183 numbers (as though the auto_increment value was reset by that amount)
I discovered by trial and error that if I tried, prior to the next upload, to reset the auto_increment value manually (through the HEIDI SQL UI) the next block would be numbered correctly. If I imported the block after that WITHOUT such intervention, it would arrive with its first number having skipped the same 6183.
As I'm trying to build a table with 300 million rows, manual intervention wasn't an option so I discovered that, if before triggering the next upload, I calculate correct auto_increment value and issue the command:
ALTER TABLE `hash_chain` AUTO_INCREMENT=[whatever I've just calculated]
that has the same effect as the manual intervention and the numbering appears as it should.
(medium whinge: it took me 3 days to get that line to work because NOWHERE could I find any hint that we needed to use that eclectic punctuation. Maria's own guide https://mariadb.com/kb/en/auto_increment/ doesn't even use punctuation and all the examples I could find were using either no punctuation or standard quote marks instead of those "diacriticals". I only discovered by forensically examining the code HEIDI produced when I did the manual intervention.)
The important point, of course, is that this kludge simply shouldn't be necessary and I can find no evidence that anyone else has reported similar behaviour.
If required, because the data is entirely anonymous, (and changes every time I build it) I'm happy to provide a few sample csvs and the code I use to run the import, for others to try to recreate the problem.
{"report":{"fcp":1201,"ttfb":357.30000019073486,"pageVisibility":"visible","entityId":114324,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"81af0443-d200-42ec-9024-cfaf3adc1766","navigationType":0,"readyForUser":1317.0999999046326,"redirectCount":0,"resourceLoadedEnd":919.3000001907349,"resourceLoadedStart":363.7000002861023,"resourceTiming":[{"duration":191.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":363.7000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":363.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":554.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":191.2000002861023,"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":364,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":364,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":555.2000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":427.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":364.2000002861023,"connectEnd":364.2000002861023,"connectStart":364.2000002861023,"domainLookupEnd":364.2000002861023,"domainLookupStart":364.2000002861023,"fetchStart":364.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":560.4000000953674,"responseEnd":791.9000000953674,"responseStart":592.4000000953674,"secureConnectionStart":364.2000002861023},{"duration":554.9000000953674,"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":364.40000009536743,"connectEnd":364.40000009536743,"connectStart":364.40000009536743,"domainLookupEnd":364.40000009536743,"domainLookupStart":364.40000009536743,"fetchStart":364.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":560.8000001907349,"responseEnd":919.3000001907349,"responseStart":631.9000000953674,"secureConnectionStart":364.40000009536743},{"duration":231.10000038146973,"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":364.59999990463257,"connectEnd":364.59999990463257,"connectStart":364.59999990463257,"domainLookupEnd":364.59999990463257,"domainLookupStart":364.59999990463257,"fetchStart":364.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":560.9000000953674,"responseEnd":595.7000002861023,"responseStart":594.8000001907349,"secureConnectionStart":364.59999990463257},{"duration":249.39999961853027,"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":364.7000002861023,"connectEnd":364.7000002861023,"connectStart":364.7000002861023,"domainLookupEnd":364.7000002861023,"domainLookupStart":364.7000002861023,"fetchStart":364.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":562.3000001907349,"responseEnd":614.0999999046326,"responseStart":608.5999999046326,"secureConnectionStart":364.7000002861023},{"duration":248,"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":364.80000019073486,"connectEnd":364.80000019073486,"connectStart":364.80000019073486,"domainLookupEnd":364.80000019073486,"domainLookupStart":364.80000019073486,"fetchStart":364.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":561.5,"responseEnd":612.8000001907349,"responseStart":606.8000001907349,"secureConnectionStart":364.80000019073486},{"duration":193,"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":365.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":365.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":558.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":248.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":365.30000019073486,"connectEnd":365.30000019073486,"connectStart":365.30000019073486,"domainLookupEnd":365.30000019073486,"domainLookupStart":365.30000019073486,"fetchStart":365.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":562.5,"responseEnd":613.8000001907349,"responseStart":607.9000000953674,"secureConnectionStart":365.30000019073486},{"duration":193.5,"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":365.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":365.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":558.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":249.2000002861023,"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":365.5,"connectEnd":365.5,"connectStart":365.5,"domainLookupEnd":365.5,"domainLookupStart":365.5,"fetchStart":365.5,"redirectEnd":0,"redirectStart":0,"requestStart":563.2000002861023,"responseEnd":614.7000002861023,"responseStart":609.4000000953674,"secureConnectionStart":365.5},{"duration":518,"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":366.40000009536743,"connectEnd":366.40000009536743,"connectStart":366.40000009536743,"domainLookupEnd":366.40000009536743,"domainLookupStart":366.40000009536743,"fetchStart":366.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":733.9000000953674,"responseEnd":884.4000000953674,"responseStart":880.0999999046326,"secureConnectionStart":366.40000009536743},{"duration":513.9000000953674,"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":370.80000019073486,"connectEnd":370.80000019073486,"connectStart":370.80000019073486,"domainLookupEnd":370.80000019073486,"domainLookupStart":370.80000019073486,"fetchStart":370.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":736.8000001907349,"responseEnd":884.7000002861023,"responseStart":880.7000002861023,"secureConnectionStart":370.80000019073486},{"duration":119.7999997138977,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":924.7000002861023,"connectEnd":924.7000002861023,"connectStart":924.7000002861023,"domainLookupEnd":924.7000002861023,"domainLookupStart":924.7000002861023,"fetchStart":924.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":1011.5,"responseEnd":1044.5,"responseStart":1043.9000000953674,"secureConnectionStart":924.7000002861023},{"duration":202.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1155.8000001907349,"connectEnd":1155.8000001907349,"connectStart":1155.8000001907349,"domainLookupEnd":1155.8000001907349,"domainLookupStart":1155.8000001907349,"fetchStart":1155.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1326.0999999046326,"responseEnd":1358.7000002861023,"responseStart":1357.9000000953674,"secureConnectionStart":1155.8000001907349},{"duration":234.2999997138977,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1194.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1194.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1428.5,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":179,"responseStart":358,"responseEnd":363,"domLoading":362,"domInteractive":1432,"domContentLoadedEventStart":1433,"domContentLoadedEventEnd":1499,"domComplete":1930,"loadEventStart":1930,"loadEventEnd":1930,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1357.8000001907349},{"name":"bigPipe.sidebar-id.end","time":1359.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":1359.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1361.9000000953674},{"name":"activityTabFullyLoaded","time":1515.0999999046326}],"measures":[],"correlationId":"4958892bd43411","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":107,"dbReadsTimeInMs":17,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
MikeJacobs, SHOW CREATE TABLE should roughly display the AUTO_INCREMENT value that would be used for the next insert. It is not exactly that simple, but close to the truth if you are using the default auto_increment_increment=1 and auto_increment_offset=0. If some operations that ‘consumed’ or ‘allocated’ AUTO_INCREMENT values were never committed (for example due to a deadlock of transactions, or due to a duplicate key error), and if the server was restarted, then
MDEV-6076could start to make trouble for you. BeforeMDEV-6076, on server restart, InnoDB would basically do SELECT MAX(auto_increment_column) to initialize the counter. Some applications require a guarantee that AUTO_INCREMENT values are never reused or reissued, and such applications must obviously be tolerant of any ‘gaps’ in the sequence.In InnoDB, you should be able to reset the AUTO_INCREMENT counter to the ‘minimal’ value (in this case 10001) by executing something like this:
The ALGORITHM=NOCOPY is just a safety measure to refuse an expensive operation. Normally, the native algorithm inside InnoDB should be chosen.
My interest in this ticket was to check if there is a bug in InnoDB. I will let my colleagues judge whether this qualifies as a bug in LOAD DATA or INSERT.