Currently, mysql_inplace_alter_table() in sql/sql_table.cc does the following:
// Upgrade to EXCLUSIVE before commit.
|
if (wait_while_table_is_used(thd, table, HA_EXTRA_PREPARE_FOR_RENAME))
|
goto rollback;
|
During this time, the ALTER TABLE thread is not doing anything useful. If this is a table-rebuilding ALTER TABLE operation (something that cannot be done as ALGORITHM=INSTANT (MDEV-13134) until parts of MDEV-11424 are finished, or if rebuild was requested by specifying the FORCE keyword), then it would make sense to let InnoDB invoke row_log_table_apply() after a request to upgrade the lock has been submitted.
I would like to consider adding a variant of the ha_innobase::inplace_alter_table() call that would let InnoDB invoke the next batch of row_log_table_apply(). Once this call returns, the caller would check if the ALTER TABLE operation was killed or the MDL upgrade timed out, or the MDL was granted. As long as the lock wait should continue, the storage engine would be called again to do useful work during the wait.
{"report":{"fcp":1270.0999999046326,"ttfb":205,"pageVisibility":"visible","entityId":66469,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"a8429156-70a3-4016-8fd2-19b1aa87f562","navigationType":0,"readyForUser":1382.5999999046326,"redirectCount":0,"resourceLoadedEnd":1876.0999999046326,"resourceLoadedStart":212.09999990463257,"resourceTiming":[{"duration":337.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":212.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":212.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":549.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":337.5,"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":212.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":212.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":550,"responseStart":0,"secureConnectionStart":0},{"duration":346,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":212.69999980926514,"connectEnd":212.69999980926514,"connectStart":212.69999980926514,"domainLookupEnd":212.69999980926514,"domainLookupStart":212.69999980926514,"fetchStart":212.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":212.69999980926514,"responseEnd":558.6999998092651,"responseStart":558.6999998092651,"secureConnectionStart":212.69999980926514},{"duration":444,"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":212.80000019073486,"connectEnd":212.80000019073486,"connectStart":212.80000019073486,"domainLookupEnd":212.80000019073486,"domainLookupStart":212.80000019073486,"fetchStart":212.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":212.80000019073486,"responseEnd":656.8000001907349,"responseStart":656.8000001907349,"secureConnectionStart":212.80000019073486},{"duration":447.90000009536743,"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":213.09999990463257,"connectEnd":213.09999990463257,"connectStart":213.09999990463257,"domainLookupEnd":213.09999990463257,"domainLookupStart":213.09999990463257,"fetchStart":213.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":213.09999990463257,"responseEnd":661,"responseStart":661,"secureConnectionStart":213.09999990463257},{"duration":448.19999980926514,"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":213.30000019073486,"connectEnd":213.30000019073486,"connectStart":213.30000019073486,"domainLookupEnd":213.30000019073486,"domainLookupStart":213.30000019073486,"fetchStart":213.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":213.30000019073486,"responseEnd":661.5,"responseStart":661.5,"secureConnectionStart":213.30000019073486},{"duration":448.40000009536743,"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":213.40000009536743,"connectEnd":213.40000009536743,"connectStart":213.40000009536743,"domainLookupEnd":213.40000009536743,"domainLookupStart":213.40000009536743,"fetchStart":213.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":213.40000009536743,"responseEnd":661.8000001907349,"responseStart":661.8000001907349,"secureConnectionStart":213.40000009536743},{"duration":503.40000009536743,"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":213.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":213.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":717,"responseStart":0,"secureConnectionStart":0},{"duration":448.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":213.80000019073486,"connectEnd":213.80000019073486,"connectStart":213.80000019073486,"domainLookupEnd":213.80000019073486,"domainLookupStart":213.80000019073486,"fetchStart":213.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":213.80000019073486,"responseEnd":662.3000001907349,"responseStart":662.3000001907349,"secureConnectionStart":213.80000019073486},{"duration":503.30000019073486,"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":214,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":214,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":717.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":448.80000019073486,"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":214.09999990463257,"connectEnd":214.09999990463257,"connectStart":214.09999990463257,"domainLookupEnd":214.09999990463257,"domainLookupStart":214.09999990463257,"fetchStart":214.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":214.09999990463257,"responseEnd":662.9000000953674,"responseStart":662.9000000953674,"secureConnectionStart":214.09999990463257},{"duration":1659.6999998092651,"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":215.80000019073486,"connectEnd":215.80000019073486,"connectStart":215.80000019073486,"domainLookupEnd":215.80000019073486,"domainLookupStart":215.80000019073486,"fetchStart":215.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":215.80000019073486,"responseEnd":1875.5,"responseStart":1875.5,"secureConnectionStart":215.80000019073486},{"duration":1660.2999997138977,"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":215.80000019073486,"connectEnd":215.80000019073486,"connectStart":215.80000019073486,"domainLookupEnd":215.80000019073486,"domainLookupStart":215.80000019073486,"fetchStart":215.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":215.80000019073486,"responseEnd":1876.0999999046326,"responseStart":1876.0999999046326,"secureConnectionStart":215.80000019073486},{"duration":99.80000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":768.1999998092651,"connectEnd":768.1999998092651,"connectStart":768.1999998092651,"domainLookupEnd":768.1999998092651,"domainLookupStart":768.1999998092651,"fetchStart":768.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":768.1999998092651,"responseEnd":868,"responseStart":868,"secureConnectionStart":768.1999998092651}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":30,"responseStart":205,"responseEnd":207,"domLoading":209,"domInteractive":1913,"domContentLoadedEventStart":1913,"domContentLoadedEventEnd":1967,"domComplete":3015,"loadEventStart":3015,"loadEventEnd":3016,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1879.9000000953674},{"name":"bigPipe.sidebar-id.end","time":1882},{"name":"bigPipe.activity-panel-pipe-id.start","time":1882.3000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1885.5},{"name":"activityTabFullyLoaded","time":1987.9000000953674}],"measures":[],"correlationId":"cc179386a510ab","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":115,"dbReadsTimeInMs":14,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The row_log_table_apply() is actually invoked while holding both dict_sys->mutex and dict_operation_lock. If there is a lot of log to apply, this may actually cause InnoDB to crash.
I collaborated with a user on the IRC #maria channel who reported a crash in MySQL 5.7.21 with the following kind of test case:
2018-03-23T15:19:10.847595Z 0 [ERROR] [FATAL] InnoDB: Semaphore wait has lasted > 600 seconds. We intentionally crash the server because it appears to be hung.