Description: Deadlock around rw_lock_debug_mutex on PPC64 This was later discovered to also fix a corruption issue on AArch64: https://mariadb.atlassian.net/browse/MDEV-6615 Origin: https://github.com/MariaDB/server/commit/c01c819209fdf09b4ba95f34d87d0617776f47cd Bug-Ubuntu: https://bugs.launchpad.net/bugs/1427406 Forwarded: http://bugs.mysql.com/bug.php?id=76135 Author: Sergey Vojtovich Last-Update: 2015-03-30 Index: mysql-5.6/storage/innobase/include/sync0rw.h =================================================================== --- mysql-5.6.orig/storage/innobase/include/sync0rw.h +++ mysql-5.6/storage/innobase/include/sync0rw.h @@ -108,14 +108,8 @@ extern ib_mutex_t rw_lock_list_mutex; #ifdef UNIV_SYNC_DEBUG /* The global mutex which protects debug info lists of all rw-locks. To modify the debug info list of an rw-lock, this mutex has to be - acquired in addition to the mutex protecting the lock. */ -extern ib_mutex_t rw_lock_debug_mutex; -extern os_event_t rw_lock_debug_event; /*!< If deadlock detection does - not get immediately the mutex it - may wait for this event */ -extern ibool rw_lock_debug_waiters; /*!< This is set to TRUE, if - there may be waiters for the event */ +extern os_fast_mutex_t rw_lock_debug_mutex; #endif /* UNIV_SYNC_DEBUG */ /** Counters for RW locks. */ Index: mysql-5.6/storage/innobase/sync/sync0rw.cc =================================================================== --- mysql-5.6.orig/storage/innobase/sync/sync0rw.cc +++ mysql-5.6/storage/innobase/sync/sync0rw.cc @@ -151,18 +151,12 @@ UNIV_INTERN mysql_pfs_key_t rw_lock_mute To modify the debug info list of an rw-lock, this mutex has to be acquired in addition to the mutex protecting the lock. */ -UNIV_INTERN ib_mutex_t rw_lock_debug_mutex; +UNIV_INTERN os_fast_mutex_t rw_lock_debug_mutex; # ifdef UNIV_PFS_MUTEX UNIV_INTERN mysql_pfs_key_t rw_lock_debug_mutex_key; # endif -/* If deadlock detection does not get immediately the mutex, -it may wait for this event */ -UNIV_INTERN os_event_t rw_lock_debug_event; -/* This is set to TRUE, if there may be waiters for the event */ -UNIV_INTERN ibool rw_lock_debug_waiters; - /******************************************************************//** Creates a debug info struct. */ static @@ -699,22 +693,7 @@ void rw_lock_debug_mutex_enter(void) /*===========================*/ { -loop: - if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) { - return; - } - - os_event_reset(rw_lock_debug_event); - - rw_lock_debug_waiters = TRUE; - - if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) { - return; - } - - os_event_wait(rw_lock_debug_event); - - goto loop; + os_fast_mutex_lock(&rw_lock_debug_mutex); } /******************************************************************//** @@ -724,12 +703,7 @@ void rw_lock_debug_mutex_exit(void) /*==========================*/ { - mutex_exit(&rw_lock_debug_mutex); - - if (rw_lock_debug_waiters) { - rw_lock_debug_waiters = FALSE; - os_event_set(rw_lock_debug_event); - } + os_fast_mutex_unlock(&rw_lock_debug_mutex); } /******************************************************************//** Index: mysql-5.6/storage/innobase/sync/sync0sync.cc =================================================================== --- mysql-5.6.orig/storage/innobase/sync/sync0sync.cc +++ mysql-5.6/storage/innobase/sync/sync0sync.cc @@ -1473,11 +1473,7 @@ sync_init(void) SYNC_NO_ORDER_CHECK); #ifdef UNIV_SYNC_DEBUG - mutex_create(rw_lock_debug_mutex_key, &rw_lock_debug_mutex, - SYNC_NO_ORDER_CHECK); - - rw_lock_debug_event = os_event_create(); - rw_lock_debug_waiters = FALSE; + os_fast_mutex_init(rw_lock_debug_mutex_key, &rw_lock_debug_mutex); #endif /* UNIV_SYNC_DEBUG */ } @@ -1545,6 +1541,7 @@ sync_close(void) sync_order_checks_on = FALSE; sync_thread_level_arrays_free(); + os_fast_mutex_free(&rw_lock_debug_mutex); #endif /* UNIV_SYNC_DEBUG */ sync_initialized = FALSE;