Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
10.6
trx_t::commit(std::vector<pfs_os_file_t> &deleted) invokes fil_delete_tablespace()->fil_space_free_low() for each modified space:
void trx_t::commit(std::vector<pfs_os_file_t> &deleted)
{
...
for ( const auto &p : mod_tables)
{
if (p.second.is_dropped())
{
...
if ( const auto id= space ? space->id : 0 )
{
pfs_os_file_t d= fil_delete_tablespace(id);
if (d != OS_FILE_CLOSED)
deleted.emplace_back(d);
}
}
}
...
}
and collects file handles in "deleted " array. Then ha_innobase::delete_table() closes files handles in "deleted" array:
int ha_innobase::delete_table( const char *name)
{
...
std::vector<pfs_os_file_t> deleted;
trx->commit(deleted);
...
row_mysql_unlock_data_dictionary(trx);
for (pfs_os_file_t d : deleted)
os_file_close(d);
...
}
Consider fil_delete_tablespace() function, which returns file handles for "delete" array:
pfs_os_file_t fil_delete_tablespace(ulint id)
{
ut_ad(!is_system_tablespace(id));
pfs_os_file_t handle= OS_FILE_CLOSED;
if (fil_space_t *space= fil_space_t::check_pending_operations(id))
{
/* Before deleting the file(s), persistently write a log record. */
mtr_t mtr;
mtr.start();
mtr.log_file_op(FILE_DELETE, id, space->chain.start->name);
handle= space->chain.start->handle;
mtr.commit_file(*space, nullptr);
fil_space_free_low(space);
}
ibuf_delete_for_discarded_space(id);
return handle;
}
fil_system_t::detach() is invoked from mtr_t::commit_file(). But during fil_delete_tablespace() execution buf_do_LRU_batch() can close the tablespace between "handle= space->chain.start->handle;" and "return handle;" lines. It can do this with the following stack:
#1 0x000055fd4a0caf59 in os_file_close_func (file=15) at ./storage/innobase/os/os0file.cc:1452
#2 0x000055fd4a319d0d in fil_node_t::close (this=0x5c8e34110e60) at ./storage/innobase/fil/fil0fil.cc:453
#3 0x000055fd4a318e20 in fil_space_t::try_to_close (print_info=false)
at ./storage/innobase/fil/fil0fil.cc:124
#4 0x000055fd4a319bf9 in fil_node_open_file (node=0x5c8e34037e30) at ./storage/innobase/fil/fil0fil.cc:422
#5 0x000055fd4a31adb2 in fil_space_t::prepare_acquired (this=0x5c8e34037cf0)
at ./storage/innobase/fil/fil0fil.cc:656
#6 0x000055fd4a31e907 in fil_space_t::get (id=67) at ./storage/innobase/fil/fil0fil.cc:1482
#7 0x000055fd4a2af3a4 in buf_flush_space (id=67) at ./storage/innobase/buf/buf0flu.cc:1186
#8 0x000055fd4a2afb72 in buf_flush_LRU_list_batch (max=2000, evict=false, n=0x326e0a09cbf0)
at ./storage/innobase/buf/buf0flu.cc:1293
#9 0x000055fd4a2b0002 in buf_do_LRU_batch (max=2000, evict=false, n=0x326e0a09cbf0)
at ./storage/innobase/buf/buf0flu.cc:1362
#10 0x000055fd4a2b1597 in buf_flush_LRU (max_n=2000, evict=false) at ./storage/innobase/buf/buf0flu.cc:1708
#11 0x000055fd4a2b441f in buf_flush_page_cleaner () at ./storage/innobase/buf/buf0flu.cc:2310
So "space->chain.start->handle" can be set to -1 in parallel thread, but fil_delete_tablespace() returns the old value, saved in local "handle" variable.
fil_space_t::try_to_close() is executed under fil_system.mutex. And mtr_t::commit_file() locks it for fil_system_t::detach() call. fil_system_t::detach() returns detached file handle if its argument detach_handle is true. The fix is to let mtr_t::commit_file() to pass that detached file handle to fil_delete_tablespace().
relates to
MDEV-30829
InnoDB: Cannot close file <tablename>.ibd because of pending fsync
Closed
Transition
Time In Source Status
Execution Times
Open
In Progress
2h 46m
1
In Progress
Closed
22h 33m
1
{"report":{"fcp":1352.5,"ttfb":701.3000001907349,"pageVisibility":"visible","entityId":121059,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"89a943cc-2c82-4981-b787-e63d08147b2c","navigationType":0,"readyForUser":1440.3000001907349,"redirectCount":0,"resourceLoadedEnd":1475.1000003814697,"resourceLoadedStart":707,"resourceTiming":[{"duration":113.90000057220459,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":707,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":707,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":820.9000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":113.90000057220459,"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":707.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":707.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":821.2000007629395,"responseStart":0,"secureConnectionStart":0},{"duration":169.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":707.5,"connectEnd":707.5,"connectStart":707.5,"domainLookupEnd":707.5,"domainLookupStart":707.5,"fetchStart":707.5,"redirectEnd":0,"redirectStart":0,"requestStart":707.5,"responseEnd":877.3000001907349,"responseStart":877.3000001907349,"secureConnectionStart":707.5},{"duration":215.5,"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":707.7000007629395,"connectEnd":707.7000007629395,"connectStart":707.7000007629395,"domainLookupEnd":707.7000007629395,"domainLookupStart":707.7000007629395,"fetchStart":707.7000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":707.7000007629395,"responseEnd":923.2000007629395,"responseStart":923.2000007629395,"secureConnectionStart":707.7000007629395},{"duration":219.10000038146973,"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":708,"connectEnd":708,"connectStart":708,"domainLookupEnd":708,"domainLookupStart":708,"fetchStart":708,"redirectEnd":0,"redirectStart":0,"requestStart":708,"responseEnd":927.1000003814697,"responseStart":927.1000003814697,"secureConnectionStart":708},{"duration":219.60000038146973,"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":708.1000003814697,"connectEnd":708.1000003814697,"connectStart":708.1000003814697,"domainLookupEnd":708.1000003814697,"domainLookupStart":708.1000003814697,"fetchStart":708.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":708.1000003814697,"responseEnd":927.7000007629395,"responseStart":927.7000007629395,"secureConnectionStart":708.1000003814697},{"duration":219.9000005722046,"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":708.3000001907349,"connectEnd":708.3000001907349,"connectStart":708.3000001907349,"domainLookupEnd":708.3000001907349,"domainLookupStart":708.3000001907349,"fetchStart":708.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":708.3000001907349,"responseEnd":928.2000007629395,"responseStart":928.2000007629395,"secureConnectionStart":708.3000001907349},{"duration":312,"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":708.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":708.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1020.5,"responseStart":0,"secureConnectionStart":0},{"duration":220.10000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":708.6000003814697,"connectEnd":708.6000003814697,"connectStart":708.6000003814697,"domainLookupEnd":708.6000003814697,"domainLookupStart":708.6000003814697,"fetchStart":708.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":708.6000003814697,"responseEnd":928.7000007629395,"responseStart":928.7000007629395,"secureConnectionStart":708.6000003814697},{"duration":311.80000019073486,"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":708.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":708.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1020.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":220.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":709,"connectEnd":709,"connectStart":709,"domainLookupEnd":709,"domainLookupStart":709,"fetchStart":709,"redirectEnd":0,"redirectStart":0,"requestStart":709,"responseEnd":929.3000001907349,"responseStart":929.3000001907349,"secureConnectionStart":709},{"duration":558.3000001907349,"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":709.8000001907349,"connectEnd":709.8000001907349,"connectStart":709.8000001907349,"domainLookupEnd":709.8000001907349,"domainLookupStart":709.8000001907349,"fetchStart":709.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":709.8000001907349,"responseEnd":1268.1000003814697,"responseStart":1268.1000003814697,"secureConnectionStart":709.8000001907349},{"duration":691.3000001907349,"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":714.1000003814697,"connectEnd":714.1000003814697,"connectStart":714.1000003814697,"domainLookupEnd":714.1000003814697,"domainLookupStart":714.1000003814697,"fetchStart":714.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":714.1000003814697,"responseEnd":1405.4000005722046,"responseStart":1405.4000005722046,"secureConnectionStart":714.1000003814697},{"duration":238.0999994277954,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1032.2000007629395,"connectEnd":1032.2000007629395,"connectStart":1032.2000007629395,"domainLookupEnd":1032.2000007629395,"domainLookupStart":1032.2000007629395,"fetchStart":1032.2000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":1032.2000007629395,"responseEnd":1270.3000001907349,"responseStart":1270.3000001907349,"secureConnectionStart":1032.2000007629395},{"duration":184.79999923706055,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1290.2000007629395,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1290.2000007629395,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1475,"responseStart":0,"secureConnectionStart":0},{"duration":184.10000038146973,"initiatorType":"link","name":"https://jira.mariadb.org/s/50bc9be5bfead1a25e72c1a9338c94f6-CDN/lu2cib/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/css/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1291,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1291,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1475.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":274.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/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&whisper-enabled=true","startTime":1291.9000005722046,"connectEnd":1291.9000005722046,"connectStart":1291.9000005722046,"domainLookupEnd":1291.9000005722046,"domainLookupStart":1291.9000005722046,"fetchStart":1291.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":1291.9000005722046,"responseEnd":1566,"responseStart":1566,"secureConnectionStart":1291.9000005722046},{"duration":290.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/e0bf5781d46ea69fb123572974cf39de-CDN/lu2cib/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/js/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1292.8000001907349,"connectEnd":1292.8000001907349,"connectStart":1292.8000001907349,"domainLookupEnd":1292.8000001907349,"domainLookupStart":1292.8000001907349,"fetchStart":1292.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1292.8000001907349,"responseEnd":1583.3000001907349,"responseStart":1583.3000001907349,"secureConnectionStart":1292.8000001907349},{"duration":289.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1292.3000001907349,"connectEnd":1292.3000001907349,"connectStart":1292.3000001907349,"domainLookupEnd":1292.3000001907349,"domainLookupStart":1292.3000001907349,"fetchStart":1292.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1292.3000001907349,"responseEnd":1581.8000001907349,"responseStart":1581.8000001907349,"secureConnectionStart":1292.3000001907349}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":465,"responseStart":701,"responseEnd":706,"domLoading":704,"domInteractive":1546,"domContentLoadedEventStart":1546,"domContentLoadedEventEnd":1588,"domComplete":1706,"loadEventStart":1706,"loadEventEnd":1706,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1528.2000007629395},{"name":"bigPipe.sidebar-id.end","time":1529},{"name":"bigPipe.activity-panel-pipe-id.start","time":1529.2000007629395},{"name":"bigPipe.activity-panel-pipe-id.end","time":1530.1000003814697},{"name":"activityTabFullyLoaded","time":1606.5}],"measures":[],"correlationId":"59eba2672a6ee3","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":168,"dbReadsTimeInMs":17,"dbConnsTimeInMs":26,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}