Skip to content

Commit

Permalink
MDEV-20648 InnoDB: Failing assertion: !(*node)->being_extended, innod…
Browse files Browse the repository at this point in the history
…b.log_data_file_size failed in buildbot, assertion `!space->is_stopping()'

InnoDB should check whether the tablespace is being deleted
while extending the tablespace.
  • Loading branch information
Thirunarayanan committed Mar 3, 2021
1 parent 676987c commit f080863
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1038,15 +1038,14 @@ fil_space_extend_must_retry(

}

/*******************************************************************//**
Reserves the fil_system mutex and tries to make sure we can open at least one
/** Reserves the fil_system mutex and tries to make sure we can open at least one
file while holding it. This should be called before calling
fil_node_prepare_for_io(), because that function may need to open a file. */
fil_node_prepare_for_io(), because that function may need to open a file.
@param[in] space_id tablespace id
@return whether the tablespace is usable for io */
static
void
fil_mutex_enter_and_prepare_for_io(
/*===============================*/
ulint space_id) /*!< in: space id */
bool
fil_mutex_enter_and_prepare_for_io(ulint space_id)
{
for (ulint count = 0;;) {
mutex_enter(&fil_system->mutex);
Expand All @@ -1059,7 +1058,7 @@ fil_mutex_enter_and_prepare_for_io(
fil_space_t* space = fil_space_get_by_id(space_id);

if (space == NULL) {
break;
return false;
}

fil_node_t* node = UT_LIST_GET_LAST(space->chain);
Expand All @@ -1074,6 +1073,10 @@ fil_mutex_enter_and_prepare_for_io(
the insert buffer. The insert buffer is in
tablespace 0, and we cannot end up waiting in
this function. */
} else if (space->is_stopping() && !space->is_being_truncated) {
/* If the tablespace is being deleted then InnoDB
shouldn't prepare the tablespace for i/o */
return false;
} else if (!node || node->is_open()) {
/* If the file is already open, no need to do
anything; if the space does not exist, we handle the
Expand Down Expand Up @@ -1144,6 +1147,8 @@ fil_mutex_enter_and_prepare_for_io(

break;
}

return true;
}

/** Try to extend a tablespace if it is smaller than the specified size.
Expand All @@ -1160,7 +1165,10 @@ fil_space_extend(
bool success;

do {
fil_mutex_enter_and_prepare_for_io(space->id);
if (!fil_mutex_enter_and_prepare_for_io(space->id)) {
success = false;
break;
}
} while (fil_space_extend_must_retry(
space, UT_LIST_GET_LAST(space->chain), size,
&success));
Expand Down Expand Up @@ -1537,7 +1545,9 @@ fil_space_t* fil_system_t::read_page0(ulint id)

/* It is possible that the tablespace is dropped while we are
not holding the mutex. */
fil_mutex_enter_and_prepare_for_io(id);
if (!fil_mutex_enter_and_prepare_for_io(id)) {
return NULL;
}

fil_space_t* space = fil_space_get_by_id(id);

Expand Down Expand Up @@ -1610,14 +1620,16 @@ fil_space_get_first_path(
ut_ad(fil_system);
ut_a(id);

fil_mutex_enter_and_prepare_for_io(id);
if (!fil_mutex_enter_and_prepare_for_io(id)) {
fail_exit:
mutex_exit(&fil_system->mutex);
return(NULL);
}

space = fil_space_get_space(id);

if (space == NULL) {
mutex_exit(&fil_system->mutex);

return(NULL);
goto fail_exit;
}

ut_ad(mutex_own(&fil_system->mutex));
Expand Down

0 comments on commit f080863

Please sign in to comment.