Skip to content

Commit

Permalink
MDEV-25214 Crash in fil_space_t::try_to_close
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Mar 15, 2022
1 parent e124677 commit 00896db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
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
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -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
closed here. */
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));

if (!node->is_open())
Expand Down Expand Up @@ -454,6 +456,8 @@ static bool fil_node_open_file(fil_node_t *node)
/* Flush tablespaces so that we can close modified files. */
fil_flush_file_spaces();
mutex_enter(&fil_system.mutex);
if (node->is_open())
return true;
}
}

Expand Down

0 comments on commit 00896db

Please sign in to comment.