summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-03-14 09:39:47 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2018-03-15 19:44:24 +0200
commit723f87e9d318aedad30dfb9dde104312d6612662 (patch)
treeecb0c905d100cae863e812c65d98fb385f858f24
parenta54abf01753a69c2186d60c155212149be59a7a6 (diff)
downloadmariadb-git-723f87e9d318aedad30dfb9dde104312d6612662.tar.gz
lock_table_create(), lock_rec_create(): Clean up the WSREP code
By definition, c_lock->trx->lock.wait_lock==c_lock cannot hold. That is, the owner transaction of a lock cannot be waiting for that particular lock. It must have been waiting for some other lock. Remove the dead code related to that. Also, test c_lock for NULLness only once.
-rw-r--r--storage/innobase/lock/lock0lock.cc43
-rw-r--r--storage/xtradb/lock/lock0lock.cc43
2 files changed, 20 insertions, 66 deletions
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index eb3d260e78a..68b19a6d2b5 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -898,7 +898,7 @@ UNIV_INLINE
void
lock_reset_lock_and_trx_wait(
/*=========================*/
- lock_t* lock) /*!< in/out: record lock */
+ lock_t* lock) /*!< in/out: record lock */
{
ut_ad(lock_get_wait(lock));
ut_ad(lock_mutex_own());
@@ -2216,13 +2216,6 @@ lock_rec_create(
trx_mutex_enter(trx);
}
- /* trx might not wait for c_lock, but some other lock
- does not matter if wait_lock was released above
- */
- if (c_lock->trx->lock.wait_lock == c_lock) {
- lock_reset_lock_and_trx_wait(lock);
- }
-
trx_mutex_exit(c_lock->trx);
if (wsrep_debug) {
@@ -4970,19 +4963,18 @@ lock_table_create(
UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock);
#ifdef WITH_WSREP
- if (wsrep_thd_is_wsrep(trx->mysql_thd)) {
- if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
+ if (c_lock) {
+ if (wsrep_thd_is_wsrep(trx->mysql_thd)
+ && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
UT_LIST_INSERT_AFTER(
un_member.tab_lock.locks, table->locks, c_lock, lock);
} else {
UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock);
}
- if (c_lock) {
- trx_mutex_enter(c_lock->trx);
- }
+ trx_mutex_enter(c_lock->trx);
- if (c_lock && c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) {
+ if (c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) {
c_lock->trx->lock.was_chosen_as_deadlock_victim = TRUE;
@@ -4991,36 +4983,21 @@ lock_table_create(
wsrep_print_wait_locks(c_lock->trx->lock.wait_lock);
}
- /* have to release trx mutex for the duration of
- victim lock release. This will eventually call
- lock_grant, which wants to grant trx mutex again
- */
- /* caller has trx_mutex, have to release for lock cancel */
+ /* The lock release will call lock_grant(),
+ which would acquire trx->mutex again. */
trx_mutex_exit(trx);
lock_cancel_waiting_and_release(c_lock->trx->lock.wait_lock);
trx_mutex_enter(trx);
- /* trx might not wait for c_lock, but some other lock
- does not matter if wait_lock was released above
- */
- if (c_lock->trx->lock.wait_lock == c_lock) {
- lock_reset_lock_and_trx_wait(lock);
- }
-
if (wsrep_debug) {
fprintf(stderr, "WSREP: c_lock canceled " TRX_ID_FMT "\n",
c_lock->trx->id);
}
}
- if (c_lock) {
- trx_mutex_exit(c_lock->trx);
- }
- } else {
+ trx_mutex_exit(c_lock->trx);
+ } else
#endif /* WITH_WSREP */
UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock);
-#ifdef WITH_WSREP
- }
-#endif /* WITH_WSREP */
if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) {
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index b50452c1d5d..e2b9a1671ca 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -910,7 +910,7 @@ UNIV_INLINE
void
lock_reset_lock_and_trx_wait(
/*=========================*/
- lock_t* lock) /*!< in/out: record lock */
+ lock_t* lock) /*!< in/out: record lock */
{
ut_ad(lock_get_wait(lock));
ut_ad(lock_mutex_own());
@@ -2358,13 +2358,6 @@ lock_rec_create(
trx_mutex_enter(trx);
}
- /* trx might not wait for c_lock, but some other lock
- does not matter if wait_lock was released above
- */
- if (c_lock->trx->lock.wait_lock == c_lock) {
- lock_reset_lock_and_trx_wait(lock);
- }
-
trx_mutex_exit(c_lock->trx);
if (wsrep_debug) {
@@ -5010,19 +5003,18 @@ lock_table_create(
UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock);
#ifdef WITH_WSREP
- if (wsrep_thd_is_wsrep(trx->mysql_thd)) {
- if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
+ if (c_lock) {
+ if (wsrep_thd_is_wsrep(trx->mysql_thd)
+ && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
UT_LIST_INSERT_AFTER(
un_member.tab_lock.locks, table->locks, c_lock, lock);
} else {
UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock);
}
- if (c_lock) {
- trx_mutex_enter(c_lock->trx);
- }
+ trx_mutex_enter(c_lock->trx);
- if (c_lock && c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) {
+ if (c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) {
c_lock->trx->lock.was_chosen_as_deadlock_victim = TRUE;
@@ -5031,36 +5023,21 @@ lock_table_create(
wsrep_print_wait_locks(c_lock->trx->lock.wait_lock);
}
- /* have to release trx mutex for the duration of
- victim lock release. This will eventually call
- lock_grant, which wants to grant trx mutex again
- */
- /* caller has trx_mutex, have to release for lock cancel */
+ /* The lock release will call lock_grant(),
+ which would acquire trx->mutex again. */
trx_mutex_exit(trx);
lock_cancel_waiting_and_release(c_lock->trx->lock.wait_lock);
trx_mutex_enter(trx);
- /* trx might not wait for c_lock, but some other lock
- does not matter if wait_lock was released above
- */
- if (c_lock->trx->lock.wait_lock == c_lock) {
- lock_reset_lock_and_trx_wait(lock);
- }
-
if (wsrep_debug) {
fprintf(stderr, "WSREP: c_lock canceled " TRX_ID_FMT "\n",
c_lock->trx->id);
}
}
- if (c_lock) {
- trx_mutex_exit(c_lock->trx);
- }
- } else {
+ trx_mutex_exit(c_lock->trx);
+ } else
#endif /* WITH_WSREP */
UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock);
-#ifdef WITH_WSREP
- }
-#endif /* WITH_WSREP */
if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) {