summaryrefslogtreecommitdiff
path: root/storage/innobase/lock/lock0wait.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-05-12 13:12:45 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-05-12 13:12:45 +0300
commit03dca7a3337f4f8e718c52a95e793bbc2c9ffa2c (patch)
tree5fb404f1256b8a4a6e3a9c714633f8b3b231c723 /storage/innobase/lock/lock0wait.cc
parentd7cfe2c4f333300e02bfaf1280d9f61f81a7bc03 (diff)
parentff166093741df0bd91ba24e02714ef882073c51b (diff)
downloadmariadb-git-03dca7a3337f4f8e718c52a95e793bbc2c9ffa2c.tar.gz
Merge 10.0 into 10.1
Diffstat (limited to 'storage/innobase/lock/lock0wait.cc')
-rw-r--r--storage/innobase/lock/lock0wait.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc
index 8f9ea7e10aa..a447027e336 100644
--- a/storage/innobase/lock/lock0wait.cc
+++ b/storage/innobase/lock/lock0wait.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2014, 2017, 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
@@ -273,6 +273,9 @@ lock_wait_suspend_thread(
slot = lock_wait_table_reserve_slot(thr, lock_wait_timeout);
+ lock_wait_mutex_exit();
+ trx_mutex_exit(trx);
+
if (thr->lock_state == QUE_THR_LOCK_ROW) {
srv_stats.n_lock_wait_count.inc();
srv_stats.n_lock_wait_current_count.inc();
@@ -284,19 +287,21 @@ lock_wait_suspend_thread(
}
}
- lock_wait_mutex_exit();
- trx_mutex_exit(trx);
-
ulint lock_type = ULINT_UNDEFINED;
- lock_mutex_enter();
-
+ /* The wait_lock can be cleared by another thread when the
+ lock is released. But the wait can only be initiated by the
+ current thread which owns the transaction. Only acquire the
+ mutex if the wait_lock is still active. */
if (const lock_t* wait_lock = trx->lock.wait_lock) {
- lock_type = lock_get_type_low(wait_lock);
+ lock_mutex_enter();
+ wait_lock = trx->lock.wait_lock;
+ if (wait_lock) {
+ lock_type = lock_get_type_low(wait_lock);
+ }
+ lock_mutex_exit();
}
- lock_mutex_exit();
-
had_dict_lock = trx->dict_operation_lock_mode;
switch (had_dict_lock) {