diff options
Diffstat (limited to 'storage/innobase/dict/dict0dict.cc')
-rw-r--r-- | storage/innobase/dict/dict0dict.cc | 149 |
1 files changed, 16 insertions, 133 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index a6d6e9e6b3c..2e165a3a7bc 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -60,7 +60,6 @@ extern uint ibuf_debug; #include "lock0lock.h" #include "mach0data.h" #include "mem0mem.h" -#include "os0once.h" #include "page0page.h" #include "page0zip.h" #include "pars0pars.h" @@ -263,76 +262,6 @@ dict_mutex_exit_for_mysql(void) mutex_exit(&dict_sys->mutex); } -/** Allocate and init a dict_table_t's stats latch. -This function must not be called concurrently on the same table object. -@param[in,out] table_void table whose stats latch to create */ -static -void -dict_table_stats_latch_alloc( - void* table_void) -{ - dict_table_t* table = static_cast<dict_table_t*>(table_void); - - /* Note: rw_lock_create() will call the constructor */ - - table->stats_latch = static_cast<rw_lock_t*>( - ut_malloc_nokey(sizeof(rw_lock_t))); - - ut_a(table->stats_latch != NULL); - - rw_lock_create(dict_table_stats_key, table->stats_latch, - SYNC_INDEX_TREE); -} - -/** Deinit and free a dict_table_t's stats latch. -This function must not be called concurrently on the same table object. -@param[in,out] table table whose stats latch to free */ -static -void -dict_table_stats_latch_free( - dict_table_t* table) -{ - rw_lock_free(table->stats_latch); - ut_free(table->stats_latch); -} - -/** Create a dict_table_t's stats latch or delay for lazy creation. -This function is only called from either single threaded environment -or from a thread that has not shared the table object with other threads. -@param[in,out] table table whose stats latch to create -@param[in] enabled if false then the latch is disabled -and dict_table_stats_lock()/unlock() become noop on this table. */ -void -dict_table_stats_latch_create( - dict_table_t* table, - bool enabled) -{ - if (!enabled) { - table->stats_latch = NULL; - table->stats_latch_created = os_once::DONE; - return; - } - - /* We create this lazily the first time it is used. */ - table->stats_latch = NULL; - table->stats_latch_created = os_once::NEVER_DONE; -} - -/** Destroy a dict_table_t's stats latch. -This function is only called from either single threaded environment -or from a thread that has not shared the table object with other threads. -@param[in,out] table table whose stats latch to destroy */ -void -dict_table_stats_latch_destroy( - dict_table_t* table) -{ - if (table->stats_latch_created == os_once::DONE - && table->stats_latch != NULL) { - - dict_table_stats_latch_free(table); - } -} - /** Lock the appropriate latch to protect a given table's statistics. @param[in] table table whose stats to lock @param[in] latch_mode RW_S_LATCH or RW_X_LATCH */ @@ -344,23 +273,12 @@ dict_table_stats_lock( ut_ad(table != NULL); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); - os_once::do_or_wait_for_done( - &table->stats_latch_created, - dict_table_stats_latch_alloc, table); - - if (table->stats_latch == NULL) { - /* This is a dummy table object that is private in the current - thread and is not shared between multiple threads, thus we - skip any locking. */ - return; - } - switch (latch_mode) { case RW_S_LATCH: - rw_lock_s_lock(table->stats_latch); + rw_lock_s_lock(&table->stats_latch); break; case RW_X_LATCH: - rw_lock_x_lock(table->stats_latch); + rw_lock_x_lock(&table->stats_latch); break; case RW_NO_LATCH: /* fall through */ @@ -380,19 +298,12 @@ dict_table_stats_unlock( ut_ad(table != NULL); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); - if (table->stats_latch == NULL) { - /* This is a dummy table object that is private in the current - thread and is not shared between multiple threads, thus we - skip any locking. */ - return; - } - switch (latch_mode) { case RW_S_LATCH: - rw_lock_s_unlock(table->stats_latch); + rw_lock_s_unlock(&table->stats_latch); break; case RW_X_LATCH: - rw_lock_x_unlock(table->stats_latch); + rw_lock_x_unlock(&table->stats_latch); break; case RW_NO_LATCH: /* fall through */ @@ -734,34 +645,6 @@ dict_table_get_nth_v_col_mysql( return(dict_table_get_nth_v_col(table, i)); } -/** Allocate and init the autoinc latch of a given table. -This function must not be called concurrently on the same table object. -@param[in,out] table_void table whose autoinc latch to create */ -static -void -dict_table_autoinc_alloc( - void* table_void) -{ - dict_table_t* table = static_cast<dict_table_t*>(table_void); - table->autoinc_mutex = UT_NEW_NOKEY(ib_mutex_t()); - ut_a(table->autoinc_mutex != NULL); - mutex_create(LATCH_ID_AUTOINC, table->autoinc_mutex); -} - -/** Allocate and init the zip_pad_mutex of a given index. -This function must not be called concurrently on the same index object. -@param[in,out] index_void index whose zip_pad_mutex to create */ -static -void -dict_index_zip_pad_alloc( - void* index_void) -{ - dict_index_t* index = static_cast<dict_index_t*>(index_void); - index->zip_pad.mutex = UT_NEW_NOKEY(SysMutex()); - ut_a(index->zip_pad.mutex != NULL); - mutex_create(LATCH_ID_ZIP_PAD_MUTEX, index->zip_pad.mutex); -} - /********************************************************************//** Acquire the autoinc lock. */ void @@ -769,11 +652,7 @@ dict_table_autoinc_lock( /*====================*/ dict_table_t* table) /*!< in/out: table */ { - os_once::do_or_wait_for_done( - &table->autoinc_mutex_created, - dict_table_autoinc_alloc, table); - - mutex_enter(table->autoinc_mutex); + mysql_mutex_lock(&table->autoinc_mutex); } /** Acquire the zip_pad_mutex latch. @@ -783,11 +662,7 @@ void dict_index_zip_pad_lock( dict_index_t* index) { - os_once::do_or_wait_for_done( - &index->zip_pad.mutex_created, - dict_index_zip_pad_alloc, index); - - mutex_enter(index->zip_pad.mutex); + mysql_mutex_lock(&index->zip_pad.mutex); } /** Get all the FTS indexes on a table. @@ -822,7 +697,7 @@ dict_table_autoinc_unlock( /*======================*/ dict_table_t* table) /*!< in/out: table */ { - mutex_exit(table->autoinc_mutex); + mysql_mutex_unlock(&table->autoinc_mutex); } /** Looks for column n in an index. @@ -1254,6 +1129,7 @@ dict_table_t::add_to_cache() ut_ad(dict_lru_validate()); ut_ad(mutex_own(&dict_sys->mutex)); + mysql_mutex_init(0, &autoinc_mutex, NULL); cached = TRUE; ulint fold = ut_fold_string(name.m_name); @@ -1395,7 +1271,7 @@ dict_index_t *dict_index_t::clone() const (mem_heap_zalloc(heap, n_uniq * sizeof *stat_n_sample_sizes)); index->stat_n_non_null_key_vals= static_cast<ib_uint64_t*> (mem_heap_zalloc(heap, n_uniq * sizeof *stat_n_non_null_key_vals)); - memset(&index->zip_pad, 0, sizeof index->zip_pad); + mysql_mutex_init(0, &index->zip_pad.mutex, NULL); return index; } @@ -2086,8 +1962,15 @@ dict_table_remove_from_cache_low( UT_DELETE(table->vc_templ); } + mysql_mutex_destroy(&table->autoinc_mutex); #ifdef BTR_CUR_HASH_ADAPT if (UNIV_UNLIKELY(UT_LIST_GET_LEN(table->freed_indexes) != 0)) { + if (table->fts) { + fts_optimize_remove_table(table); + fts_free(table); + table->fts = NULL; + } + table->vc_templ = NULL; table->id = 0; return; |