Skip to content

Commit

Permalink
MDEV-16169 InnoDB: Failing assertion: !space->referenced()
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
dr-m committed May 15, 2018
1 parent 2b812ab commit 93b6982
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
32 changes: 14 additions & 18 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5411,7 +5411,7 @@ test_make_filepath()

/** Return the next fil_space_t.
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.
@param[in] prev_space Pointer to the previous fil_space_t.
If NULL, use the first fil_space_t on fil_system.space_list.
Expand All @@ -5424,31 +5424,27 @@ fil_space_next(fil_space_t* prev_space)

mutex_enter(&fil_system.mutex);

if (prev_space == NULL) {
if (!space) {
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 {
ut_a(space->referenced());

/* Move on to the next fil_space_t */
space->release();
space = UT_LIST_GET_NEXT(space_list, space);
}

/* Skip spaces that are being created by
fil_ibd_create(), or dropped, or !tablespace. */
while (space != NULL
&& (UT_LIST_GET_LEN(space->chain) == 0
|| space->is_stopping()
|| space->purpose != FIL_TYPE_TABLESPACE)) {
space = UT_LIST_GET_NEXT(space_list, space);
}
/* Skip spaces that are being created by
fil_ibd_create(), or dropped, or !tablespace. */
while (space != NULL
&& (UT_LIST_GET_LEN(space->chain) == 0
|| space->is_stopping()
|| space->purpose != FIL_TYPE_TABLESPACE)) {
space = UT_LIST_GET_NEXT(space_list, space);
}

if (space != NULL) {
space->acquire();
}
if (space != NULL) {
space->acquire();
}

mutex_exit(&fil_system.mutex);
Expand Down Expand Up @@ -5477,7 +5473,7 @@ fil_space_remove_from_keyrotation(fil_space_t* space)

/** Return the next fil_space_t from key rotation list.
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.
@param[in] prev_space Pointer to the previous fil_space_t.
If NULL, use the first fil_space_t on fil_system.space_list.
Expand Down
6 changes: 4 additions & 2 deletions storage/innobase/handler/i_s.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8618,7 +8618,8 @@ i_s_tablespaces_encryption_fill_table(

for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list);
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();
mutex_exit(&fil_system.mutex);
if (int err = i_s_dict_fill_tablespaces_encryption(
Expand Down Expand Up @@ -8889,7 +8890,8 @@ i_s_tablespaces_scrubbing_fill_table(

for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list);
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();
mutex_exit(&fil_system.mutex);
if (int err = i_s_dict_fill_tablespaces_scrubbing(
Expand Down

0 comments on commit 93b6982

Please sign in to comment.