[Commits] Rev 4483: MDEV-7101: SAFE_MUTEX lock order warning when reusing wait_for_commit mutex in http://bazaar.launchpad.net/~maria-captains/maria/10.0

knielsen at knielsen-hq.org knielsen at knielsen-hq.org
Thu Nov 13 14:55:50 EET 2014

At http://bazaar.launchpad.net/~maria-captains/maria/10.0

revno: 4483
revision-id: knielsen at knielsen-hq.org-20141113081912-g9i5bnkznczg0rgu
parent: jplindst at mariadb.org-20141113112426-1qsup03sbbzxv6hu
committer: Kristian Nielsen <knielsen at knielsen-hq.org>
branch nick: work-10.0
timestamp: Thu 2014-11-13 09:19:12 +0100
  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.
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2014-09-30 17:31:14 +0000
+++ b/sql/sql_class.cc	2014-11-13 08:19:12 +0000
@@ -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);

More information about the commits mailing list