List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:September 7 2010 8:42am
Subject:bzr commit into mysql-5.5-runtime branch (jon.hauglid:3133) Bug#56494
View as plain text  
#At file:///export/home/x/mysql-5.5-runtime-bug56494/ based on revid:jon.hauglid@stripped

 3133 Jon Olav Hauglid	2010-09-07
      Bug #56494 Segfault in upgrade_shared_lock_to_exclusive() for
                 REPAIR of merge table
      
      This crash happened if a table maintenance statement (ANALYZE TABLE,
      REPAIR TABLE, etc.) was executed on a MERGE table and opening and 
      locking a child table failed. This could for example happen if a child
      table did not exist or if a lock timeout happened while waiting for
      a conflicting metadata lock to disappear.
      
      Since opening and locking the MERGE table and its children failed,
      the tables would be closed and the metadata locks released.
      The table maintenance statement would however still try to continue
      and upgrade the metadata lock on the MERGE table. But since the lock
      already had been released, this caused a segfault.
      
      This patch fixes the problem by checking that we in fact have a 
      metadata lock on the table before lock upgrade is attempted.
      
      Test case added to mdl_sync.test.

    modified:
      mysql-test/r/mdl_sync.result
      mysql-test/t/mdl_sync.test
      sql/sql_admin.cc
=== modified file 'mysql-test/r/mdl_sync.result'
--- a/mysql-test/r/mdl_sync.result	2010-08-12 13:50:23 +0000
+++ b/mysql-test/r/mdl_sync.result	2010-09-07 08:42:15 +0000
@@ -2913,3 +2913,13 @@ UNLOCK TABLES;
 # Connection default
 UNLOCK TABLES;
 DROP DATABASE db1;
+#
+# Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for
+#           REPAIR of merge table
+#
+DROP TABLE IF EXISTS t1, t_not_exists;
+CREATE TABLE t1(a int);
+ALTER TABLE t1 ENGINE = MERGE UNION ( t_not_exists );
+REPAIR TABLE t1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+DROP TABLE t1;

=== modified file 'mysql-test/t/mdl_sync.test'
--- a/mysql-test/t/mdl_sync.test	2010-08-12 13:50:23 +0000
+++ b/mysql-test/t/mdl_sync.test	2010-09-07 08:42:15 +0000
@@ -4532,6 +4532,23 @@ disconnect con2;
 disconnect con3;
 
 
+--echo #
+--echo # Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for
+--echo #           REPAIR of merge table
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t_not_exists;
+--enable_warnings
+
+CREATE TABLE t1(a int);
+ALTER TABLE t1 ENGINE = MERGE UNION ( t_not_exists );
+--error ER_WRONG_MRG_TABLE
+REPAIR TABLE t1;
+
+DROP TABLE t1;
+
+
 # Check that all connections opened by test cases in this file are really
 # gone so execution of other tests won't be affected by their presence.
 --source include/wait_until_count_sessions.inc

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2010-08-18 11:29:04 +0000
+++ b/sql/sql_admin.cc	2010-09-07 08:42:15 +0000
@@ -488,7 +488,8 @@ static bool mysql_admin_table(THD* thd, 
     */
     if (lock_type == TL_WRITE && !table->table->s->tmp_table)
     {
-      if (wait_while_table_is_used(thd, table->table,
+      if (!table->table->mdl_ticket ||
+          wait_while_table_is_used(thd, table->table,
                                    HA_EXTRA_PREPARE_FOR_RENAME))
         goto err;
       DEBUG_SYNC(thd, "after_admin_flush");


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20100907084215-rzf9jxrxa33uua1z.bundle
Thread
bzr commit into mysql-5.5-runtime branch (jon.hauglid:3133) Bug#56494Jon Olav Hauglid7 Sep