List:Commits« Previous MessageNext Message »
From:Sven Sandberg Date:May 26 2011 11:20am
Subject:bzr commit into mysql-trunk branch (sven.sandberg:3123) Bug#12574820
View as plain text  
#At file:///home/sven/bzr/b12574820-reset_logs_lock_order/trunk/ based on revid:jorgen.loland@stripped

 3123 Sven Sandberg	2011-05-26 [merge]
      Merged BUG#12574820 from 5.5 to trunk
      One conflict resolved manually:
      Text conflict in sql/log.cc

    added:
      mysql-test/suite/binlog/r/binlog_reset_master.result
      mysql-test/suite/binlog/t/binlog_reset_master.test
    modified:
      sql/binlog.cc
      sql/mysqld.cc
=== added file 'mysql-test/suite/binlog/r/binlog_reset_master.result'
--- a/mysql-test/suite/binlog/r/binlog_reset_master.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/binlog_reset_master.result	2011-05-26 10:50:43 +0000
@@ -0,0 +1 @@
+RESET MASTER;

=== added file 'mysql-test/suite/binlog/t/binlog_reset_master.test'
--- a/mysql-test/suite/binlog/t/binlog_reset_master.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_reset_master.test	2011-05-26 10:50:43 +0000
@@ -0,0 +1,26 @@
+# ==== Purpose ====
+#
+# Test bugs in RESET MASTER.
+
+--source include/have_debug.inc
+--source include/have_log_bin.inc
+
+#######################################################################
+# BUG#12574820: binlog.binlog_tmp_table timing out in daily and weekly trunk run
+# Problem: MYSQL_BIN_LOG::reset_logs acquired LOCK_thread_count and
+# LOCK_log in the wrong order. This could cause a deadlock when
+# RESET MASTER was run concurrently with a disconnecting thread.
+#######################################################################
+
+# We use sleep, not debug_sync, because the sync point needs to be in
+# the thread shut down code after the debug sync facility has been
+# shut down.
+--let $write_var= SET DEBUG="+d,sleep_after_lock_thread_count_before_delete_thd"; CREATE TEMPORARY TABLE test.t1 (a INT);
+--let $write_to_file= GENERATE
+--disable_query_log
+--source include/write_var_to_file.inc
+--enable_query_log
+
+--exec $MYSQL < $write_to_file
+RESET MASTER;
+--remove_file $write_to_file

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2011-05-12 17:29:19 +0000
+++ b/sql/binlog.cc	2011-05-26 11:18:45 +0000
@@ -2315,12 +2315,6 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
   DBUG_ENTER("reset_logs");
 
   ha_reset_logs(thd);
-  /*
-    We need to get both locks to be sure that no one is trying to
-    write to the index log file.
-  */
-  mysql_mutex_lock(&LOCK_log);
-  mysql_mutex_lock(&LOCK_index);
 
   /*
     The following mutex is needed to ensure that no threads call
@@ -2330,6 +2324,13 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
   */
   mysql_mutex_lock(&LOCK_thread_count);
 
+  /*
+    We need to get both locks to be sure that no one is trying to
+    write to the index log file.
+  */
+  mysql_mutex_lock(&LOCK_log);
+  mysql_mutex_lock(&LOCK_index);
+
   /* Save variables so that we can reopen the log */
   save_name=name;
   name=0;					// Protect against free

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-05-25 10:18:08 +0000
+++ b/sql/mysqld.cc	2011-05-26 11:18:45 +0000
@@ -2081,6 +2081,12 @@ void unlink_thd(THD *thd)
   thd_cleanup(thd);
   dec_connection_count();
   mysql_mutex_lock(&LOCK_thread_count);
+  /*
+    Used by binlog_reset_master.  It would be cleaner to use
+    DEBUG_SYNC here, but that's not possible because the THD's debug
+    sync feature has been shut down at this point.
+  */
+  DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd", sleep(5););
   delete_thd(thd);
   DBUG_VOID_RETURN;
 }

No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into mysql-trunk branch (sven.sandberg:3123) Bug#12574820Sven Sandberg26 May