MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:lars-erik.bjork Date:September 22 2009 11:29am
Subject:bzr commit into mysql-6.0-bugfixing branch (lars-erik.bjork:2831) Bug#47098
View as plain text  
#At file:///home/lb200670/mysql/47098/ based on revid:jon.hauglid@stripped

 2831 lars-erik.bjork@stripped	2009-09-22
      This is a patch for bug#47098 assert in MDL_context::destroy on
      HANDLER <damaged merge table> OPEN.
      
      The assert occurs in MDL_context::destroy when the connection is terminated,
      because all mdl_tickets have not been released.
      MERGE tables do not support being opened using the HANDLER ... OPEN command,
      and trying to do so will result in an error. In the event of an error, all
      tables that are opened, should be closed again. The fix for bug#45781 made
      sure that this also works for MERGE tables, which causes multiple tables to
      be opened.
      This fix extends the fix for bug#45781, by ensuring that also all locks are
      released, when MERGE tables are involved.
      modified:
        mysql-test/r/merge.result
        mysql-test/t/merge.test
        sql/sql_handler.cc

per-file messages:
  mysql-test/r/merge.result
    The result of the test.
  mysql-test/t/merge.test
    Added a test based on the bug report, as well as a test of the more general
    scenario.
  sql/sql_handler.cc
    Added code to release all the locks.
=== modified file 'mysql-test/r/merge.result'
--- a/mysql-test/r/merge.result	2009-09-16 05:36:47 +0000
+++ b/mysql-test/r/merge.result	2009-09-22 11:29:49 +0000
@@ -2423,4 +2423,34 @@ c1
 DROP TRIGGER t2_au;
 DROP FUNCTION f1;
 DROP TABLE tm1, t1, t2, t3, t4, t5;
+#
+# Bug47098 assert in MDL_context::destroy on HANDLER
+#          <damaged merge table> OPEN
+#
+# Test that merge tables are closed correctly when opened using 
+# HANDLER ... OPEN.
+# The general case.
+DROP TABLE IF EXISTS t1, t2, t3;
+# Connection con1.
+CREATE TABLE t1 (c1 int);
+CREATE TABLE t2 (c1 int);
+CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2);
+START TRANSACTION;
+HANDLER t3 OPEN;
+ERROR HY000: Table storage engine for 't3' doesn't have this option
+DROP TABLE t1, t2, t3;
+# Connection default.
+# Disconnecting con1, all mdl_tickets must have been released.
+# The bug-specific case.
+# Connection con1.
+CREATE TABLE t1 (c1 int);
+CREATE TABLE t2 (c1 int);
+CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2);
+DROP TABLE t2;
+START TRANSACTION;
+HANDLER t3 OPEN;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+DROP TABLE t1, t3;
+# Connection default.
+# Disconnecting con1, all mdl_tickets must have been released.
 End of 6.0 tests

=== modified file 'mysql-test/t/merge.test'
--- a/mysql-test/t/merge.test	2009-09-16 05:36:47 +0000
+++ b/mysql-test/t/merge.test	2009-09-22 11:29:49 +0000
@@ -1859,6 +1859,45 @@ DROP TRIGGER t2_au;
 DROP FUNCTION f1;
 DROP TABLE tm1, t1, t2, t3, t4, t5;
 
+--echo #
+--echo # Bug47098 assert in MDL_context::destroy on HANDLER
+--echo #          <damaged merge table> OPEN
+--echo #
+--echo # Test that merge tables are closed correctly when opened using 
+--echo # HANDLER ... OPEN.
+--echo # The general case.
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+--echo # Connection con1.
+connect (con1,localhost,root,,);
+CREATE TABLE t1 (c1 int);
+CREATE TABLE t2 (c1 int);
+CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2);
+START TRANSACTION;
+--error ER_ILLEGAL_HA
+HANDLER t3 OPEN;
+DROP TABLE t1, t2, t3;
+--echo # Connection default.
+connection default;
+--echo # Disconnecting con1, all mdl_tickets must have been released.
+disconnect con1;
+--echo # The bug-specific case.
+--echo # Connection con1.
+connect (con1,localhost,root,,);
+CREATE TABLE t1 (c1 int);
+CREATE TABLE t2 (c1 int);
+CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2);
+DROP TABLE t2;
+START TRANSACTION;
+--error ER_WRONG_MRG_TABLE
+HANDLER t3 OPEN;
+DROP TABLE t1, t3;
+--echo # Connection default.
+connection default;
+--echo # Disconnecting con1, all mdl_tickets must have been released.
+disconnect con1;
+
 --echo End of 6.0 tests
 
 --disable_result_log

=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc	2009-09-18 15:22:02 +0000
+++ b/sql/sql_handler.cc	2009-09-22 11:29:49 +0000
@@ -321,6 +321,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST 
         can close a single table only.
       */
       close_thread_tables(thd);
+      thd->mdl_context.release_all_locks();
       my_error(ER_ILLEGAL_HA, MYF(0), hash_tables->alias);
       error= TRUE;
     }

Thread
bzr commit into mysql-6.0-bugfixing branch (lars-erik.bjork:2831) Bug#47098lars-erik.bjork22 Sep