I get complete table deadlock with simple test case like below:
1. setup default two-node galera cluster on the same host, e.g. on ports 3314 and 3315
2. Create table:
create table test.t select 1;
3. Start following concurrent load:
( for i1 in {1..100000} ; do mysql -h127.0.0.1 -P3314 -e "insert into t select $i1" test || : ; done ) &> /dev/null &
|
( for i1 in {1..100000} ; do mysql -h127.0.0.1 -P3315 -e "insert into t select $i1" test || : ; done ) &> /dev/null &
|
|
( for k1 in {1..1000}; do sleep 10; mysql -h127.0.0.1 -P3314 -e "optimize table t" test & wait ; done ) &>/dev/null &
|
( for k1 in {1..1000}; do sleep 10; mysql -h127.0.0.1 -P3315 -e "optimize table t" test & wait ; done ) &>/dev/null &
|
|
|
while true ; do
|
mysql -h127.0.0.1 -P3314 -e 'show processlist'
|
mysql -h127.0.0.1 -P3315 -e 'show processlist'
|
mysql -h127.0.0.1 -P3314 -e 'select count(*) from t' test
|
mysql -h127.0.0.1 -P3315 -e 'select count(*) from t' test
|
sleep 2
|
done
|
The cluster usually hangs up within 1 min, this is what observed:
(11:17 sql) > mysql -h 127.0.0.1 -P 3314 -uroot -e 'show processlist'
|
+-----+-------------+-----------------+------+---------+------+-------------------------+--------------------------+----------+
|
| Id | User | Host | db | Command | Time | State | Info | Progress |
|
+-----+-------------+-----------------+------+---------+------+-------------------------+--------------------------+----------+
|
| 1 | system user | | test | Sleep | 748 | Waiting for table flush | optimize table t | 0.000 |
|
| 2 | system user | | NULL | Sleep | 815 | wsrep aborter idle | NULL | 0.000 |
|
| 518 | a | localhost:37078 | test | Query | 748 | query end | insert into t select 487 | 0.000 |
|
| 519 | a | localhost:37080 | test | Query | 748 | Waiting for table flush | select count(*) from t | 0.000 |
|
| 520 | a | localhost:37122 | test | Query | 738 | checking permissions | optimize table t | 0.000 |
|
| 526 | root | localhost:38382 | NULL | Query | 0 | init | show processlist | 0.000 |
|
+-----+-------------+-----------------+------+---------+------+-------------------------+--------------------------+----------+
|
(11:17 sql) > mysql -h 127.0.0.1 -P 3315 -uroot -e 'show processlist'
|
+-----+-------------+-----------------+------+---------+------+----------------------+--------------------------+----------+
|
| Id | User | Host | db | Command | Time | State | Info | Progress |
|
+-----+-------------+-----------------+------+---------+------+----------------------+--------------------------+----------+
|
| 1 | system user | | NULL | Sleep | 799 | wsrep aborter idle | NULL | 0.000 |
|
| 2 | system user | | NULL | Sleep | 748 | committed 992 | NULL | 0.000 |
|
| 517 | a | localhost:46558 | test | Query | 748 | query end | insert into t select 505 | 0.000 |
|
| 518 | a | localhost:46562 | test | Query | 738 | checking permissions | optimize table t | 0.000 |
|
| 524 | root | localhost:47822 | NULL | Query | 0 | init | show processlist | 0.000 |
|
+-----+-------------+-----------------+------+---------+------+----------------------+--------------------------+----------+
|
It is kid of strange to me that I cannot reproduce the problem with alter command below instead of OPTIMIZE:
alter table t engine=innodb, algorithm=copy
{"report":{"fcp":1637.2999997138977,"ttfb":412.09999990463257,"pageVisibility":"visible","entityId":62380,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"e17f34ff-03dc-4153-a044-d67e5b4f4731","navigationType":0,"readyForUser":1739.1999998092651,"redirectCount":0,"resourceLoadedEnd":1413.0999999046326,"resourceLoadedStart":419.19999980926514,"resourceTiming":[{"duration":427.19999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":419.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":419.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":846.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":428,"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":419.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":419.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":847.5,"responseStart":0,"secureConnectionStart":0},{"duration":762.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":419.7999997138977,"connectEnd":419.7999997138977,"connectStart":419.7999997138977,"domainLookupEnd":419.7999997138977,"domainLookupStart":419.7999997138977,"fetchStart":419.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":850.6999998092651,"responseEnd":1182,"responseStart":893.7999997138977,"secureConnectionStart":419.7999997138977},{"duration":905.1000003814697,"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":419.8999996185303,"connectEnd":419.8999996185303,"connectStart":419.8999996185303,"domainLookupEnd":419.8999996185303,"domainLookupStart":419.8999996185303,"fetchStart":419.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":850.5,"responseEnd":1325,"responseStart":890.0999999046326,"secureConnectionStart":419.8999996185303},{"duration":475.69999980926514,"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":420.09999990463257,"connectEnd":420.09999990463257,"connectStart":420.09999990463257,"domainLookupEnd":420.09999990463257,"domainLookupStart":420.09999990463257,"fetchStart":420.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":851.0999999046326,"responseEnd":895.7999997138977,"responseStart":892.5,"secureConnectionStart":420.09999990463257},{"duration":479.7000002861023,"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":420.2999997138977,"connectEnd":420.2999997138977,"connectStart":420.2999997138977,"domainLookupEnd":420.2999997138977,"domainLookupStart":420.2999997138977,"fetchStart":420.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":851.5,"responseEnd":900,"responseStart":896.0999999046326,"secureConnectionStart":420.2999997138977},{"duration":481,"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":420.3999996185303,"connectEnd":420.3999996185303,"connectStart":420.3999996185303,"domainLookupEnd":420.3999996185303,"domainLookupStart":420.3999996185303,"fetchStart":420.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":851.6999998092651,"responseEnd":901.3999996185303,"responseStart":896.8999996185303,"secureConnectionStart":420.3999996185303},{"duration":428.19999980926514,"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":420.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":420.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":848.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":484.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":420.8999996185303,"connectEnd":420.8999996185303,"connectStart":420.8999996185303,"domainLookupEnd":420.8999996185303,"domainLookupStart":420.8999996185303,"fetchStart":420.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":852,"responseEnd":905.0999999046326,"responseStart":903.0999999046326,"secureConnectionStart":420.8999996185303},{"duration":428.2999997138977,"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":421,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":421,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":849.2999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":483.90000009536743,"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":421.09999990463257,"connectEnd":421.09999990463257,"connectStart":421.09999990463257,"domainLookupEnd":421.09999990463257,"domainLookupStart":421.09999990463257,"fetchStart":421.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":852.1999998092651,"responseEnd":905,"responseStart":902,"secureConnectionStart":421.09999990463257},{"duration":899.4000000953674,"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":422.09999990463257,"connectEnd":422.09999990463257,"connectStart":422.09999990463257,"domainLookupEnd":422.09999990463257,"domainLookupStart":422.09999990463257,"fetchStart":422.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":1161.8999996185303,"responseEnd":1321.5,"responseStart":1319.3999996185303,"secureConnectionStart":422.09999990463257},{"duration":991,"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":422.09999990463257,"connectEnd":422.09999990463257,"connectStart":422.09999990463257,"domainLookupEnd":422.09999990463257,"domainLookupStart":422.09999990463257,"fetchStart":422.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":1399,"responseEnd":1413.0999999046326,"responseStart":1411.7999997138977,"secureConnectionStart":422.09999990463257},{"duration":234.7000002861023,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1317.3999996185303,"connectEnd":1317.3999996185303,"connectStart":1317.3999996185303,"domainLookupEnd":1317.3999996185303,"domainLookupStart":1317.3999996185303,"fetchStart":1317.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":1517,"responseEnd":1552.0999999046326,"responseStart":1550.7999997138977,"secureConnectionStart":1317.3999996185303},{"duration":343.19999980926514,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1579.5999999046326,"connectEnd":1579.5999999046326,"connectStart":1579.5999999046326,"domainLookupEnd":1579.5999999046326,"domainLookupStart":1579.5999999046326,"fetchStart":1579.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1876,"responseEnd":1922.7999997138977,"responseStart":1907.5,"secureConnectionStart":1579.5999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":215,"responseStart":412,"responseEnd":415,"domLoading":416,"domInteractive":1936,"domContentLoadedEventStart":1936,"domContentLoadedEventEnd":2008,"domComplete":2822,"loadEventStart":2822,"loadEventEnd":2823,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1899.1999998092651},{"name":"bigPipe.sidebar-id.end","time":1899.8999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":1900.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":1903.0999999046326},{"name":"activityTabFullyLoaded","time":2032.5999999046326}],"measures":[],"correlationId":"4aa5edaac462d9","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":112,"dbReadsTimeInMs":15,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
See also
MDEV-10245, which is also about concurrent OPTIMIZE causing a deadlock. Stack traces are different, though.