When issuing a CREATE TABLE .... SELECT, the information schema becomes unusable because it gets metadata-locked. This is creating issues to monitoring systems that normally query information_schema for monitoring purposes (queries stack up in processlist waiting for metadata lock).
How to reproduce:
In terminal 1:
create table test (id int not null primary key default 0) select 1, sleep(100);
|
In termninal 2:
SELECT SUM((DATA_LENGTH+INDEX_LENGTH)) FROM INFORMATION_SCHEMA.TABLES;
|
- relates to
-
MDEV-21602
CREATE TABLE…PRIMARY KEY…SELECT workaround causes DROP TABLE to ignore locks
-
-
Closed
{"report":{"fcp":1185.4000000953674,"ttfb":224.40000009536743,"pageVisibility":"visible","entityId":83551,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"9392af5d-4059-4ec8-b04f-71c85cf4b1b3","navigationType":0,"readyForUser":1266.1000001430511,"redirectCount":0,"resourceLoadedEnd":906.9000000953674,"resourceLoadedStart":233.70000004768372,"resourceTiming":[{"duration":306,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":233.70000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":233.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":539.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":306.2999999523163,"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":234,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":234,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":540.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":507.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":234.20000004768372,"connectEnd":234.20000004768372,"connectStart":234.20000004768372,"domainLookupEnd":234.20000004768372,"domainLookupStart":234.20000004768372,"fetchStart":234.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":543.2999999523163,"responseEnd":741.7999999523163,"responseStart":557.2999999523163,"secureConnectionStart":234.20000004768372},{"duration":657.9000000953674,"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":234.70000004768372,"connectEnd":234.70000004768372,"connectStart":234.70000004768372,"domainLookupEnd":234.70000004768372,"domainLookupStart":234.70000004768372,"fetchStart":234.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":544.7000000476837,"responseEnd":892.6000001430511,"responseStart":566.6000001430511,"secureConnectionStart":234.70000004768372},{"duration":326.5,"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":234.79999995231628,"connectEnd":234.79999995231628,"connectStart":234.79999995231628,"domainLookupEnd":234.79999995231628,"domainLookupStart":234.79999995231628,"fetchStart":234.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":544.9000000953674,"responseEnd":561.2999999523163,"responseStart":560.2000000476837,"secureConnectionStart":234.79999995231628},{"duration":328.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":234.90000009536743,"connectEnd":234.90000009536743,"connectStart":234.90000009536743,"domainLookupEnd":234.90000009536743,"domainLookupStart":234.90000009536743,"fetchStart":234.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":545.2999999523163,"responseEnd":563.5,"responseStart":562,"secureConnectionStart":234.90000009536743},{"duration":328.2000000476837,"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":235,"connectEnd":235,"connectStart":235,"domainLookupEnd":235,"domainLookupStart":235,"fetchStart":235,"redirectEnd":0,"redirectStart":0,"requestStart":545.7000000476837,"responseEnd":563.2000000476837,"responseStart":561.5,"secureConnectionStart":235},{"duration":310.89999985694885,"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":235.10000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":235.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":546,"responseStart":0,"secureConnectionStart":0},{"duration":334.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":235.20000004768372,"connectEnd":235.20000004768372,"connectStart":235.20000004768372,"domainLookupEnd":235.20000004768372,"domainLookupStart":235.20000004768372,"fetchStart":235.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":548.5,"responseEnd":570.1000001430511,"responseStart":569.1000001430511,"secureConnectionStart":235.20000004768372},{"duration":311.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":235.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":235.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":547.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":343.59999990463257,"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":235.40000009536743,"connectEnd":235.40000009536743,"connectStart":235.40000009536743,"domainLookupEnd":235.40000009536743,"domainLookupStart":235.40000009536743,"fetchStart":235.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":549.6000001430511,"responseEnd":579,"responseStart":570.2999999523163,"secureConnectionStart":235.40000009536743},{"duration":668.0999999046326,"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":238.10000014305115,"connectEnd":238.10000014305115,"connectStart":238.10000014305115,"domainLookupEnd":238.10000014305115,"domainLookupStart":238.10000014305115,"fetchStart":238.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":680.6000001430511,"responseEnd":906.2000000476837,"responseStart":900.1000001430511,"secureConnectionStart":238.10000014305115},{"duration":668.7000000476837,"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":238.20000004768372,"connectEnd":238.20000004768372,"connectStart":238.20000004768372,"domainLookupEnd":238.20000004768372,"domainLookupStart":238.20000004768372,"fetchStart":238.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":789.1000001430511,"responseEnd":906.9000000953674,"responseStart":900.7999999523163,"secureConnectionStart":238.20000004768372},{"duration":204.89999985694885,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":898.1000001430511,"connectEnd":898.1000001430511,"connectStart":898.1000001430511,"domainLookupEnd":898.1000001430511,"domainLookupStart":898.1000001430511,"fetchStart":898.1000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":1070.6000001430511,"responseEnd":1103,"responseStart":1102.1000001430511,"secureConnectionStart":898.1000001430511}],"fetchStart":0,"domainLookupStart":46,"domainLookupEnd":64,"connectStart":64,"connectEnd":84,"secureConnectionStart":73,"requestStart":85,"responseStart":224,"responseEnd":237,"domLoading":228,"domInteractive":1320,"domContentLoadedEventStart":1320,"domContentLoadedEventEnd":1370,"domComplete":1786,"loadEventStart":1786,"loadEventEnd":1787,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1297.4000000953674},{"name":"bigPipe.sidebar-id.end","time":1298.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.start","time":1298.4000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":1300.2000000476837},{"name":"activityTabFullyLoaded","time":1390.1000001430511}],"measures":[],"correlationId":"d54c9d735f81b6","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":78,"dbReadsTimeInMs":13,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
I would guess that CREATE TABLE…SELECT is unnecessarily holding MDL_EXCLUSIVE on the table name for the duration of the entire operation. That ought to block SHOW TABLES as well.
Related to this, we have another problem with CREATE TABLE…SELECT, which requires a problematic work-around in InnoDB, as mentioned in
MDEV-21602. I think that we should consider the following fix:MDEV-11415for ALTER TABLE…ALGORITHM=COPY.