revision-id: 422506fdd5605eca6e23a35bd115ee5d40409f11 (mariadb-10.1.34-46-g422506fdd56) parent(s): 998b1c0e75a9512bfec308da19096cbced4150ad author: Jan Lindström committer: Jan Lindström timestamp: 2018-08-06 15:32:19 +0300 message: MDEV-13333: Deadlock failure that does not occur elsewhere InnoDB executed code that is mean to execute only when Galera is used and in bad luck one of the transactions is selected incorrectly as deadlock victim. Fixed by adding wsrep_on_trx() condition before entering actual Galera transaction handling. No always repeatable test case for this issue is known. --- storage/innobase/lock/lock0lock.cc | 5 +++-- storage/xtradb/lock/lock0lock.cc | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 441fcace7c3..381127bf74e 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -4963,7 +4963,7 @@ lock_table_create( UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock); #ifdef WITH_WSREP - if (c_lock) { + if (c_lock && wsrep_on_trx(trx)) { if (wsrep_thd_is_wsrep(trx->mysql_thd) && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { UT_LIST_INSERT_AFTER( @@ -5202,9 +5202,10 @@ lock_table_enqueue_waiting( /* Enqueue the lock request that will wait to be granted */ #ifdef WITH_WSREP - if (trx->lock.was_chosen_as_deadlock_victim) { + if (wsrep_on_trx(trx) && trx->lock.was_chosen_as_deadlock_victim) { return(DB_DEADLOCK); } + lock = lock_table_create(c_lock, table, mode | LOCK_WAIT, trx); #else lock = lock_table_create(table, mode | LOCK_WAIT, trx); diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 549cc411f69..87df0e8a75e 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -5003,7 +5003,7 @@ lock_table_create( UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock); #ifdef WITH_WSREP - if (c_lock) { + if (c_lock && wsrep_on_trx(trx)) { if (wsrep_thd_is_wsrep(trx->mysql_thd) && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { UT_LIST_INSERT_AFTER( @@ -5244,9 +5244,10 @@ lock_table_enqueue_waiting( /* Enqueue the lock request that will wait to be granted */ #ifdef WITH_WSREP - if (trx->lock.was_chosen_as_deadlock_victim) { + if (wsrep_on_trx(trx) && trx->lock.was_chosen_as_deadlock_victim) { return(DB_DEADLOCK); } + lock = lock_table_create(c_lock, table, mode | LOCK_WAIT, trx); #else lock = lock_table_create(table, mode | LOCK_WAIT, trx);