diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-20 09:31:27 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-24 15:43:11 +0200 |
commit | 1a1b7a6f16c44239655aa8785647f686730e7632 (patch) | |
tree | 65065db2522909022883ba23165bee06d01bdfb4 /storage/innobase/include | |
parent | 06ef5509d0be2ed8197a981e2b9ceb8ac2bab0cc (diff) | |
download | mariadb-git-1a1b7a6f16c44239655aa8785647f686730e7632.tar.gz |
MDEV-24167: Replace dict_operation_lock (dict_sys.latch)
Diffstat (limited to 'storage/innobase/include')
-rw-r--r-- | storage/innobase/include/dict0dict.h | 57 | ||||
-rw-r--r-- | storage/innobase/include/log0log.ic | 2 | ||||
-rw-r--r-- | storage/innobase/include/row0mysql.h | 10 | ||||
-rw-r--r-- | storage/innobase/include/sync0types.h | 4 |
4 files changed, 34 insertions, 39 deletions
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index f7c4d5dca29..2d347feb7d6 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -31,6 +31,7 @@ Created 1/8/1996 Heikki Tuuri #include "data0data.h" #include "dict0mem.h" #include "fsp0fsp.h" +#include "srw_lock.h" #include <deque> class MDL_ticket; @@ -1392,6 +1393,21 @@ extern ib_mutex_t dict_foreign_err_mutex; /* mutex protecting the /** InnoDB data dictionary cache */ class dict_sys_t { +private: + /** @brief the data dictionary rw-latch protecting dict_sys + + Table create, drop, etc. reserve this in X-mode (along with + acquiring dict_sys.mutex); implicit or + backround operations that are not fully covered by MDL + (rollback, foreign key checks) reserve this in S-mode. + + This latch also prevents lock waits when accessing the InnoDB + data dictionary tables. @see trx_t::dict_operation_lock_mode */ + MY_ALIGNED(CACHE_LINE_SIZE) srw_lock latch; +#ifdef UNIV_DEBUG + /** whether latch is being held in exclusive mode (by any thread) */ + bool latch_ex; +#endif public: DictSysMutex mutex; /*!< mutex protecting the data dictionary; protects also the @@ -1400,15 +1416,6 @@ public: and DROP TABLE, as well as reading the dictionary data for a table from system tables */ - /** @brief the data dictionary rw-latch protecting dict_sys - - Table create, drop, etc. reserve this in X-mode; implicit or - backround operations purge, rollback, foreign key checks reserve this - in S-mode; not all internal InnoDB operations are covered by MDL. - - This latch also prevents lock waits when accessing the InnoDB - data dictionary tables. @see trx_t::dict_operation_lock_mode */ - rw_lock_t latch; row_id_t row_id; /*!< the next row id to assign; NOTE that at a checkpoint this must be written to the dict system @@ -1433,9 +1440,10 @@ public: table_non_LRU; /*!< List of tables that can't be evicted from the cache */ private: - bool m_initialised; - /** the sequence of temporary table IDs */ - std::atomic<table_id_t> temp_table_id; + bool m_initialised= false; + /** the sequence of temporary table IDs */ + std::atomic<table_id_t> temp_table_id{DICT_HDR_FIRST_ID}; + /** hash table of temporary table IDs */ hash_table_t temp_id_hash; public: @@ -1480,12 +1488,6 @@ public: return table; } - /** - Constructor. Further initialisation happens in create(). - */ - - dict_sys_t() : m_initialised(false), temp_table_id(DICT_HDR_FIRST_ID) {} - bool is_initialised() const { return m_initialised; } /** Initialise the data dictionary cache. */ @@ -1544,26 +1546,31 @@ public: #ifdef UNIV_DEBUG /** Assert that the data dictionary is locked */ - void assert_locked() - { - ut_ad(mutex_own(&mutex)); - ut_ad(rw_lock_own(&latch, RW_LOCK_X)); - } + void assert_locked() { ut_ad(mutex_own(&mutex)); } #endif /** Lock the data dictionary cache. */ void lock(const char* file, unsigned line) { - rw_lock_x_lock_func(&latch, 0, file, line); + latch.wr_lock(); + ut_ad(!latch_ex); + ut_d(latch_ex= true); mutex_enter_loc(&mutex, file, line); } /** Unlock the data dictionary cache. */ void unlock() { + ut_ad(latch_ex); + ut_d(latch_ex= false); mutex_exit(&mutex); - rw_lock_x_unlock(&latch); + latch.wr_unlock(); } + /** Prevent modifications of the data dictionary */ + void freeze() { latch.rd_lock(); ut_ad(!latch_ex); } + /** Allow modifications of the data dictionary */ + void unfreeze() { ut_ad(!latch_ex); latch.rd_unlock(); } + /** Estimate the used memory occupied by the data dictionary table and index objects. @return number of bytes occupied */ diff --git a/storage/innobase/include/log0log.ic b/storage/innobase/include/log0log.ic index d503e3ffec9..3af021ee9df 100644 --- a/storage/innobase/include/log0log.ic +++ b/storage/innobase/include/log0log.ic @@ -308,8 +308,6 @@ log_free_check(void) static const latch_level_t latches[] = { SYNC_DICT, /* dict_sys.mutex during commit_try_rebuild() */ - SYNC_DICT_OPERATION, /* dict_sys.latch X-latch during - commit_try_rebuild() */ SYNC_FTS_CACHE, /* fts_cache_t::lock */ SYNC_INDEX_TREE /* index->lock */ }; diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index fc454826c2b..18114f18b14 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -330,14 +330,8 @@ row_mysql_unlock_data_dictionary( /*********************************************************************//** Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL. */ -void -row_mysql_freeze_data_dictionary_func( -/*==================================*/ - trx_t* trx, /*!< in/out: transaction */ - const char* file, /*!< in: file name */ - unsigned line); /*!< in: line number */ -#define row_mysql_freeze_data_dictionary(trx) \ - row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__) +void row_mysql_freeze_data_dictionary(trx_t *trx); + /*********************************************************************//** Unlocks the data dictionary shared lock. */ void diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h index a12fb88ae55..b1fa2c52ca2 100644 --- a/storage/innobase/include/sync0types.h +++ b/storage/innobase/include/sync0types.h @@ -236,8 +236,6 @@ enum latch_level_t { SYNC_DICT, SYNC_FTS_CACHE, - SYNC_DICT_OPERATION, - /** Level is varying. Only used with buffer pool page locks, which do not have a fixed level, but instead have their level set after the page is locked; see e.g. ibuf_bitmap_get_map_page(). */ @@ -291,7 +289,6 @@ enum latch_id_t { LATCH_ID_WORK_QUEUE, LATCH_ID_BUF_BLOCK_LOCK, LATCH_ID_BUF_BLOCK_DEBUG, - LATCH_ID_DICT_OPERATION, LATCH_ID_FIL_SPACE, LATCH_ID_FTS_CACHE, LATCH_ID_FTS_CACHE_INIT, @@ -960,7 +957,6 @@ struct sync_checker : public sync_check_functor_t switch (level) { case SYNC_FSP: case SYNC_DICT: - case SYNC_DICT_OPERATION: case SYNC_FTS_CACHE: case SYNC_NO_ORDER_CHECK: return(false); |