diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 54429a3..3a3bf08 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -6655,7 +6655,7 @@ struct btr_blob_log_check_t { const mtr_log_t log_mode = m_mtr->get_log_mode(); m_mtr->start(); m_mtr->set_log_mode(log_mode); - m_mtr->set_named_space(index->space); + m_mtr->set_named_space(index); m_mtr->set_flush_observer(observer); if (m_op == BTR_STORE_INSERT_BULK) { @@ -6866,7 +6866,7 @@ btr_store_big_rec_extern_fields( } mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); mtr.set_log_mode(btr_mtr->get_log_mode()); mtr.set_flush_observer(btr_mtr->get_flush_observer()); diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 63e4436..3d44a83 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -1001,7 +1001,7 @@ dict_create_index_tree_step( || dict_table_is_discarded(index->table); if (!missing) { - mtr.set_named_space(index->space); + mtr.set_named_space(index); } search_tuple = dict_create_search_tuple(node->ind_row, node->heap); diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 214c2c4..21eb02c 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1677,6 +1677,8 @@ struct dict_table_t { It is protected by lock_sys->mutex. */ ulint n_rec_locks; + /* Pointer to the tablespace object that this table blongs to. */ + fil_space_t* space_object; #ifndef UNIV_DEBUG private: #endif diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index a0cec39..5e86f14 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -164,6 +164,8 @@ struct mtr_memo_slot_t { ulint type; }; +struct dict_index_t; + /** Mini-transaction handle and buffer */ struct mtr_t { @@ -353,6 +355,11 @@ struct mtr_t { @param[in] space user or system tablespace */ void set_named_space(fil_space_t* space); + /** Set the tablespace associated with the mini-transaction + (needed for generating a MLOG_FILE_NAME record) + @param[in] index index object */ + void set_named_space(dict_index_t* index); + #ifdef UNIV_DEBUG /** Check the tablespace associated with the mini-transaction (needed for generating a MLOG_FILE_NAME record) diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index e7865c5..364df42 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -745,6 +745,21 @@ mtr_t::set_named_space(fil_space_t* space) } } +/** Set the tablespace associated with the mini-transaction +(needed for generating a MLOG_FILE_NAME record) +@param[in] index index object */ +void +mtr_t::set_named_space(dict_index_t* index) +{ + if (index->table->space_object) { + ut_ad(index->table->space_object + == fil_space_get(index->space)); + set_named_space(index->table->space_object); + } else { + index->table->space_object = set_named_space(index->space); + } +} + /** Release an object in the memo stack. @return true if released */ bool diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 9dbb2f3..e18c767 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -3985,6 +3985,7 @@ row_import_for_mysql( } table->ibd_file_missing = false; + table->space_object = NULL; table->flags2 &= ~DICT_TF2_DISCARDED; /* Set autoinc value read from cfg file. The value is set to zero diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 9760a97..5006767 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2455,7 +2455,7 @@ row_ins_clust_index_entry_low( ut_ad(!thr_get_trx(thr)->in_rollback); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); if (dict_table_is_temporary(index->table)) { /* Disable REDO logging as the lifetime of temp-tables is @@ -2805,7 +2805,7 @@ row_ins_sec_mtr_start_and_check_if_aborted( const mtr_log_t log_mode = mtr->get_log_mode(); mtr_start(mtr); - mtr->set_named_space(index->space); + mtr->set_named_space(index); mtr->set_log_mode(log_mode); if (!check) { @@ -2881,7 +2881,7 @@ row_ins_sec_index_entry_low( || dict_table_is_intrinsic(index->table)); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); if (dict_table_is_temporary(index->table)) { /* Disable REDO logging as the lifetime of temp-tables is @@ -2947,7 +2947,7 @@ row_ins_sec_index_entry_low( index, false); rtr_info_update_btr(&cursor, &rtr_info); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); search_mode &= ~BTR_MODIFY_LEAF; search_mode |= BTR_MODIFY_TREE; btr_cur_search_to_nth_level( @@ -3217,7 +3217,7 @@ row_ins_index_entry_big_rec_func( DEBUG_SYNC_C_IF_THD(thd, "before_row_ins_extern_latch"); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index a448d55..4fce3b0 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1802,7 +1802,7 @@ row_log_table_apply_delete_low( const dtuple_t* entry = row_build_index_entry( row, save_ext, index, heap); mtr_start(mtr); - mtr->set_named_space(index->space); + mtr->set_named_space(index); btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE, pcur, mtr); @@ -1893,7 +1893,7 @@ row_log_table_apply_delete( } mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); btr_pcur_open(index, old_pk, PAGE_CUR_LE, BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE, &pcur, &mtr); @@ -2046,7 +2046,7 @@ row_log_table_apply_update( } mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); btr_pcur_open(index, old_pk, PAGE_CUR_LE, BTR_MODIFY_TREE, &pcur, &mtr); #ifdef UNIV_DEBUG @@ -2306,7 +2306,7 @@ func_exit_committed: } mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); if (ROW_FOUND != row_search_index_entry( index, entry, BTR_MODIFY_TREE, &pcur, &mtr)) { @@ -2338,7 +2338,7 @@ func_exit_committed: } mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); } goto func_exit; @@ -3280,7 +3280,7 @@ row_log_apply_op_low( rec_printer(entry).str().c_str())); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); /* We perform the pessimistic variant of the operations if we already hold index->lock exclusively. First, search the @@ -3337,7 +3337,7 @@ row_log_apply_op_low( Lock the index tree exclusively. */ mtr_commit(&mtr); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); btr_cur_search_to_nth_level( index, 0, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, &cursor, 0, @@ -3440,7 +3440,7 @@ insert_the_rec: Lock the index tree exclusively. */ mtr_commit(&mtr); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); btr_cur_search_to_nth_level( index, 0, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, &cursor, 0, diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 85521e7..18ca68a 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -3916,6 +3916,8 @@ row_discard_tablespace( table->ibd_file_missing = TRUE; + table->space_object = NULL; + table->flags2 |= DICT_TF2_DISCARDED; dict_table_change_id_in_cache(table, new_id); diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index c412b43..d944c5f 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -144,7 +144,7 @@ row_purge_remove_clust_if_poss_low( log_free_check(); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); if (!row_purge_reposition_pcur(mode, node, &mtr)) { /* The record was already removed. */ @@ -294,7 +294,7 @@ row_purge_remove_sec_if_poss_tree( log_free_check(); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); if (!index->is_committed()) { /* The index->online_status may change if the index is @@ -414,7 +414,7 @@ row_purge_remove_sec_if_poss_leaf( log_free_check(); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); if (!index->is_committed()) { /* For uncommitted spatial index, we also skip the purge. */ @@ -770,7 +770,7 @@ skip_secondaries: index = dict_table_get_first_index(node->table); mtr_sx_lock(dict_index_get_lock(index), &mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); /* NOTE: we must also acquire an X-latch to the root page of the tree. We will need it when we diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index 27be7c1..b66a85a 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -79,7 +79,7 @@ row_undo_ins_remove_clust_rec( ut_ad(node->trx->in_rollback); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); /* This is similar to row_undo_mod_clust(). The DDL thread may @@ -145,7 +145,7 @@ row_undo_ins_remove_clust_rec( retry: /* If did not succeed, try pessimistic descent to tree */ mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); success = btr_pcur_restore_position( @@ -202,7 +202,7 @@ row_undo_ins_remove_sec_low( memset(&pcur, 0, sizeof(pcur)); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); if (mode == BTR_MODIFY_LEAF) { diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index 10928d7..d35d0ab 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -272,7 +272,7 @@ row_undo_mod_clust( index = btr_cur_get_index(btr_pcur_get_btr_cur(pcur)); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); online = dict_index_is_online_ddl(index); @@ -303,7 +303,7 @@ row_undo_mod_clust( descent down the index tree */ mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); err = row_undo_mod_clust_low( @@ -354,7 +354,7 @@ row_undo_mod_clust( if (err == DB_SUCCESS && node->rec_type == TRX_UNDO_UPD_DEL_REC) { mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); /* It is not necessary to call row_log_table, @@ -369,7 +369,7 @@ row_undo_mod_clust( pessimistic descent down the index tree */ mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); err = row_undo_mod_remove_clust_low( @@ -418,7 +418,7 @@ row_undo_mod_del_mark_or_remove_sec_low( log_free_check(); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); if (mode == BTR_MODIFY_LEAF) { @@ -623,7 +623,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( try_again: log_free_check(); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); dict_disable_redo_if_temporary(index->table, &mtr); if (!index->is_committed()) { diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 8259aa9..28add2b 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -2125,7 +2125,7 @@ row_upd_sec_index_entry( "before_row_upd_sec_index_entry"); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); /* Disable REDO logging as lifetime of temp-tables is limited to server or connection lifetime and so REDO information is not needed @@ -2628,7 +2628,7 @@ row_upd_clust_rec( down the index tree */ mtr_start(mtr); - mtr->set_named_space(index->space); + mtr->set_named_space(index); /* Disable REDO logging as lifetime of temp-tables is limited to server or connection lifetime and so REDO information is not needed @@ -2791,7 +2791,7 @@ row_upd_clust_step( /* We have to restore the cursor to its position */ mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); /* Disable REDO logging as lifetime of temp-tables is limited to server or connection lifetime and so REDO information is not needed @@ -2854,7 +2854,7 @@ row_upd_clust_step( mtr_commit(&mtr); mtr_start(&mtr); - mtr.set_named_space(index->space); + mtr.set_named_space(index); success = btr_pcur_restore_position(BTR_MODIFY_LEAF, pcur, &mtr);