Skip to content

Commit 1a0c283

Browse files
Marcin Babijdahlerlend
authored andcommitted
Bug #32173596 ASSERTION FAILURE: FIL0FIL.CC:3110:FILE->N_PE AFTER DBSYSTEM START AFTER UPGRADE
dd_load_tablespace re-checks the space still is not loaded after we reacquire the dict_sys mutex. RB#25596
1 parent e2c3410 commit 1a0c283

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

storage/innobase/dict/dict0dd.cc

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3981,13 +3981,18 @@ void dd_load_tablespace(const Table *dd_table, dict_table_t *table,
39813981
space_name = tablespace_name.c_str();
39823982
}
39833983

3984+
auto is_already_opened = [&]() {
3985+
if (fil_space_exists_in_mem(table->space, space_name, false, true, heap,
3986+
table->id)) {
3987+
dd_get_and_save_data_dir_path(table, dd_table, true);
3988+
ut_free(shared_space_name);
3989+
return true;
3990+
}
3991+
return false;
3992+
};
3993+
39843994
/* The tablespace may already be open. */
3985-
if (fil_space_exists_in_mem(table->space, space_name, false, true, heap,
3986-
table->id)) {
3987-
dd_get_and_save_data_dir_path(table, dd_table, true);
3988-
ut_free(shared_space_name);
3989-
return;
3990-
}
3995+
if (is_already_opened()) return;
39913996

39923997
if (!(ignore_err & DICT_ERR_IGNORE_RECOVER_LOCK)) {
39933998
ib::error(ER_IB_MSG_172)
@@ -4019,6 +4024,7 @@ void dd_load_tablespace(const Table *dd_table, dict_table_t *table,
40194024
path is changed then boot_tablespaces() would always open the tablespace. */
40204025
mutex_exit(&dict_sys->mutex);
40214026
filepath = dd_get_first_path(heap, table, dd_table);
4027+
DEBUG_SYNC_C("innodb_dd_load_tablespace_no_dict_mutex");
40224028
mutex_enter(&dict_sys->mutex);
40234029

40244030
if (filepath == nullptr) {
@@ -4027,6 +4033,12 @@ void dd_load_tablespace(const Table *dd_table, dict_table_t *table,
40274033
<< table->space << " in the data dictionary.";
40284034
}
40294035

4036+
/* The tablespace may have been opened while we released the dict_sys mutex.
4037+
We need to check again if it was not opened in meantime, as fil_ibd_open
4038+
will try to close it forcefully, even if some IO is underway, leading to
4039+
crash. */
4040+
if (is_already_opened()) return;
4041+
40304042
/* Try to open the tablespace. We set the 2nd param (fix_dict) to
40314043
false because we do not have an x-lock on dict_operation_lock */
40324044
dberr_t err =
@@ -4295,6 +4307,8 @@ dict_table_t *dd_open_table_one(dd::cache::Dictionary_client *client,
42954307
dd_load_tablespace(dd_table, m_table, heap, DICT_ERR_IGNORE_RECOVER_LOCK,
42964308
dd_fsp_flags);
42974309

4310+
DEBUG_SYNC_C("innodb_dd_load_tablespace_done");
4311+
42984312
if (dd_space && m_table->space != TRX_SYS_SPACE &&
42994313
fil_space_get(m_table->space) != nullptr) {
43004314
/* Get the autoextend_size property from the tablespace

storage/innobase/fil/fil0fil.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8063,6 +8063,8 @@ dberr_t Fil_shard::do_io(const IORequest &type, bool sync,
80638063

80648064
mutex_release();
80658065

8066+
DEBUG_SYNC_C("innodb_fil_do_io_prepared_io_with_no_mutex");
8067+
80668068
ut_a(page_size.is_compressed() ||
80678069
page_size.physical() == page_size.logical());
80688070

0 commit comments

Comments
 (0)