From 21bb5cdfb59629e4d35ba6bfea4d050bf2ec5f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 27 Nov 2013 08:43:46 +0200 Subject: [PATCH] MDEV-4223: Galera: InnoDB assertion failure !mutex_own(mutex) in file sync0sync.ic line 207 Analysis: Code acquired kernel_mutex when calling wsrep_innobase_kill_one_trx. However, functions below also might take kernel mutex thus the assertion. Fix: Acquire kernel_mutex only for lock_cancel_waiting_and_release where it is really needed. --- storage/innobase/handler/ha_innodb.cc | 4 ++-- storage/xtradb/handler/ha_innodb.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index c2c7301bc97..028eea45726 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12662,7 +12662,9 @@ wsrep_innobase_kill_one_trx(void *bf_thd_ptr, trx_t *bf_trx, trx_t *victim_trx, if (wait_lock) { WSREP_DEBUG("canceling wait lock"); victim_trx->was_chosen_as_deadlock_victim= TRUE; + mutex_enter(&kernel_mutex); lock_cancel_waiting_and_release(wait_lock); + mutex_exit(&kernel_mutex); } wsrep_thd_awake(bf_thd, thd, signal); @@ -12753,10 +12755,8 @@ wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd, if (victim_trx) { - mutex_enter(&kernel_mutex); int rcode = wsrep_innobase_kill_one_trx( bf_thd, bf_trx, victim_trx, signal); - mutex_exit(&kernel_mutex); wsrep_srv_conc_cancel_wait(victim_trx); DBUG_RETURN(rcode); } else { diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 2da3ead5abd..d1c6a971e4d 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -13985,7 +13985,9 @@ wsrep_innobase_kill_one_trx(trx_t *bf_trx, trx_t *victim_trx, ibool signal) if (wait_lock) { WSREP_DEBUG("canceling wait lock"); victim_trx->was_chosen_as_deadlock_victim= TRUE; + mutex_enter(&kernel_mutex); lock_cancel_waiting_and_release(wait_lock); + mutex_exit(&kernel_mutex); } wsrep_thd_awake(bf_thd, thd, signal); @@ -14076,10 +14078,8 @@ wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd, if (victim_trx) { - mutex_enter(&kernel_mutex); int rcode = wsrep_innobase_kill_one_trx(bf_trx, victim_trx, signal); - mutex_exit(&kernel_mutex); wsrep_srv_conc_cancel_wait(victim_trx); DBUG_RETURN(rcode); } else {