From fbc8768ce5dd790af93df2385731216338d76c42 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Thu, 13 Nov 2014 09:19:12 +0100 Subject: [PATCH] MDEV-7101: SAFE_MUTEX lock order warning when reusing wait_for_commit mutex In SAFE_MUTEX builds, reset the wait_for_commit mutex (destroy and re-initialise), so that SAFE_MUTEX lock order check does not become confused when the mutex is re-used for a different purpose. --- sql/sql_class.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 54d603adfc5..31772403f32 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6342,6 +6342,18 @@ wait_for_commit::reinit() opaque_pointer= NULL; wakeup_error= 0; wakeup_subsequent_commits_running= false; +#ifdef SAFE_MUTEX + /* + When using SAFE_MUTEX, the ordering between taking the LOCK_wait_commit + mutexes is checked. This causes a problem when we re-use a mutex, as then + the expected locking order may change. + + So in this case, do a re-init of the mutex. In release builds, we want to + avoid the overhead of a re-init though. + */ + mysql_mutex_destroy(&LOCK_wait_commit); + mysql_mutex_init(key_LOCK_wait_commit, &LOCK_wait_commit, MY_MUTEX_INIT_FAST); +#endif }