Type:
Bug
Priority:
Critical
Resolution:
Fixed
Affects Version/s:
N/A
InnoDB fails to drop the intermediate table during DDL using copy algorithm.
Failure happens due to lock wait while acquiring the lock on stats table.
So it leads to orphaned intermediate table name in InnoDB dictionary.
Consecutive alter tries to rename the source table to intermediate table
and fails with DUPLICATE key error.
Test case:
=========
--source include/have_innodb.inc
set global innodb_lock_wait_timeout=0;
create table t1(f1 int not null primary key,
f2 int not null, index idx(f2))engine=innodb;
insert into t1 values(1, 1);
set DEBUG_SYNC="before_delete_table_stats SIGNAL con1_wait WAIT_FOR con1_signal";
send alter ignore table t1 drop primary key, lock=shared, algorithm=copy;
connect(con1,localhost,root,,,);
SET DEBUG_SYNC="now WAIT_FOR con1_wait";
begin;
SELECT * FROM mysql.innodb_table_stats FOR UPDATE;
SET DEBUG_SYNC="now SIGNAL con1_signal";
connection default;
reap;
set DEBUG_SYNC="now SIGNAL con1_skip";
connection con1;
set DEBUG_SYNC="now WAIT_FOR con1_skip";
commit;
set DEBUG_SYNC="now SIGNAL con1_finish";
connection default;
set DEBUG_SYNC="now WAIT_FOR con1_finish";
disconnect con1;
alter ignore table t1 rename key if exists idx to idx1, algorithm=copy;
drop table t1;
The following patch is to demonstrate the problem:
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index e431e0499c4..34010ea9899 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -13488,6 +13488,8 @@ int ha_innobase::delete_table(const char *name)
}
#endif
+ DEBUG_SYNC(thd, "before_delete_table_stats");
+
if (err == DB_SUCCESS && dict_stats_is_persistent_enabled(table) &&
!table->is_stats_table())
{"report":{"fcp":685.5999999046326,"ttfb":169.70000004768372,"pageVisibility":"visible","entityId":103671,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"64596995-2b0b-413d-8bf8-1991f1e17789","navigationType":0,"readyForUser":809.4000000953674,"redirectCount":0,"resourceLoadedEnd":741.5999999046326,"resourceLoadedStart":177,"resourceTiming":[{"duration":17.299999952316284,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":177,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":177,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":194.29999995231628,"responseStart":0,"secureConnectionStart":0},{"duration":23.100000143051147,"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":177.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":177.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":200.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":85.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":177.5,"connectEnd":177.5,"connectStart":177.5,"domainLookupEnd":177.5,"domainLookupStart":177.5,"fetchStart":177.5,"redirectEnd":0,"redirectStart":0,"requestStart":177.5,"responseEnd":262.7000000476837,"responseStart":262.7000000476837,"secureConnectionStart":177.5},{"duration":175.20000004768372,"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":177.5,"connectEnd":177.5,"connectStart":177.5,"domainLookupEnd":177.5,"domainLookupStart":177.5,"fetchStart":177.5,"redirectEnd":0,"redirectStart":0,"requestStart":177.5,"responseEnd":352.7000000476837,"responseStart":352.7000000476837,"secureConnectionStart":177.5},{"duration":179.09999990463257,"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":177.70000004768372,"connectEnd":177.70000004768372,"connectStart":177.70000004768372,"domainLookupEnd":177.70000004768372,"domainLookupStart":177.70000004768372,"fetchStart":177.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":177.70000004768372,"responseEnd":356.7999999523163,"responseStart":356.7999999523163,"secureConnectionStart":177.70000004768372},{"duration":179.70000004768372,"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":177.79999995231628,"connectEnd":177.79999995231628,"connectStart":177.79999995231628,"domainLookupEnd":177.79999995231628,"domainLookupStart":177.79999995231628,"fetchStart":177.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":177.79999995231628,"responseEnd":357.5,"responseStart":357.40000009536743,"secureConnectionStart":177.79999995231628},{"duration":182.29999995231628,"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":178,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":178,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":360.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":180.09999990463257,"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":178,"connectEnd":178,"connectStart":178,"domainLookupEnd":178,"domainLookupStart":178,"fetchStart":178,"redirectEnd":0,"redirectStart":0,"requestStart":178,"responseEnd":358.09999990463257,"responseStart":358.09999990463257,"secureConnectionStart":178},{"duration":182.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":178.09999990463257,"connectEnd":178.09999990463257,"connectStart":178.09999990463257,"domainLookupEnd":178.09999990463257,"domainLookupStart":178.09999990463257,"fetchStart":178.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":178.09999990463257,"responseEnd":360.2000000476837,"responseStart":360.2000000476837,"secureConnectionStart":178.09999990463257},{"duration":184.60000014305115,"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":178.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":178.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":362.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":184.29999995231628,"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":178.29999995231628,"connectEnd":178.29999995231628,"connectStart":178.29999995231628,"domainLookupEnd":178.29999995231628,"domainLookupStart":178.29999995231628,"fetchStart":178.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":178.29999995231628,"responseEnd":362.59999990463257,"responseStart":362.59999990463257,"secureConnectionStart":178.29999995231628},{"duration":485.09999990463257,"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":179.20000004768372,"connectEnd":179.20000004768372,"connectStart":179.20000004768372,"domainLookupEnd":179.20000004768372,"domainLookupStart":179.20000004768372,"fetchStart":179.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":179.20000004768372,"responseEnd":664.2999999523163,"responseStart":664.2999999523163,"secureConnectionStart":179.20000004768372},{"duration":486,"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":179.20000004768372,"connectEnd":179.20000004768372,"connectStart":179.20000004768372,"domainLookupEnd":179.20000004768372,"domainLookupStart":179.20000004768372,"fetchStart":179.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":179.20000004768372,"responseEnd":665.2000000476837,"responseStart":665.2000000476837,"secureConnectionStart":179.20000004768372},{"duration":213.29999995231628,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":418.2999999523163,"connectEnd":418.2999999523163,"connectStart":418.2999999523163,"domainLookupEnd":418.2999999523163,"domainLookupStart":418.2999999523163,"fetchStart":418.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":418.2999999523163,"responseEnd":631.5999999046326,"responseStart":631.5999999046326,"secureConnectionStart":418.2999999523163},{"duration":38.89999985694885,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":678.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":678.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":717.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":44.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":696.9000000953674,"connectEnd":696.9000000953674,"connectStart":696.9000000953674,"domainLookupEnd":696.9000000953674,"domainLookupStart":696.9000000953674,"fetchStart":696.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":696.9000000953674,"responseEnd":741.5999999046326,"responseStart":741.5999999046326,"secureConnectionStart":696.9000000953674}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":27,"responseStart":170,"responseEnd":175,"domLoading":174,"domInteractive":885,"domContentLoadedEventStart":886,"domContentLoadedEventEnd":942,"domComplete":1805,"loadEventStart":1805,"loadEventEnd":1806,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":861.0999999046326},{"name":"bigPipe.sidebar-id.end","time":861.7999999523163},{"name":"bigPipe.activity-panel-pipe-id.start","time":862},{"name":"bigPipe.activity-panel-pipe-id.end","time":864.5},{"name":"activityTabFullyLoaded","time":949.4000000953674}],"measures":[],"correlationId":"dc659fa7f3457b","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":82,"dbReadsTimeInMs":12,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}