MariaDB [lfdb]> create table t5 as select * from t1;
^CCtrl-C – query killed. Continuing normally.
ERROR 1317 (70100): Query execution was interrupted
MariaDB [lfdb]> create table t5 as select * from t1;
ERROR 1813 (HY000): Tablespace for table '`lfdb`.`t5`' exists. Please DISCARD the tablespace before IMPORT
try to delete the tablespace
[root@19c lfdb]# rm t5.ibd
rm: remove regular file ‘t5.ibd’? y
[root@19c lfdb]# ls
db.opt t1.frm t1.ibd t2.frm t2.ibd t3.frm t3.ibd t4.frm t4.ibd
try to recreate the table
MariaDB [lfdb]> truncate table t5;
ERROR 1146 (42S02): Table 'lfdb.t5' doesn't exist
MariaDB [lfdb]> create table t5 as select * from t1;
ERROR 1050 (42S01): Table '`lfdb`.`t5`' already exists
MariaDB [lfdb]> drop table t5;
ERROR 1051 (42S02): Unknown table 'lfdb.t5'
why? and how do i fix this?
Thanks.
- is caused by
-
MDEV-16515
InnoDB: Failing assertion: ++retries < 10000 in file dict0dict.cc line 2737
-
-
Closed
{"report":{"fcp":1166.5,"ttfb":378.19999980926514,"pageVisibility":"visible","entityId":77653,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"6c02d078-989b-4a67-b1c9-155917a984f2","navigationType":0,"readyForUser":1238.8000001907349,"redirectCount":0,"resourceLoadedEnd":825.1999998092651,"resourceLoadedStart":383.69999980926514,"resourceTiming":[{"duration":32.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":383.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":383.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":416,"responseStart":0,"secureConnectionStart":0},{"duration":36.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":384,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":384,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":420.30000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":251.10000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":384.19999980926514,"connectEnd":384.19999980926514,"connectStart":384.19999980926514,"domainLookupEnd":384.19999980926514,"domainLookupStart":384.19999980926514,"fetchStart":384.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":421.19999980926514,"responseEnd":635.3000001907349,"responseStart":437.0999994277954,"secureConnectionStart":384.19999980926514},{"duration":440.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":384.30000019073486,"connectEnd":384.30000019073486,"connectStart":384.30000019073486,"domainLookupEnd":384.30000019073486,"domainLookupStart":384.30000019073486,"fetchStart":384.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":421.5,"responseEnd":825.1999998092651,"responseStart":444.8999996185303,"secureConnectionStart":384.30000019073486},{"duration":52.5,"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":384.5,"connectEnd":384.5,"connectStart":384.5,"domainLookupEnd":384.5,"domainLookupStart":384.5,"fetchStart":384.5,"redirectEnd":0,"redirectStart":0,"requestStart":422.0999994277954,"responseEnd":437,"responseStart":434.5,"secureConnectionStart":384.5},{"duration":53.39999961853027,"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":384.69999980926514,"connectEnd":384.69999980926514,"connectStart":384.69999980926514,"domainLookupEnd":384.69999980926514,"domainLookupStart":384.69999980926514,"fetchStart":384.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":422.3999996185303,"responseEnd":438.0999994277954,"responseStart":435.3999996185303,"secureConnectionStart":384.69999980926514},{"duration":61.90000057220459,"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":384.8999996185303,"connectEnd":384.8999996185303,"connectStart":384.8999996185303,"domainLookupEnd":384.8999996185303,"domainLookupStart":384.8999996185303,"fetchStart":384.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":422.5999994277954,"responseEnd":446.80000019073486,"responseStart":443.80000019073486,"secureConnectionStart":384.8999996185303},{"duration":37.39999961853027,"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":385,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":385,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":422.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":64.79999923706055,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":385.30000019073486,"connectEnd":385.30000019073486,"connectStart":385.30000019073486,"domainLookupEnd":385.30000019073486,"domainLookupStart":385.30000019073486,"fetchStart":385.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":424.80000019073486,"responseEnd":450.0999994277954,"responseStart":447.30000019073486,"secureConnectionStart":385.30000019073486},{"duration":38,"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":385.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":385.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":423.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":66.30000019073486,"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":385.5999994277954,"connectEnd":385.5999994277954,"connectStart":385.5999994277954,"domainLookupEnd":385.5999994277954,"domainLookupStart":385.5999994277954,"fetchStart":385.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":430.3999996185303,"responseEnd":451.8999996185303,"responseStart":450.19999980926514,"secureConnectionStart":385.5999994277954},{"duration":409.5,"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":391.8999996185303,"connectEnd":391.8999996185303,"connectStart":391.8999996185303,"domainLookupEnd":391.8999996185303,"domainLookupStart":391.8999996185303,"fetchStart":391.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":505.0999994277954,"responseEnd":801.3999996185303,"responseStart":795.0999994277954,"secureConnectionStart":391.8999996185303},{"duration":414.0999994277954,"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":393.80000019073486,"connectEnd":393.80000019073486,"connectStart":393.80000019073486,"domainLookupEnd":393.80000019073486,"domainLookupStart":393.80000019073486,"fetchStart":393.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":590.5,"responseEnd":807.8999996185303,"responseStart":801.6999998092651,"secureConnectionStart":393.80000019073486},{"duration":117.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":776.3999996185303,"connectEnd":776.3999996185303,"connectStart":776.3999996185303,"domainLookupEnd":776.3999996185303,"domainLookupStart":776.3999996185303,"fetchStart":776.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":857,"responseEnd":893.8999996185303,"responseStart":892.8000001907349,"secureConnectionStart":776.3999996185303}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":192,"responseStart":378,"responseEnd":393,"domLoading":382,"domInteractive":1365,"domContentLoadedEventStart":1365,"domContentLoadedEventEnd":1427,"domComplete":2338,"loadEventStart":2338,"loadEventEnd":2338,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1277},{"name":"bigPipe.sidebar-id.end","time":1277.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1278},{"name":"bigPipe.activity-panel-pipe-id.end","time":1282.5},{"name":"activityTabFullyLoaded","time":1443.1999998092651}],"measures":[],"correlationId":"9f917e6ecc1cc","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":112,"dbReadsTimeInMs":15,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
I can repeat with the following test, on both mariadb-10.3.14 and the latest 10.3 development version (ef44ec4afaa):
--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/count_sessions.inc
let $wait_condition=
--source include/wait_condition.inc
KILL QUERY @id;
disconnect con1;
--error ER_QUERY_INTERRUPTED
reap;
The CREATE TABLE…SELECT is internally implemented as two transactions, performing CREATE TABLE and INSERT…SELECT. If the operation is interrupted at the CREATE TABLE phase, then it will be rolled back properly. If it is interrupted during the INSERT…SELECT, then apparently the .frm file will be deleted, but the table will not be dropped inside InnoDB. We appear to be missing error handling (DROP TABLE) if the operation was interrupted. Such handling does exists for some errors.
In MariaDB 5.5, there is no SEQUENCE engine, so I tried a different test:
--source include/have_innodb.inc
--source include/count_sessions.inc
let $wait_condition=
--source include/wait_condition.inc
KILL QUERY @id;
disconnect con1;
--error ER_QUERY_INTERRUPTED
reap;
It looks like when the execution is interrupted while executing the SLEEP function, the table will be dropped correctly (in both 10.3 and 5.5, which I tested). Here is the call stack for dropping the table in 5.5:
5.5 f90040fd9ccb99cb4541d181a7052c37dc38decb
#0 ha_innobase::delete_table (this=0x7fffc4015b18,
name=0x7ffff43abac0 "./test/t1")
at /mariadb/5.5/storage/xtradb/handler/ha_innodb.cc:8746
#1 0x0000555555af12de in handler::ha_delete_table (this=0x7fffc4015b18,
name=0x7ffff43abac0 "./test/t1") at /mariadb/5.5/sql/handler.cc:3724
#2 0x0000555555aee3eb in ha_delete_table (thd=0x555557c07090,
table_type=0x555556fe7e30, path=0x7ffff43abac0 "./test/t1",
db=0x7fffc40077f8 "test", alias=0x7fffc40071e8 "t1",
generate_warning=false) at /mariadb/5.5/sql/handler.cc:2156
#3 0x00005555559d0c67 in quick_rm_table (base=0x555556fe7e30,
db=0x7fffc40077f8 "test", table_name=0x7fffc40071e8 "t1", flags=0)
at /mariadb/5.5/sql/sql_table.cc:2491
#4 0x00005555558d9fb2 in drop_open_table (thd=0x555557c07090,
table=0x7fffc4017ad0, db_name=0x7fffc40077f8 "test",
table_name=0x7fffc40071e8 "t1") at /mariadb/5.5/sql/sql_base.cc:2410
#5 0x0000555555924a14 in select_create::abort_result_set (
this=0x7fffc40082d8) at /mariadb/5.5/sql/sql_insert.cc:4318
#6 0x0000555555966ea2 in handle_select (thd=0x555557c07090,
lex=0x555557c0a308, result=0x7fffc40082d8, setup_tables_done_option=0)
at /mariadb/5.5/sql/sql_select.cc:330
#7 0x0000555555939a3e in mysql_execute_command (thd=0x555557c07090)
at /mariadb/5.5/sql/sql_parse.cc:2610
#8 0x00005555559428bd in mysql_parse (thd=0x555557c07090,
rawbuf=0x7fffc4007108 "CREATE TABLE t1 ENGINE=InnoDB SELECT a,SLEEP(1) FROM t", length=54, parser_state=0x7ffff43ac650)
at /mariadb/5.5/sql/sql_parse.cc:5929
Workaround: To drop the table from the InnoDB data dictionary afterwards, you could copy the .frm file of a similar InnoDB table to the ‘phantom’ name, and then issue DROP TABLE.