List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:November 7 2010 5:43pm
Subject:bzr push into mysql-5.1-bugteam branch (Dmitry.Shulga:3553 to 3554) Bug#47924
View as plain text  
 3554 Dmitry Shulga	2010-11-07
      A fix and a test case for Bug#47924 -main.log_tables times out
      sporadically.
      
      The cause of the sporadic time out was a leaking protection
      against the global read lock, taken by the RENAME statement,
      and not released in case of an error occurred during RENAME.
      The leaking protection counter would lead to the value of
      protect_against_global_read never dropping to 0.
      Consequently FLUSH TABLES in all connections, including the
      one that leaked the protection, could not proceed.
       
      The fix is to ensure that all branchesin RENAME code properly
      release GRL protection.
     @ mysql-test/r/log_tables.result
        Added results for test for bug#47924.
     @ mysql-test/t/log_tables.test
        Added test for bug#47924.
     @ sql/sql_rename.cc
        mysql_rename_tables() modified: replaced return from function
        to goto to clean up code block in case of error.

    modified:
      mysql-test/r/log_tables.result
      mysql-test/t/log_tables.test
      sql/sql_rename.cc
 3553 Guilhem Bichot	2010-11-05
      BUG#57933 "add -Wdeclaration-after-statement to gcc builds";
      first part, for autotools build.
     @ config/ac-macros/maintainer.m4
        Add the flag. With it, and as we use -Werror, we nicely get
        "error: ISO C90 forbids mixed declarations and code" if
        a declaration follows a statement in C code.
        Note that g++ refuses this flag.

    modified:
      config/ac-macros/maintainer.m4
=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	2009-03-11 20:30:56 +0000
+++ b/mysql-test/r/log_tables.result	2010-11-07 17:42:54 +0000
@@ -899,6 +899,16 @@ TIMESTAMP	1	1	SELECT SQL_NO_CACHE 'Bug#3
 TIMESTAMP	1	1	SELECT SQL_NO_CACHE 'Bug#31700 - PK',  f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2
 DROP TABLE t1;
 TRUNCATE TABLE mysql.slow_log;
+use mysql;
+drop table if exists renamed_general_log;
+drop table if exists renamed_slow_log;
+RENAME TABLE general_log TO renamed_general_log;
+ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log'
+RENAME TABLE slow_log TO renamed_slow_log;
+ERROR HY000: Cannot rename 'slow_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'slow_log'
+use test;
+flush tables with read lock;
+unlock tables;
 SET @@session.long_query_time= @old_long_query_time;
 SET @@global.log_output=       @old_log_output;
 SET @@global.slow_query_log=   @old_slow_query_log;

=== modified file 'mysql-test/t/log_tables.test'
--- a/mysql-test/t/log_tables.test	2009-03-11 20:30:56 +0000
+++ b/mysql-test/t/log_tables.test	2010-11-07 17:42:54 +0000
@@ -1027,6 +1027,25 @@ DROP TABLE t1;
 
 TRUNCATE TABLE mysql.slow_log;
 
+#
+# Bug #47924 main.log_tables times out sporadically
+#
+
+use mysql;
+# Should result in error
+--disable_warnings
+drop table if exists renamed_general_log;
+drop table if exists renamed_slow_log;
+--enable_warnings
+--error ER_CANT_RENAME_LOG_TABLE
+RENAME TABLE general_log TO renamed_general_log;
+--error ER_CANT_RENAME_LOG_TABLE
+RENAME TABLE slow_log TO renamed_slow_log;
+
+use test;
+flush tables with read lock;
+unlock tables;
+
 SET @@session.long_query_time= @old_long_query_time;
 
 SET @@global.log_output=       @old_log_output;

=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc	2010-01-24 07:03:23 +0000
+++ b/sql/sql_rename.cc	2010-11-07 17:42:54 +0000
@@ -99,7 +99,7 @@ bool mysql_rename_tables(THD *thd, TABLE
             */
             my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), ren_table->table_name,
                      ren_table->table_name);
-            DBUG_RETURN(1);
+            goto err;
           }
         }
         else
@@ -112,7 +112,7 @@ bool mysql_rename_tables(THD *thd, TABLE
             */
             my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), ren_table->table_name,
                      ren_table->table_name);
-            DBUG_RETURN(1);
+            goto err;
           }
           else
           {
@@ -130,7 +130,7 @@ bool mysql_rename_tables(THD *thd, TABLE
       else
         my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), rename_log_table[1],
                  rename_log_table[1]);
-      DBUG_RETURN(1);
+      goto err;
     }
   }
 


Attachment: [text/bzr-bundle] bzr/dmitry.shulga@oracle.com-20101107174254-rr1n5tuj3t4mrgc7.bundle
Thread
bzr push into mysql-5.1-bugteam branch (Dmitry.Shulga:3553 to 3554) Bug#47924Dmitry Shulga7 Nov