diff options
Diffstat (limited to 'storage/innobase/include')
-rw-r--r-- | storage/innobase/include/hash0hash.h | 27 | ||||
-rw-r--r-- | storage/innobase/include/lock0lock.h | 50 | ||||
-rw-r--r-- | storage/innobase/include/lock0lock.inl | 41 | ||||
-rw-r--r-- | storage/innobase/include/lock0priv.h | 29 | ||||
-rw-r--r-- | storage/innobase/include/lock0priv.inl | 15 | ||||
-rw-r--r-- | storage/innobase/include/trx0trx.h | 4 |
6 files changed, 61 insertions, 105 deletions
diff --git a/storage/innobase/include/hash0hash.h b/storage/innobase/include/hash0hash.h index 57c9d42a0e2..981ff5a0814 100644 --- a/storage/innobase/include/hash0hash.h +++ b/storage/innobase/include/hash0hash.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2022, MariaDB Corporation. +Copyright (c) 2018, 2020, 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 @@ -28,29 +28,8 @@ Created 5/20/1997 Heikki Tuuri #include "ut0rnd.h" struct hash_table_t; -struct hash_cell_t -{ - /** singly-linked, nullptr terminated list of hash buckets */ - void *node; - - /** Insert an element after another. - @tparam T type of the element - @param after the element after which to insert - @param insert the being-inserted element - @param next the next-element pointer in T */ - template<typename T> - void insert_after(T &after, T &insert, T *T::*next) - { -#ifdef UNIV_DEBUG - for (const T *c= static_cast<const T*>(node); c; c= c->*next) - if (c == &after) - goto found; - ut_error; - found: -#endif - insert.*next= after.*next; - after.*next= &insert; - } +struct hash_cell_t{ + void* node; /*!< hash chain node, NULL if none */ }; typedef void* hash_node_t; diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index fa36cf8eef1..a107359ccf1 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2021, 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 @@ -832,29 +832,26 @@ public: /*********************************************************************//** Creates a new record lock and inserts it to the lock queue. Does NOT check for deadlocks or lock compatibility! -@param[in] c_lock conflicting lock -@param[in] thr thread owning trx -@param[in] type_mode lock mode and wait flag, type is ignored and replaced by -LOCK_REC -@param[in] block buffer block containing the record -@param[in] heap_no heap number of the record -@param[in] index index of record -@param[in,out] trx transaction -@param[in] caller_owns_trx_mutex TRUE if caller owns trx mutex -@param[in] insert_before_waiting if true, inserts new B-tree record lock -just after the last non-waiting lock of the current transaction which is -located before the first waiting for the current transaction lock, otherwise -the lock is inserted at the end of the queue @return created lock */ UNIV_INLINE -lock_t *lock_rec_create(lock_t *c_lock, +lock_t* +lock_rec_create( +/*============*/ #ifdef WITH_WSREP - que_thr_t *thr, + lock_t* c_lock, /*!< conflicting lock */ + que_thr_t* thr, /*!< thread owning trx */ #endif - unsigned type_mode, const buf_block_t *block, - ulint heap_no, dict_index_t *index, trx_t *trx, - bool caller_owns_trx_mutex, - bool insert_before_waiting= false); + unsigned type_mode,/*!< in: lock mode and wait + flag, type is ignored and + replaced by LOCK_REC */ + const buf_block_t* block, /*!< in: buffer block containing + the record */ + ulint heap_no,/*!< in: heap number of the record */ + dict_index_t* index, /*!< in: index of record */ + trx_t* trx, /*!< in,out: transaction */ + bool caller_owns_trx_mutex); + /*!< in: true if caller owns + trx mutex */ /*************************************************************//** Removes a record lock request, waiting or granted, from the queue. */ @@ -867,7 +864,6 @@ lock_rec_discard( /** Create a new record lock and inserts it to the lock queue, without checking for deadlocks or conflicts. -@param[in] c_lock conflicting lock @param[in] type_mode lock mode and wait flag; type will be replaced with LOCK_REC @param[in] page_id index page number @@ -876,15 +872,11 @@ without checking for deadlocks or conflicts. @param[in] index the index tree @param[in,out] trx transaction @param[in] holds_trx_mutex whether the caller holds trx->mutex -@param[in] insert_before_waiting if true, inserts new B-tree record lock -just after the last non-waiting lock of the current transaction which is -located before the first waiting for the current transaction lock, otherwise -the lock is inserted at the end of the queue @return created lock */ lock_t* lock_rec_create_low( - lock_t* c_lock, #ifdef WITH_WSREP + lock_t* c_lock, /*!< conflicting lock */ que_thr_t* thr, /*!< thread owning trx */ #endif unsigned type_mode, @@ -893,9 +885,7 @@ lock_rec_create_low( ulint heap_no, dict_index_t* index, trx_t* trx, - bool holds_trx_mutex, - bool insert_before_waiting = false); - + bool holds_trx_mutex); /** Enqueue a waiting request for a lock which cannot be granted immediately. Check for deadlocks. @param[in] type_mode the requested lock mode (LOCK_S or LOCK_X) @@ -916,7 +906,9 @@ Check for deadlocks. (or it happened to commit) */ dberr_t lock_rec_enqueue_waiting( +#ifdef WITH_WSREP lock_t* c_lock, /*!< conflicting lock */ +#endif unsigned type_mode, const buf_block_t* block, ulint heap_no, diff --git a/storage/innobase/include/lock0lock.inl b/storage/innobase/include/lock0lock.inl index 2d35796e3c4..2d5b6ff37f1 100644 --- a/storage/innobase/include/lock0lock.inl +++ b/storage/innobase/include/lock0lock.inl @@ -72,35 +72,32 @@ lock_hash_get( /*********************************************************************//** Creates a new record lock and inserts it to the lock queue. Does NOT check for deadlocks or lock compatibility! -@param[in] c_lock conflicting lock -@param[in] thr thread owning trx -@param[in] type_mode lock mode and wait flag, type is ignored and replaced by -LOCK_REC -@param[in] block buffer block containing the record -@param[in] heap_no heap number of the record -@param[in] index index of record -@param[in,out] trx transaction -@param[in] caller_owns_trx_mutex TRUE if caller owns trx mutex -@param[in] insert_before_waiting if true, inserts new B-tree record lock -just after the last non-waiting lock of the current transaction which is -located before the first waiting for the current transaction lock, otherwise -the lock is inserted at the end of the queue @return created lock */ UNIV_INLINE -lock_t *lock_rec_create(lock_t *c_lock, +lock_t* +lock_rec_create( +/*============*/ #ifdef WITH_WSREP - que_thr_t *thr, + lock_t* c_lock, /*!< conflicting lock */ + que_thr_t* thr, /*!< thread owning trx */ #endif - unsigned type_mode, const buf_block_t *block, - ulint heap_no, dict_index_t *index, trx_t *trx, - bool caller_owns_trx_mutex, - bool insert_before_waiting) + unsigned type_mode,/*!< in: lock mode and wait + flag, type is ignored and + replaced by LOCK_REC */ + const buf_block_t* block, /*!< in: buffer block containing + the record */ + ulint heap_no,/*!< in: heap number of the record */ + dict_index_t* index, /*!< in: index of record */ + trx_t* trx, /*!< in,out: transaction */ + bool caller_owns_trx_mutex) + /*!< in: TRUE if caller owns + trx mutex */ { btr_assert_not_corrupted(block, index); - return lock_rec_create_low(c_lock, + return lock_rec_create_low( #ifdef WITH_WSREP - thr, + c_lock, thr, #endif type_mode, block->page.id(), block->frame, heap_no, - index, trx, caller_owns_trx_mutex, insert_before_waiting); + index, trx, caller_owns_trx_mutex); } diff --git a/storage/innobase/include/lock0priv.h b/storage/innobase/include/lock0priv.h index 46b4597a0d8..f39692903fa 100644 --- a/storage/innobase/include/lock0priv.h +++ b/storage/innobase/include/lock0priv.h @@ -562,13 +562,14 @@ lock_rec_get_next_const( /*********************************************************************//** Gets the first explicit lock request on a record. -@param[in] hash hash chain the lock on -@param[in] page_id page id -@param[in] heap_no heap number of the record @return first lock, NULL if none exists */ UNIV_INLINE -lock_t *lock_rec_get_first(hash_table_t *hash, page_id_t page_id, - ulint heap_no); +lock_t* +lock_rec_get_first( +/*===============*/ + hash_table_t* hash, /*!< in: hash chain the lock on */ + const buf_block_t* block, /*!< in: block containing the record */ + ulint heap_no);/*!< in: heap number of the record */ /*********************************************************************//** Gets the mode of a lock. @@ -622,26 +623,15 @@ lock_table_has( /** Set the wait status of a lock. @param[in,out] lock lock that will be waited for -@param[in,out] trx transaction that will wait for the lock -@param[in] c_lock conflicting lock */ -inline void lock_set_lock_and_trx_wait(lock_t* lock, trx_t* trx, - const lock_t *c_lock) +@param[in,out] trx transaction that will wait for the lock */ +inline void lock_set_lock_and_trx_wait(lock_t* lock, trx_t* trx) { ut_ad(lock); ut_ad(lock->trx == trx); + ut_ad(trx->lock.wait_lock == NULL); ut_ad(lock_mutex_own()); ut_ad(trx_mutex_own(trx)); - if (trx->lock.wait_trx) { - ut_ad(!c_lock || trx->lock.wait_trx == c_lock->trx); - ut_ad(trx->lock.wait_lock); - ut_ad((*trx->lock.wait_lock).trx == trx); - } else { - ut_ad(c_lock); - trx->lock.wait_trx = c_lock->trx; - ut_ad(!trx->lock.wait_lock); - } - trx->lock.wait_lock = lock; lock->type_mode |= LOCK_WAIT; } @@ -654,7 +644,6 @@ inline void lock_reset_lock_and_trx_wait(lock_t* lock) ut_ad(lock_mutex_own()); ut_ad(lock->trx->lock.wait_lock == NULL || lock->trx->lock.wait_lock == lock); - lock->trx->lock.wait_trx= nullptr; lock->trx->lock.wait_lock = NULL; lock->type_mode &= ~LOCK_WAIT; } diff --git a/storage/innobase/include/lock0priv.inl b/storage/innobase/include/lock0priv.inl index 966c8a22028..e16949a4917 100644 --- a/storage/innobase/include/lock0priv.inl +++ b/storage/innobase/include/lock0priv.inl @@ -156,15 +156,16 @@ lock_rec_get_next_const( /*********************************************************************//** Gets the first explicit lock request on a record. -@param[in] hash hash chain the lock on -@param[in] page_id page id -@param[in] heap_no heap number of the record -@return first lock, NULL if none exists */ +@return first lock, NULL if none exists */ UNIV_INLINE -lock_t *lock_rec_get_first(hash_table_t *hash, page_id_t page_id, - ulint heap_no) +lock_t* +lock_rec_get_first( +/*===============*/ + hash_table_t* hash, /*!< in: hash chain the lock on */ + const buf_block_t* block, /*!< in: block containing the record */ + ulint heap_no)/*!< in: heap number of the record */ { - for (lock_t *lock= lock_sys.get_first(*hash, page_id); + for (lock_t *lock= lock_sys.get_first(*hash, block->page.id()); lock; lock= lock_rec_get_next_on_page(lock)) if (lock_rec_get_nth_bit(lock, heap_no)) return lock; diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 5954c3141fa..68a9812468f 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -426,9 +426,7 @@ struct trx_lock_t { trx_que_t que_state; /*!< valid when trx->state == TRX_STATE_ACTIVE: TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT, ... */ - /** Transaction being waited for; protected by the same mutexes as - wait_lock */ - trx_t* wait_trx; + lock_t* wait_lock; /*!< if trx execution state is TRX_QUE_LOCK_WAIT, this points to the lock request, otherwise this is |