Commit 00896db1 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-25214 Crash in fil_space_t::try_to_close

fil_space_t::try_to_close(): Tolerate a tablespace that has no
data files attached. The function fil_ibd_create() initially
creates and attaches a tablespace with no files, and invokes
fil_space_t::add() later.

fil_node_open_file(): After releasing and reacquiring fil_system.mutex,
check if the file was already opened by another thread. This avoids
an assertion failure !node->is_open() in fil_node_open_file_low().

These failures were reproduced with the test
innodb.table_definition_cache_debug and the fix of MDEV-27985.
parent e1246775
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2021, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2021, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2021, MariaDB Corporation. Copyright (c) 2014, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -89,7 +89,9 @@ bool fil_space_t::try_to_close(bool print_info) ...@@ -89,7 +89,9 @@ bool fil_space_t::try_to_close(bool print_info)
of fil_system.space_list, so that they would be less likely to be of fil_system.space_list, so that they would be less likely to be
closed here. */ closed here. */
fil_node_t *node= UT_LIST_GET_FIRST(space->chain); fil_node_t *node= UT_LIST_GET_FIRST(space->chain);
ut_ad(node); if (!node)
/* fil_ibd_create() did not invoke fil_space_t::add() yet */
continue;
ut_ad(!UT_LIST_GET_NEXT(chain, node)); ut_ad(!UT_LIST_GET_NEXT(chain, node));
if (!node->is_open()) if (!node->is_open())
...@@ -454,6 +456,8 @@ static bool fil_node_open_file(fil_node_t *node) ...@@ -454,6 +456,8 @@ static bool fil_node_open_file(fil_node_t *node)
/* Flush tablespaces so that we can close modified files. */ /* Flush tablespaces so that we can close modified files. */
fil_flush_file_spaces(); fil_flush_file_spaces();
mutex_enter(&fil_system.mutex); mutex_enter(&fil_system.mutex);
if (node->is_open())
return true;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment