List:Commits« Previous MessageNext Message »
From:ramil Date:May 31 2007 7:48am
Subject:bk commit into 5.1 tree (ramil:1.2526) BUG#26380
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-05-31 12:48:10+05:00, ramil@stripped +3 -0
  Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
  
  Problem: executing 'flush logs' we don't check global read lock for a thread 
  launching the command. That may cause a deadlock if tables are locked
  and logger calls wait_if_global_read_lock() for the logging thread
  that is not the owner of the global read lock.
  
  Fix: check for global read lock before flushing logs.

  mysql-test/r/flush.result@stripped, 2007-05-31 12:48:08+05:00, ramil@stripped +17 -0
    Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
      - test result.

  mysql-test/t/flush.test@stripped, 2007-05-31 12:48:09+05:00, ramil@stripped +34 -1
    Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
      - test case.

  sql/sql_parse.cc@stripped, 2007-05-31 12:48:09+05:00, ramil@stripped +5 -0
    Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
      - check for global read lock before flushing logs.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ramil
# Host:	ramil.myoffice.izhnet.ru
# Root:	/home/ram/work/b26380/b26380.5.1

--- 1.670/sql/sql_parse.cc	2007-05-31 12:48:15 +05:00
+++ 1.671/sql/sql_parse.cc	2007-05-31 12:48:16 +05:00
@@ -6220,6 +6220,9 @@ bool reload_acl_and_cache(THD *thd, ulon
       tables.
     */
 
+    if (wait_if_global_read_lock(thd, 0, 1))
+      return 1;
+    
     /*
       Writing this command to the binlog may result in infinite loops
       when doing mysqlbinlog|mysql, and anyway it does not really make
@@ -6244,6 +6247,8 @@ bool reload_acl_and_cache(THD *thd, ulon
       result=1;
     if (flush_error_log())
       result=1;
+
+    start_waiting_global_read_lock(thd);
   }
 #ifdef HAVE_QUERY_CACHE
   if (options & REFRESH_QUERY_CACHE_FREE)

--- 1.16/mysql-test/r/flush.result	2007-05-31 12:48:16 +05:00
+++ 1.17/mysql-test/r/flush.result	2007-05-31 12:48:16 +05:00
@@ -55,3 +55,20 @@ flush tables with read lock;
 insert into t2 values(1);
 unlock tables;
 drop table t1, t2;
+End of 5.0 tests
+select @@global.general_log;
+@@global.general_log
+1
+flush tables with read lock;
+flush logs;
+ERROR HY000: Can't execute the query because you have a conflicting read lock
+unlock tables;
+flush tables with read lock;
+flush logs;
+flush logs;
+ERROR HY000: Can't execute the query because you have a conflicting read lock
+unlock tables;
+select @@global.general_log;
+@@global.general_log
+1
+End of 5.1 tests

--- 1.23/mysql-test/t/flush.test	2007-05-31 12:48:16 +05:00
+++ 1.24/mysql-test/t/flush.test	2007-05-31 12:48:16 +05:00
@@ -133,4 +133,37 @@ disconnect con3;
 connection default;
 drop table t1, t2;
 
-# End of 5.0 tests
+--echo End of 5.0 tests
+
+#
+# Bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
+#
+select @@global.general_log;
+flush tables with read lock;
+--error 1223
+flush logs;
+unlock tables;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+flush tables with read lock;
+
+connection con2;
+send flush logs;
+
+connection con1;
+--error 1223
+flush logs;
+unlock tables;
+disconnect con1;
+
+connection con2;
+reap;
+select @@global.general_log;
+disconnect con2;
+
+connection default;
+
+--echo End of 5.1 tests
Thread
bk commit into 5.1 tree (ramil:1.2526) BUG#26380ramil31 May