diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-09-06 09:43:16 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-09-08 15:49:03 +0300 |
commit | fec844aca88e1c6b9c36bb0b811e92d9d023ffb9 (patch) | |
tree | 3e8602113e591b163bf23fffe95c8908cac88ea3 /storage/innobase/include/lock0priv.h | |
parent | 2e814d4702d71a04388386a9f591d14a35980bfe (diff) | |
download | mariadb-git-fec844aca88e1c6b9c36bb0b811e92d9d023ffb9.tar.gz |
Merge InnoDB 5.7 from mysql-5.7.14.
Contains also:
MDEV-10549 mysqld: sql/handler.cc:2692: int handler::ha_index_first(uchar*): Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2' failed. (branch bb-10.2-jan)
Unlike MySQL, InnoDB still uses THR_LOCK in MariaDB
MDEV-10548 Some of the debug sync waits do not work with InnoDB 5.7 (branch bb-10.2-jan)
enable tests that were fixed in MDEV-10549
MDEV-10548 Some of the debug sync waits do not work with InnoDB 5.7 (branch bb-10.2-jan)
fix main.innodb_mysql_sync - re-enable online alter for partitioned innodb tables
Diffstat (limited to 'storage/innobase/include/lock0priv.h')
-rw-r--r-- | storage/innobase/include/lock0priv.h | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/storage/innobase/include/lock0priv.h b/storage/innobase/include/lock0priv.h index 06573d261fb..0b2ab1bfcfe 100644 --- a/storage/innobase/include/lock0priv.h +++ b/storage/innobase/include/lock0priv.h @@ -729,20 +729,23 @@ public: Create a lock for a transaction and initialise it. @param[in, out] trx Transaction requesting the new lock @param[in] owns_trx_mutex true if caller owns the trx_t::mutex + @param[in] add_to_hash add the lock to hash table @param[in] prdt Predicate lock (optional) @return new lock instance */ lock_t* create( trx_t* trx, bool owns_trx_mutex, + bool add_to_hash, const lock_prdt_t* prdt = NULL); + lock_t* create( lock_t* const c_lock, trx_t* trx, bool owns_trx_mutex, + bool add_to_hash, const lock_prdt_t* prdt = NULL); - /** Check of the lock is on m_rec_id. @param[in] lock Lock to compare with @@ -765,19 +768,6 @@ public: ulint size); private: - /** - Enqueue a lock wait for a high priority transaction, jump the record - lock wait queue and if the transaction at the head of the queue is - itself waiting roll it back. - @param[in, out] wait_for The lock that the joining - transaction is waiting for - @param[in] prdt Predicate for the predicate lock - @return NULL if the lock was granted */ - lock_t* enqueue_priority( - const lock_t* wait_for, - const lock_prdt_t* - prdt); - /* @return the record lock size in bytes */ size_t lock_size() const @@ -795,15 +785,47 @@ private: void mark_trx_for_rollback(trx_t* trx); /** - Add the lock to the head of the record lock {space, page_no} wait - queue and the transaction's lock list. If the transactions holding - blocking locks are already marked for termination then they are not - added to the hit list. - @param[in, out] lock Lock being requested - @param[in] wait_for The blocking lock - @param[in] kill_trx true if the transaction that m_trx - is waiting for should be killed */ - void jump_queue(lock_t* lock, const lock_t* wait_for, bool kill_trx); + Jump the queue for the record over all low priority transactions and + add the lock. If all current granted locks are compatible, grant the + lock. Otherwise, mark all granted transaction for asynchronous + rollback and add to hit list. + @param[in, out] lock Lock being requested + @param[in] conflict_lock First conflicting lock from the head + @return true if the lock is granted */ + bool jump_queue(lock_t* lock, const lock_t* conflict_lock); + + /** Find position in lock queue and add the high priority transaction + lock. Intention and GAP only locks can be granted even if there are + waiting locks in front of the queue. To add the High priority + transaction in a safe position we keep the following rule. + + 1. If the lock can be granted, add it before the first waiting lock + in the queue so that all currently waiting locks need to do conflict + check before getting granted. + + 2. If the lock has to wait, add it after the last granted lock or the + last waiting high priority transaction in the queue whichever is later. + This ensures that the transaction is granted only after doing conflict + check with all granted transactions. + @param[in] lock Lock being requested + @param[in] conflict_lock First conflicting lock from the head + @param[out] high_priority high priority transaction ahead in queue + @return true if the lock can be granted */ + bool + lock_add_priority( + lock_t* lock, + const lock_t* conflict_lock, + bool* high_priority); + + /** Iterate over the granted locks and prepare the hit list for ASYNC Rollback. + If the transaction is waiting for some other lock then wake up with deadlock error. + Currently we don't mark following transactions for ASYNC Rollback. + 1. Read only transactions + 2. Background transactions + 3. Other High priority transactions + @param[in] lock Lock being requested + @param[in] conflict_lock First conflicting lock from the head */ + void make_trx_hit_list(lock_t* lock, const lock_t* conflict_lock); /** Setup the requesting transaction state for lock grant @@ -811,11 +833,6 @@ private: void set_wait_state(lock_t* lock); /** - Rollback the transaction that is blocking the requesting transaction - @param[in, out] lock The blocking lock */ - void rollback_blocking_trx(lock_t* lock) const; - - /** Add the lock to the record lock hash and the transaction's lock list @param[in,out] lock Newly created record lock to add to the rec hash and the transaction lock list @@ -987,7 +1004,7 @@ lock_clust_rec_some_has_impl( const rec_t* rec, /*!< in: user record */ const dict_index_t* index, /*!< in: clustered index */ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ - MY_ATTRIBUTE((nonnull, warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** Gets the first or next record lock on a page. |