A workload where many workers concurrently pull a number from a InnoDB sequence and insert the number into another InnoDB table using transactions, occasionally causes all worker threads to hang in SEQUENCE::next_value. Everything is fine when no transactions are used (autocommit) or when the sequence object is using the MyISAM engine.
How to repeat:
You need Lua-enabled sysbench, i.e. from https://github.com/hgxl64/sysbench-mariadb.git. Then use the attached test script sequence_native.lua:
mysql -S ... -u root -e "drop database if exists sbtest"
|
mysql -S ... -u root -e "create database sbtest"
|
sysbench --test=sequence_native.lua --oltp-tables-count=32 \
|
--mysql-table-engine=InnoDB --sequence-cache=10 \
|
--mysql-user=root --mysql-socket=... prepare
|
sysbench --test=sequence_native.lua --oltp-tables-count=32 \
|
--trx-size=10 --num-threads=2 --report-interval=1 --max-time=0 \
|
--max-requests=0 --mysql-user=root --mysql-socket=... run
|
You might need to alter the sequence cache size or number of threads. The Lua script understands a few options:
--sequence-cache is used for the CACHE option when creating the sequence
--sequence-engine is used for the ENGINE option of the sequence
--trx-size gives the number of inserts in each transaction
My guess is, that something goes wrong if the sequence cache runs empty for multiple worker threads and they have to dive for the base table at the same time. The bigger the sequence cache is, the more worker threads are needed to trigger the hang. I.e. with Cache=1000 I need 16 threads.
Attached is also my.cnf and a stack trace from a hanging mysqld.
{"report":{"fcp":982.7000000476837,"ttfb":130.60000014305115,"pageVisibility":"visible","entityId":62587,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"78e22759-7473-4a23-9dd5-69c6f3351d6b","navigationType":0,"readyForUser":1044.7000000476837,"redirectCount":0,"resourceLoadedEnd":1115.2000000476837,"resourceLoadedStart":138.30000019073486,"resourceTiming":[{"duration":415,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":138.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":138.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":553.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":414.7000000476837,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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","startTime":138.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":138.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":553.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":423.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":138.70000004768372,"connectEnd":138.70000004768372,"connectStart":138.70000004768372,"domainLookupEnd":138.70000004768372,"domainLookupStart":138.70000004768372,"fetchStart":138.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":138.70000004768372,"responseEnd":562.4000000953674,"responseStart":562.4000000953674,"secureConnectionStart":138.70000004768372},{"duration":451.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":138.90000009536743,"connectEnd":138.90000009536743,"connectStart":138.90000009536743,"domainLookupEnd":138.90000009536743,"domainLookupStart":138.90000009536743,"fetchStart":138.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":138.90000009536743,"responseEnd":590.3000001907349,"responseStart":590.3000001907349,"secureConnectionStart":138.90000009536743},{"duration":447.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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","startTime":138.90000009536743,"connectEnd":138.90000009536743,"connectStart":138.90000009536743,"domainLookupEnd":138.90000009536743,"domainLookupStart":138.90000009536743,"fetchStart":138.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":138.90000009536743,"responseEnd":586.7000000476837,"responseStart":586.7000000476837,"secureConnectionStart":138.90000009536743},{"duration":451.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":139.10000014305115,"connectEnd":139.10000014305115,"connectStart":139.10000014305115,"domainLookupEnd":139.10000014305115,"domainLookupStart":139.10000014305115,"fetchStart":139.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":139.10000014305115,"responseEnd":590.7000000476837,"responseStart":590.7000000476837,"secureConnectionStart":139.10000014305115},{"duration":451.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":139.20000004768372,"connectEnd":139.20000004768372,"connectStart":139.20000004768372,"domainLookupEnd":139.20000004768372,"domainLookupStart":139.20000004768372,"fetchStart":139.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":139.20000004768372,"responseEnd":591.1000001430511,"responseStart":591.1000001430511,"secureConnectionStart":139.20000004768372},{"duration":453,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":139.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":139.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":592.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":452.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":139.40000009536743,"connectEnd":139.40000009536743,"connectStart":139.40000009536743,"domainLookupEnd":139.40000009536743,"domainLookupStart":139.40000009536743,"fetchStart":139.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":139.40000009536743,"responseEnd":591.6000001430511,"responseStart":591.6000001430511,"secureConnectionStart":139.40000009536743},{"duration":452.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":139.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":139.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":592.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":452.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":139.60000014305115,"connectEnd":139.60000014305115,"connectStart":139.60000014305115,"domainLookupEnd":139.60000014305115,"domainLookupStart":139.60000014305115,"fetchStart":139.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":139.60000014305115,"responseEnd":592.1000001430511,"responseStart":592.1000001430511,"secureConnectionStart":139.60000014305115},{"duration":465.39999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":145.10000014305115,"connectEnd":145.10000014305115,"connectStart":145.10000014305115,"domainLookupEnd":145.10000014305115,"domainLookupStart":145.10000014305115,"fetchStart":145.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":145.10000014305115,"responseEnd":610.5,"responseStart":610.5,"secureConnectionStart":145.10000014305115},{"duration":970.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":145.10000014305115,"connectEnd":145.10000014305115,"connectStart":145.10000014305115,"domainLookupEnd":145.10000014305115,"domainLookupStart":145.10000014305115,"fetchStart":145.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":145.10000014305115,"responseEnd":1115.2000000476837,"responseStart":1115.2000000476837,"secureConnectionStart":145.10000014305115}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":3,"responseStart":131,"responseEnd":141,"domLoading":137,"domInteractive":1134,"domContentLoadedEventStart":1134,"domContentLoadedEventEnd":1168,"domComplete":2181,"loadEventStart":2181,"loadEventEnd":2183,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1116.8000001907349},{"name":"bigPipe.sidebar-id.end","time":1117.6000001430511},{"name":"bigPipe.activity-panel-pipe-id.start","time":1117.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1120},{"name":"activityTabFullyLoaded","time":1173.9000000953674}],"measures":[],"correlationId":"b6288d320ef6c2","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":79,"dbReadsTimeInMs":12,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}