diff options
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 1 | ||||
-rw-r--r-- | storage/innobase/include/trx0sys.h | 35 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.cc | 12 | ||||
-rw-r--r-- | storage/innobase/trx/trx0roll.cc | 10 | ||||
-rw-r--r-- | storage/innobase/trx/trx0trx.cc | 14 |
5 files changed, 34 insertions, 38 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index cec7fe3c615..625093e25f4 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -546,7 +546,6 @@ mysql_pfs_key_t trx_sys_mutex_key; mysql_pfs_key_t srv_threads_mutex_key; mysql_pfs_key_t thread_mutex_key; mysql_pfs_key_t row_drop_list_mutex_key; -mysql_pfs_key_t rw_trx_hash_element_mutex_key; mysql_pfs_key_t read_view_mutex_key; /* all_innodb_mutexes array contains mutexes that are diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index aa3cdd6a24b..16414f2841f 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -40,7 +40,6 @@ Created 3/26/1996 Heikki Tuuri #ifdef UNIV_PFS_MUTEX extern mysql_pfs_key_t trx_sys_mutex_key; -extern mysql_pfs_key_t rw_trx_hash_element_mutex_key; #endif /** Checks if a page address is the trx sys header page. @@ -335,16 +334,14 @@ trx_t* current_trx(); struct rw_trx_hash_element_t { - rw_trx_hash_element_t(): trx(0) + rw_trx_hash_element_t() { - mysql_mutex_init(rw_trx_hash_element_mutex_key, &mutex, nullptr); + memset(reinterpret_cast<void*>(this), 0, sizeof *this); + mutex.init(); } - ~rw_trx_hash_element_t() - { - mysql_mutex_destroy(&mutex); - } + ~rw_trx_hash_element_t() { mutex.destroy(); } trx_id_t id; /* lf_hash_init() relies on this to be first in the struct */ @@ -357,7 +354,7 @@ struct rw_trx_hash_element_t */ Atomic_counter<trx_id_t> no; trx_t *trx; - mysql_mutex_t mutex; + srw_mutex mutex; }; @@ -526,10 +523,10 @@ class rw_trx_hash_t static my_bool debug_iterator(rw_trx_hash_element_t *element, debug_iterator_arg<T> *arg) { - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (element->trx) validate_element(element->trx); - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); return arg->action(element, arg->argument); } #endif @@ -631,7 +628,7 @@ public: sizeof(trx_id_t))); if (element) { - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); lf_hash_search_unpin(pins); if ((trx= element->trx)) { DBUG_ASSERT(trx_id == trx->id); @@ -652,7 +649,7 @@ public: trx->reference(); } } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); } if (!caller_trx) lf_hash_put_pins(pins); @@ -686,9 +683,9 @@ public: void erase(trx_t *trx) { ut_d(validate_element(trx)); - mysql_mutex_lock(&trx->rw_trx_hash_element->mutex); - trx->rw_trx_hash_element->trx= 0; - mysql_mutex_unlock(&trx->rw_trx_hash_element->mutex); + trx->rw_trx_hash_element->mutex.wr_lock(); + trx->rw_trx_hash_element->trx= nullptr; + trx->rw_trx_hash_element->mutex.wr_unlock(); int res= lf_hash_delete(&hash, get_pins(trx), reinterpret_cast<const void*>(&trx->id), sizeof(trx_id_t)); @@ -722,12 +719,12 @@ public: May return element with committed transaction. If caller doesn't like to see committed transactions, it has to skip those under element mutex: - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (trx_t trx= element->trx) { // trx is protected against commit in this branch } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); May miss concurrently inserted transactions. @@ -1180,11 +1177,11 @@ private: { if (element->id < *id) { - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); /* We don't care about read-only transactions here. */ if (element->trx && element->trx->rsegs.m_redo.rseg) *id= element->id; - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); } return 0; } diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index f920ac1ac95..05fdf9b3efe 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -4868,7 +4868,7 @@ static void lock_rec_block_validate(const page_id_t page_id) static my_bool lock_validate_table_locks(rw_trx_hash_element_t *element, void*) { lock_sys.assert_locked(); - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (element->trx) { check_trx_state(element->trx); @@ -4878,7 +4878,7 @@ static my_bool lock_validate_table_locks(rw_trx_hash_element_t *element, void*) if (lock->is_table()) lock_table_queue_validate(lock->un_member.tab_lock.table); } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); return 0; } @@ -5075,7 +5075,7 @@ static my_bool lock_rec_other_trx_holds_expl_callback( rw_trx_hash_element_t *element, lock_rec_other_trx_holds_expl_arg *arg) { - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (element->trx) { element->trx->mutex_lock(); @@ -5091,7 +5091,7 @@ static my_bool lock_rec_other_trx_holds_expl_callback( ut_ad(!expl_lock || expl_lock->trx == &arg->impl_trx); element->trx->mutex_unlock(); } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); return 0; } @@ -5835,7 +5835,7 @@ static my_bool lock_table_locks_lookup(rw_trx_hash_element_t *element, const dict_table_t *table) { lock_sys.assert_locked(); - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (element->trx) { element->trx->mutex_lock(); @@ -5859,7 +5859,7 @@ static my_bool lock_table_locks_lookup(rw_trx_hash_element_t *element, } element->trx->mutex_unlock(); } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); return 0; } #endif /* UNIV_DEBUG */ diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 8fd9f93909c..ddad699ead4 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2021, MariaDB Corporation. +Copyright (c) 2016, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -631,7 +631,7 @@ struct trx_roll_count_callback_arg static my_bool trx_roll_count_callback(rw_trx_hash_element_t *element, trx_roll_count_callback_arg *arg) { - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (trx_t *trx= element->trx) { if (trx->is_recovered && trx_state_eq(trx, TRX_STATE_ACTIVE)) @@ -640,7 +640,7 @@ static my_bool trx_roll_count_callback(rw_trx_hash_element_t *element, arg->n_rows+= trx->undo_no; } } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); return 0; } @@ -678,7 +678,7 @@ void trx_roll_report_progress() static my_bool trx_rollback_recovered_callback(rw_trx_hash_element_t *element, std::vector<trx_t*> *trx_list) { - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (trx_t *trx= element->trx) { trx->mutex_lock(); @@ -686,7 +686,7 @@ static my_bool trx_rollback_recovered_callback(rw_trx_hash_element_t *element, trx_list->push_back(trx); trx->mutex_unlock(); } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); return 0; } diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 7b070a605f4..3c3c4db2b3e 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2021, MariaDB Corporation. +Copyright (c) 2015, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1914,7 +1914,7 @@ static my_bool trx_recover_for_mysql_callback(rw_trx_hash_element_t *element, trx_recover_for_mysql_callback_arg *arg) { DBUG_ASSERT(arg->len > 0); - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (trx_t *trx= element->trx) { /* @@ -1940,7 +1940,7 @@ static my_bool trx_recover_for_mysql_callback(rw_trx_hash_element_t *element, } } } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); /* Do not terminate upon reaching arg->len; count all transactions */ return false; } @@ -1949,13 +1949,13 @@ static my_bool trx_recover_for_mysql_callback(rw_trx_hash_element_t *element, static my_bool trx_recover_reset_callback(rw_trx_hash_element_t *element, void*) { - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (trx_t *trx= element->trx) { if (trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)) trx->state= TRX_STATE_PREPARED; } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); return false; } @@ -2004,7 +2004,7 @@ static my_bool trx_get_trx_by_xid_callback(rw_trx_hash_element_t *element, trx_get_trx_by_xid_callback_arg *arg) { my_bool found= 0; - mysql_mutex_lock(&element->mutex); + element->mutex.wr_lock(); if (trx_t *trx= element->trx) { trx->mutex_lock(); @@ -2026,7 +2026,7 @@ static my_bool trx_get_trx_by_xid_callback(rw_trx_hash_element_t *element, } trx->mutex_unlock(); } - mysql_mutex_unlock(&element->mutex); + element->mutex.wr_unlock(); return found; } |