summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2023-04-05 16:55:07 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2023-04-11 18:18:54 +0530
commitfbed00a68725b3f74a5d8ba8635fcc2de5a659e8 (patch)
tree8b067d7c01b1f6fd3de8e463798daebdecf5fe08
parent375991a531f8885634e7a2af224bf396ee7e1f60 (diff)
downloadmariadb-git-fbed00a68725b3f74a5d8ba8635fcc2de5a659e8.tar.gz
MDEV-29273 Race condition between drop table and closing of table
- This issue caused by race condition between drop thread and fil_encrypt_thread. fil_encrypt_thread closes the tablespace if the number of opened files exceeds innodb_open_files. fil_node_open_file() closes the tablespace which are open and it doesn't have pending operations. At that time, InnoDB drop tries to write the redo log for the file delete operation. It throws the bad file descriptor error. - When trying to close the file, InnoDB should check whether the table is going to be dropped.
-rw-r--r--storage/innobase/fil/fil0fil.cc13
-rw-r--r--storage/innobase/include/fil0fil.h3
2 files changed, 12 insertions, 4 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 63df46c3817..698bc783733 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -100,7 +100,13 @@ bool fil_space_t::try_to_close(bool print_info)
if (!node->is_open())
continue;
- if (const auto n= space.set_closing())
+ /* Other thread is trying to do fil_delete_tablespace()
+ concurrently for the same tablespace. So ignore this
+ tablespace and try to close the other one */
+ const auto n= space.set_closing();
+ if (n & STOPPING)
+ continue;
+ if (n & (PENDING | NEEDS_FSYNC))
{
if (!print_info)
continue;
@@ -1372,7 +1378,10 @@ void fil_space_t::close_all()
for (ulint count= 10000; count--;)
{
- if (!space.set_closing())
+ const auto n= space.set_closing();
+ if (n & STOPPING)
+ goto next;
+ if (!(n & (PENDING | NEEDS_FSYNC)))
{
node->close();
goto next;
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index ff6ece8a360..12ac86dc9be 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -628,8 +628,7 @@ private:
@return number of pending operations, possibly with NEEDS_FSYNC flag */
uint32_t set_closing()
{
- return n_pending.fetch_or(CLOSING, std::memory_order_acquire) &
- (PENDING | NEEDS_FSYNC);
+ return n_pending.fetch_or(CLOSING, std::memory_order_acquire);
}
public: