List:Commits« Previous MessageNext Message »
From:ramil Date:June 17 2007 4:56am
Subject:bk commit into 5.1 tree (ramil:1.2502) 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-06-17 09:56:33+05:00, ramil@stripped +5 -0
  Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
  
  The log tables are by nature PERFORMANCE_SCHEMA tables,
  which should not be affected by SET GLOBAL READ_ONLY or FLUSH TABLES
  WITH READ LOCK.
  
  The implementation of FLUSH TABLES WITH READ LOCK already ignored log tables.
  Now with this patch, the implementation of LOCK TABLE also ignore a
  global read lock for log tables, which was the missing symmetry.

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

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

  sql/lock.cc@stripped, 2007-06-17 09:56:31+05:00, ramil@stripped +1 -3
    Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
      - logger.is_privileged_thread() used.

  sql/log.h@stripped, 2007-06-17 09:56:31+05:00, ramil@stripped +6 -0
    Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
      - LOGGER::is_privileged_thread() introduced that returns TRUE if a given thread 
        is either a general_log or a slow_log or a privileged thread.

  sql/sql_base.cc@stripped, 2007-06-17 09:56:31+05:00, ramil@stripped +6 -2
    Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
      - pass MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK to the mysql_lock_tables() in case of 
        call from a logger in order not to honor the GLOBAL READ LOCK 
        and to avoid possible deadlocks.

# 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

--- 1.108/sql/lock.cc	2007-06-17 09:56:37 +05:00
+++ 1.109/sql/lock.cc	2007-06-17 09:56:37 +05:00
@@ -707,9 +707,7 @@ static MYSQL_LOCK *get_lock_data(THD *th
     if (!table_ptr[i]-> file->
           check_if_locking_is_allowed(thd->lex->sql_command, thd->lex->type,
                                       table_ptr[i], count, i, &system_count,
-                                      (thd == logger.get_general_log_thd()) ||
-                                      (thd == logger.get_slow_log_thd()) ||
-                                      (thd == logger.get_privileged_thread())))
+                                      logger.is_privileged_thread(thd)))
       DBUG_RETURN(0);
   }
 

--- 1.408/sql/sql_base.cc	2007-06-17 09:56:37 +05:00
+++ 1.409/sql/sql_base.cc	2007-06-17 09:56:37 +05:00
@@ -4018,6 +4018,11 @@ int lock_tables(THD *thd, TABLE_LIST *ta
   {
     DBUG_ASSERT(thd->lock == 0);	// You must lock everything at once
     TABLE **start,**ptr;
+    uint lock_flag= MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN;
+    
+    /* Don't honor the GLOBAL READ LOCK if called from a logger */
+    if (logger.is_privileged_thread(thd))
+      lock_flag|= MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK;
 
     if (!(ptr=start=(TABLE**) thd->alloc(sizeof(TABLE*)*count)))
       DBUG_RETURN(-1);
@@ -4046,8 +4051,7 @@ int lock_tables(THD *thd, TABLE_LIST *ta
     }
 
     if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start),
-                                        MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN,
-                                        need_reopen)))
+                                        lock_flag, need_reopen)))
     {
       if (thd->lex->requires_prelocking())
       {

--- 1.25/sql/log.h	2007-06-17 09:56:37 +05:00
+++ 1.26/sql/log.h	2007-06-17 09:56:37 +05:00
@@ -600,6 +600,12 @@ public:
     else
       return NULL;
   }
+  bool is_privileged_thread(THD *thd)
+  {
+    return thd == get_general_log_thd() ||
+           thd == get_slow_log_thd() ||
+           thd == get_privileged_thread();
+  }
 };
 
 enum enum_binlog_format {

--- 1.16/mysql-test/r/flush.result	2007-06-17 09:56:37 +05:00
+++ 1.17/mysql-test/r/flush.result	2007-06-17 09:56:37 +05:00
@@ -55,3 +55,19 @@ flush tables with read lock;
 insert into t2 values(1);
 unlock tables;
 drop table t1, t2;
+End of 5.0 tests
+set @old_general_log= @@general_log;
+set @old_read_only= @@read_only;
+set global general_log= on;
+flush tables with read lock;
+flush logs;
+unlock tables;
+set global read_only=1;
+flush logs;
+unlock tables;
+flush tables with read lock;
+flush logs;
+unlock tables;
+set global general_log= @old_general_log;
+set global read_only= @old_read_only;
+End of 5.1 tests

--- 1.23/mysql-test/t/flush.test	2007-06-17 09:56:37 +05:00
+++ 1.24/mysql-test/t/flush.test	2007-06-17 09:56:37 +05:00
@@ -133,4 +133,28 @@ 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
+#
+set @old_general_log= @@general_log;
+set @old_read_only= @@read_only;
+set global general_log= on;
+
+flush tables with read lock;
+flush logs;
+unlock tables;
+
+set global read_only=1;
+flush logs;
+unlock tables;
+
+flush tables with read lock;
+flush logs;
+unlock tables;
+
+set global general_log= @old_general_log;
+set global read_only= @old_read_only;
+
+--echo End of 5.1 tests
Thread
bk commit into 5.1 tree (ramil:1.2502) BUG#26380ramil17 Jun