diff options
author | Vlad Lesin <vlad_lesin@mail.ru> | 2023-04-13 17:56:38 +0300 |
---|---|---|
committer | Vlad Lesin <vlad_lesin@mail.ru> | 2023-04-13 18:44:53 +0300 |
commit | 7c0af5c56994f37c45d40e45fa4e15743acaeb06 (patch) | |
tree | 525d337abebcb3edead53da3ad067767e64decdd | |
parent | 3f75d8b24d6a39d8293fd0ce0a4923715d189a73 (diff) | |
download | mariadb-git-bb-10.6-MDEV-30775-try_to_close.tar.gz |
MDEV-31049 fil_delete_tablespace() returns wrong file handle if tablespace was closed by parrallel threadbb-10.6-MDEV-30775-try_to_close
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 4 | ||||
-rw-r--r-- | storage/innobase/include/mtr0mtr.h | 12 | ||||
-rw-r--r-- | storage/innobase/mtr/mtr0mtr.cc | 12 |
3 files changed, 20 insertions, 8 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 3549b3950d0..27a6147bef2 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1676,9 +1676,7 @@ pfs_os_file_t fil_delete_tablespace(ulint id) 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); - + mtr.commit_file(*space, nullptr, &handle); fil_space_free_low(space); } diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index 60e01abe18d..51bc24e1812 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -93,10 +93,16 @@ struct mtr_t { ATTRIBUTE_COLD void commit_shrink(fil_space_t &space); /** Commit a mini-transaction that is deleting or renaming a file. - @param space tablespace that is being renamed or deleted - @param name new file name (nullptr=the file will be deleted) + @param space tablespace that is being renamed or deleted + @param name new file name (nullptr=the file will be deleted) + @param detached_handle if detached_handle != nullptr and if space is detached + during the function execution the file handle if it's + node will be set to OS_FILE_CLOSED, and the previous + value of the file handle will be assigned to the + address, pointed by detached_handle. @return whether the operation succeeded */ - ATTRIBUTE_COLD bool commit_file(fil_space_t &space, const char *name); + ATTRIBUTE_COLD bool commit_file(fil_space_t &space, const char *name, + pfs_os_file_t *detached_handle= nullptr); /** Commit a mini-transaction that did not modify any pages, but generated some redo log on a higher level, such as diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 2c004cb0aa6..a466d1598fa 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -333,8 +333,14 @@ void mtr_t::commit_shrink(fil_space_t &space) /** Commit a mini-transaction that is deleting or renaming a file. @param space tablespace that is being renamed or deleted @param name new file name (nullptr=the file will be deleted) +@param detached_handle if detached_handle != nullptr and if space is detached + during the function execution the file handle if it's + node will be set to OS_FILE_CLOSED, and the previous + value of the file handle will be assigned to the + address, pointed by detached_handle. @return whether the operation succeeded */ -bool mtr_t::commit_file(fil_space_t &space, const char *name) +bool mtr_t::commit_file(fil_space_t &space, const char *name, + pfs_os_file_t *detached_handle) { ut_ad(is_active()); ut_ad(!is_inside_ibuf()); @@ -402,7 +408,9 @@ bool mtr_t::commit_file(fil_space_t &space, const char *name) ut_ad(!space.referenced()); ut_ad(space.is_stopping()); - fil_system.detach(&space, true); + pfs_os_file_t handle = fil_system.detach(&space, true); + if (detached_handle) + *detached_handle = handle; mysql_mutex_unlock(&fil_system.mutex); success= true; |