In the end we decided to support the idea of FORCE but without the FORCE keyword:
If a .frm table doesn't exists, try dropping the table from all storage engines.
If the .frm table exists but the table does not exist in the engine try dropping the table from all storage engines.
Update storage engines using many table files (.CSV, MyISAM, Aria) to succeed with the drop even if some of the files are missing.
Add HTON_AUTOMATIC_DELETE_TABLE to handlerton's where delete_table() is not needed and always succeed. This is used by ha_delete_table_force() to know which handlers to ignore when trying to drop a table without a .frm file.
The disadvantage of this solution is that a DROP TABLE on a non existing table will be a bit slower as we have to ask all active storage engines if they know anything about the table.
Things left to do in another MDEV:
Handle dropping of partitioned tables without .par file or .frm
Verify that one can drop partitions with a DROP TABLE #mysql50#...
A note just for the record (it has already been discussed and confirmed to be expected).
1) If .par file is missing, orphan per-partition data files don't get removed upon DROP TABLE:
--source include/have_partition.inc
--let $datadir= `select @@datadir`
createtable t1 (a int) partition by hash(a) partitions 2;
--remove_file $datadir/test/t1.par
droptable t1;
--list_files $datadir/test/
drop table t1;
Warnings:
Warning 1017 Can't find file: './test/t1.par' (errno: 2 "No such file or directory")
db.opt
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
2) If .TRG file is missing, orphan .TRN files don't get removed upon DROP TABLE
--let $datadir= `select @@datadir`
createtable t1 (a int);
createtrigger tr afterinserton t1 for each row beginend;
--remove_file $datadir/test/t1.TRG
droptable t1;
--list_files $datadir/test/
drop table t1;
db.opt
tr.TRN
Elena Stepanova
added a comment - A note just for the record (it has already been discussed and confirmed to be expected).
1) If .par file is missing, orphan per-partition data files don't get removed upon DROP TABLE :
--source include/have_partition.inc
--let $datadir= `select @@datadir`
create table t1 (a int ) partition by hash(a) partitions 2;
--remove_file $datadir/test/t1.par
drop table t1;
--list_files $datadir/test/
drop table t1;
Warnings:
Warning 1017 Can't find file: './test/t1.par' (errno: 2 "No such file or directory")
db.opt
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
2) If .TRG file is missing, orphan .TRN files don't get removed upon DROP TABLE
--let $datadir= `select @@datadir`
create table t1 (a int );
create trigger tr after insert on t1 for each row begin end ;
--remove_file $datadir/test/t1.TRG
drop table t1;
--list_files $datadir/test/
drop table t1;
db.opt
tr.TRN
Has this fix been verified to “play nicely” with the new S3 Storage Engine added in 10.5.4?
When an existing table is converted to S3 Storage Engine (with ALTER TABLE test ENGINE=S3), only the .frm file is "left behind" in local storage, but the other files (e.g. .ibd) are removed
(source in the docs).
# Before ALTER TABLE test ENGINE=S3;
[test]$ ll -alh test.*
-rw-rw---- 1 user grp 461 Sep 24 01:24 test.frm
-rw-rw---- 1 user grp 96K Sep 24 01:24 test.ibd
# After ALTER TABLE test ENGINE=S3;
[test]$ ll -alh test.*
-rw-rw---- 1 user grp 457 Sep 24 01:25 test.frm
Daniel Lenski (Inactive)
added a comment - - edited Has this fix been verified to “play nicely” with the new S3 Storage Engine added in 10.5.4?
When an existing table is converted to S3 Storage Engine (with ALTER TABLE test ENGINE=S3 ), only the .frm file is "left behind" in local storage, but the other files (e.g. .ibd ) are removed
( source in the docs ).
# Before ALTER TABLE test ENGINE=S3;
[test]$ ll -alh test.*
-rw-rw---- 1 user grp 461 Sep 24 01:24 test.frm
-rw-rw---- 1 user grp 96K Sep 24 01:24 test.ibd
# After ALTER TABLE test ENGINE=S3;
[test]$ ll -alh test.*
-rw-rw---- 1 user grp 457 Sep 24 01:25 test.frm
Yes, there are test cases (for example here) that create and drop S3 tables. They're run in CI, so we'd notice if DROP wouldn't work.
Sergei Golubchik
added a comment - Yes, there are test cases (for example here ) that create and drop S3 tables. They're run in CI, so we'd notice if DROP wouldn't work.
Regarding S3.
The .frm file is left (or copied from the S3 storage on discovery) so that the server can easily find it.
When the .frm is opened, the server also checks from the S3 storage that the .frm is up to date. If not, it's updated or removed.
Michael Widenius
added a comment - Regarding S3.
The .frm file is left (or copied from the S3 storage on discovery) so that the server can easily find it.
When the .frm is opened, the server also checks from the S3 storage that the .frm is up to date. If not, it's updated or removed.
There are patches for backporting this to 10.2, but would advice against doing that as there has been a lot of changes in the code between 10.5 and 10.2 and backporting these to 10.2 can cause other unforeseen larger problems.
If anyone has a problem with this in 10.2, then the best option is to upgrade to 10.5 or 10.6.
Michael Widenius
added a comment - There are patches for backporting this to 10.2, but would advice against doing that as there has been a lot of changes in the code between 10.5 and 10.2 and backporting these to 10.2 can cause other unforeseen larger problems.
If anyone has a problem with this in 10.2, then the best option is to upgrade to 10.5 or 10.6.
People
Michael Widenius
Sergey Vojtovich
Votes:
1Vote for this issue
Watchers:
9Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":2303.9000000953674,"ttfb":602.3000001907349,"pageVisibility":"visible","entityId":59122,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"59c4594b-fd88-48cb-89f8-09fd65679694","navigationType":0,"readyForUser":2432.300000190735,"redirectCount":0,"resourceLoadedEnd":1906.6000001430511,"resourceLoadedStart":614.4000000953674,"resourceTiming":[{"duration":378.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":614.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":614.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":992.5,"responseStart":0,"secureConnectionStart":0},{"duration":378.7999999523163,"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":614.7000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":614.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":993.5,"responseStart":0,"secureConnectionStart":0},{"duration":949.6000001430511,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":615,"connectEnd":615,"connectStart":615,"domainLookupEnd":615,"domainLookupStart":615,"fetchStart":615,"redirectEnd":0,"redirectStart":0,"requestStart":999.6000001430511,"responseEnd":1564.6000001430511,"responseStart":1065.9000000953674,"secureConnectionStart":615},{"duration":1273,"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":615.1000001430511,"connectEnd":615.1000001430511,"connectStart":615.1000001430511,"domainLookupEnd":615.1000001430511,"domainLookupStart":615.1000001430511,"fetchStart":615.1000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":1000.2000000476837,"responseEnd":1888.1000001430511,"responseStart":1086.4000000953674,"secureConnectionStart":615.1000001430511},{"duration":467.2999999523163,"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":615.3000001907349,"connectEnd":615.3000001907349,"connectStart":615.3000001907349,"domainLookupEnd":615.3000001907349,"domainLookupStart":615.3000001907349,"fetchStart":615.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1016.9000000953674,"responseEnd":1082.6000001430511,"responseStart":1073.7000000476837,"secureConnectionStart":615.3000001907349},{"duration":471.7000000476837,"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":615.5,"connectEnd":615.5,"connectStart":615.5,"domainLookupEnd":615.5,"domainLookupStart":615.5,"fetchStart":615.5,"redirectEnd":0,"redirectStart":0,"requestStart":1017.1000001430511,"responseEnd":1087.2000000476837,"responseStart":1078.4000000953674,"secureConnectionStart":615.5},{"duration":467.90000009536743,"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":615.7000000476837,"connectEnd":615.7000000476837,"connectStart":615.7000000476837,"domainLookupEnd":615.7000000476837,"domainLookupStart":615.7000000476837,"fetchStart":615.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":1017.3000001907349,"responseEnd":1083.6000001430511,"responseStart":1075.2000000476837,"secureConnectionStart":615.7000000476837},{"duration":398.2000000476837,"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":616,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":616,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1014.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":475.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":616.1000001430511,"connectEnd":616.1000001430511,"connectStart":616.1000001430511,"domainLookupEnd":616.1000001430511,"domainLookupStart":616.1000001430511,"fetchStart":616.1000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":1025.9000000953674,"responseEnd":1091.2000000476837,"responseStart":1089.5,"secureConnectionStart":616.1000001430511},{"duration":402.5,"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":616.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":616.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1018.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":476.09999990463257,"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":616.3000001907349,"connectEnd":616.3000001907349,"connectStart":616.3000001907349,"domainLookupEnd":616.3000001907349,"domainLookupStart":616.3000001907349,"fetchStart":616.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1026.4000000953674,"responseEnd":1092.4000000953674,"responseStart":1091.5,"secureConnectionStart":616.3000001907349},{"duration":1287.0999999046326,"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":618.1000001430511,"connectEnd":618.1000001430511,"connectStart":618.1000001430511,"domainLookupEnd":618.1000001430511,"domainLookupStart":618.1000001430511,"fetchStart":618.1000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":1182.6000001430511,"responseEnd":1905.2000000476837,"responseStart":1897.8000001907349,"secureConnectionStart":618.1000001430511},{"duration":1276.7999999523163,"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":629.8000001907349,"connectEnd":629.8000001907349,"connectStart":629.8000001907349,"domainLookupEnd":629.8000001907349,"domainLookupStart":629.8000001907349,"fetchStart":629.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1295.7000000476837,"responseEnd":1906.6000001430511,"responseStart":1900.6000001430511,"secureConnectionStart":629.8000001907349},{"duration":228.29999995231628,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1816.4000000953674,"connectEnd":1816.4000000953674,"connectStart":1816.4000000953674,"domainLookupEnd":1816.4000000953674,"domainLookupStart":1816.4000000953674,"fetchStart":1816.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":2009.2000000476837,"responseEnd":2044.7000000476837,"responseStart":2043.9000000953674,"secureConnectionStart":1816.4000000953674},{"duration":228.89999985694885,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":2167.800000190735,"connectEnd":2167.800000190735,"connectStart":2167.800000190735,"domainLookupEnd":2167.800000190735,"domainLookupStart":2167.800000190735,"fetchStart":2167.800000190735,"redirectEnd":0,"redirectStart":0,"requestStart":2349.300000190735,"responseEnd":2396.7000000476837,"responseStart":2382.800000190735,"secureConnectionStart":2167.800000190735},{"duration":313.2000000476837,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":2296.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":2296.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2609.7000000476837,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":353,"domainLookupEnd":377,"connectStart":377,"connectEnd":408,"secureConnectionStart":386,"requestStart":408,"responseStart":602,"responseEnd":628,"domLoading":609,"domInteractive":2701,"domContentLoadedEventStart":2701,"domContentLoadedEventEnd":2781,"domComplete":3126,"loadEventStart":3126,"loadEventEnd":3126,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2617},{"name":"bigPipe.sidebar-id.end","time":2617.800000190735},{"name":"bigPipe.activity-panel-pipe-id.start","time":2618},{"name":"bigPipe.activity-panel-pipe-id.end","time":2622.2000000476837},{"name":"activityTabFullyLoaded","time":2824.4000000953674}],"measures":[],"correlationId":"276e72bb82abbf","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":119,"dbReadsTimeInMs":23,"dbConnsTimeInMs":33,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
A note just for the record (it has already been discussed and confirmed to be expected).
1) If .par file is missing, orphan per-partition data files don't get removed upon DROP TABLE:
--source include/have_partition.inc
--let $datadir= `select @@datadir`
--remove_file $datadir/test/t1.par
drop table t1;
Warnings:
Warning 1017 Can't find file: './test/t1.par' (errno: 2 "No such file or directory")
db.opt
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
2) If .TRG file is missing, orphan .TRN files don't get removed upon DROP TABLE
--let $datadir= `select @@datadir`
--remove_file $datadir/test/t1.TRG
drop table t1;
db.opt
tr.TRN