Commit 93b69825 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-16169 InnoDB: Failing assertion: !space->referenced()

Before invoking fil_space_t::acquire(), check space->is_stopping()
to ensure that the tablespace actually is accessible. This fixes
a regression introduced by MDEV-15983.

fil_space_next(): Remove some duplicated code for prev_space==NULL,
and check is_stopping() also on the first tablespace.

i_s_tablespaces_encryption_fill_table(),
i_s_tablespaces_scrubbing_fill_table(): Check is_stopping().
parent 2b812abd
...@@ -5411,7 +5411,7 @@ test_make_filepath() ...@@ -5411,7 +5411,7 @@ test_make_filepath()
/** Return the next fil_space_t. /** Return the next fil_space_t.
Once started, the caller must keep calling this until it returns NULL. Once started, the caller must keep calling this until it returns NULL.
fil_space_acquire() and fil_space_t::release() are invoked here which fil_space_t::acquire() and fil_space_t::release() are invoked here which
blocks a concurrent operation from dropping the tablespace. blocks a concurrent operation from dropping the tablespace.
@param[in] prev_space Pointer to the previous fil_space_t. @param[in] prev_space Pointer to the previous fil_space_t.
If NULL, use the first fil_space_t on fil_system.space_list. If NULL, use the first fil_space_t on fil_system.space_list.
...@@ -5424,31 +5424,27 @@ fil_space_next(fil_space_t* prev_space) ...@@ -5424,31 +5424,27 @@ fil_space_next(fil_space_t* prev_space)
mutex_enter(&fil_system.mutex); mutex_enter(&fil_system.mutex);
if (prev_space == NULL) { if (!space) {
space = UT_LIST_GET_FIRST(fil_system.space_list); space = UT_LIST_GET_FIRST(fil_system.space_list);
/* We can trust that space is not NULL because at least the
system tablespace is always present and loaded first. */
space->acquire();
} else { } else {
ut_a(space->referenced()); ut_a(space->referenced());
/* Move on to the next fil_space_t */ /* Move on to the next fil_space_t */
space->release(); space->release();
space = UT_LIST_GET_NEXT(space_list, space); space = UT_LIST_GET_NEXT(space_list, space);
}
/* Skip spaces that are being created by /* Skip spaces that are being created by
fil_ibd_create(), or dropped, or !tablespace. */ fil_ibd_create(), or dropped, or !tablespace. */
while (space != NULL while (space != NULL
&& (UT_LIST_GET_LEN(space->chain) == 0 && (UT_LIST_GET_LEN(space->chain) == 0
|| space->is_stopping() || space->is_stopping()
|| space->purpose != FIL_TYPE_TABLESPACE)) { || space->purpose != FIL_TYPE_TABLESPACE)) {
space = UT_LIST_GET_NEXT(space_list, space); space = UT_LIST_GET_NEXT(space_list, space);
} }
if (space != NULL) { if (space != NULL) {
space->acquire(); space->acquire();
}
} }
mutex_exit(&fil_system.mutex); mutex_exit(&fil_system.mutex);
...@@ -5477,7 +5473,7 @@ fil_space_remove_from_keyrotation(fil_space_t* space) ...@@ -5477,7 +5473,7 @@ fil_space_remove_from_keyrotation(fil_space_t* space)
/** Return the next fil_space_t from key rotation list. /** Return the next fil_space_t from key rotation list.
Once started, the caller must keep calling this until it returns NULL. Once started, the caller must keep calling this until it returns NULL.
fil_space_acquire() and fil_space_t::release() are invoked here which fil_space_t::acquire() and fil_space_t::release() are invoked here which
blocks a concurrent operation from dropping the tablespace. blocks a concurrent operation from dropping the tablespace.
@param[in] prev_space Pointer to the previous fil_space_t. @param[in] prev_space Pointer to the previous fil_space_t.
If NULL, use the first fil_space_t on fil_system.space_list. If NULL, use the first fil_space_t on fil_system.space_list.
......
...@@ -8618,7 +8618,8 @@ i_s_tablespaces_encryption_fill_table( ...@@ -8618,7 +8618,8 @@ i_s_tablespaces_encryption_fill_table(
for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list);
space; space = UT_LIST_GET_NEXT(space_list, space)) { space; space = UT_LIST_GET_NEXT(space_list, space)) {
if (space->purpose == FIL_TYPE_TABLESPACE) { if (space->purpose == FIL_TYPE_TABLESPACE
&& !space->is_stopping()) {
space->acquire(); space->acquire();
mutex_exit(&fil_system.mutex); mutex_exit(&fil_system.mutex);
if (int err = i_s_dict_fill_tablespaces_encryption( if (int err = i_s_dict_fill_tablespaces_encryption(
...@@ -8889,7 +8890,8 @@ i_s_tablespaces_scrubbing_fill_table( ...@@ -8889,7 +8890,8 @@ i_s_tablespaces_scrubbing_fill_table(
for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list); for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list);
space; space = UT_LIST_GET_NEXT(space_list, space)) { space; space = UT_LIST_GET_NEXT(space_list, space)) {
if (space->purpose == FIL_TYPE_TABLESPACE) { if (space->purpose == FIL_TYPE_TABLESPACE
&& !space->is_stopping()) {
space->acquire(); space->acquire();
mutex_exit(&fil_system.mutex); mutex_exit(&fil_system.mutex);
if (int err = i_s_dict_fill_tablespaces_scrubbing( if (int err = i_s_dict_fill_tablespaces_scrubbing(
......
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