List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:August 10 2010 11:17am
Subject:bzr push into mysql-5.5-bugfixing branch (jon.hauglid:3097 to 3098) Bug#54360
View as plain text  
 3098 Jon Olav Hauglid	2010-08-10
      Followup for Bug #54360 Deadlock DROP/ALTER/CREATE DATABASE
                              with open HANDLER
      
      This patch changes the code for table renames to not drop metadata
      locks. Since table renames are done as a part of ALTER DATABASE ...
      UPGRADE, dropping metadata locks in the middle of execution can
      result in wrong binlog order since it means that no locks are held
      when the binlog is written to.
      
      The RENAME TABLE statement is unafffected since it auto commits and
      therefore already drops metadata locks at the end of execution.
      
      This patch also reverts the regression test for Bug#48940 back to
      its original version. The test was temporarily changed due to the
      issue mentioned above.

    modified:
      mysql-test/r/schema.result
      mysql-test/t/mdl_sync.test
      mysql-test/t/schema.test
      sql/sql_rename.cc
 3097 Konstantin Osipov	2010-08-09
      A fix for Bug#41158 "DROP TABLE holds LOCK_open during unlink()". 
      
      Remove acquisition of LOCK_open around file system operations,
      since such operations are now protected by metadata locks.
      Rework table discovery algorithm to not require LOCK_open.
      
      No new tests added since all MDL locking operations are covered
      in lock.test and mdl_sync.test, and as long as these tests
      pass despite the increased concurrency, consistency must be
      unaffected.
     @ mysql-test/t/disabled.def
        Disable NDB tests due to Bug#55799.
     @ sql/datadict.cc
        No longer necessary to protect ha_create_table() with
        LOCK_open. Serial execution is now ensured by metadata
        locks.
     @ sql/ha_ndbcluster.cc
        Do not manipulate with LOCK_open in cluster code.
     @ sql/ha_ndbcluster_binlog.cc
        Do not manipulate with LOCK_open in cluster code.
     @ sql/ha_ndbcluster_binlog.h
        Update function signature.
     @ sql/handler.cc
        Implement ha_check_if_table_exists().
        @todo: some engines provide ha_table_exists_in_engine()
        handlerton call, for those we perhaps shouldn't
        call ha_discover(), to be more efficient.
        Since currently it's only NDB, postpone till
        integration with NDB.
     @ sql/handler.h
        Declare ha_check_if_table_exists() function.
     @ sql/mdl.cc
        Remove an obsolete comment.
     @ sql/sql_base.cc
        Update to a new signature of close_cached_tables():
        from now on we always call it without LOCK_open.
        Update comments.
        Remove get_table_share_with_create(), we should
        not attempt to create a table under LOCK_open.
        Introduce get_table_share_with_discover() instead,
        which would request a back off action if the table
        exists in engine.
        Remove acquisition of LOCK_open for 
        data dictionary operations, such as check_if_table_exists().
        Do not use get_table_share_with_create/discover for views,
        where it's not needed.
        Make tdc_remove_table() optionally acquire LOCK_open
        to simplify usage of this function.
        Use the right mutex in the partitioning code when
        manipulating with thd->open_tables.
     @ sql/sql_base.h
        Update signatures of changes functions.
     @ sql/sql_insert.cc
        Do not wrap quick_rm_table() with LOCK_open acquisition, 
        this is unnecessary.
     @ sql/sql_parse.cc
        Update to the new calling convention of tdc_remove_table().
        Update to the new signature of close_cached_tables().
        Update comments.
     @ sql/sql_rename.cc
        Update to the new calling convention of tdc_remove_table().
        Remove acquisition of LOCK_open around filesystem
        operations.
     @ sql/sql_show.cc
        Remove get_trigger_table_impl().
        Do not acquire LOCK_open for a dirty read of the trigger
        file.
     @ sql/sql_table.cc
        Do not acquire LOCK_open for filesystem operations.
     @ sql/sql_trigger.cc
        Do not require LOCK_open for trigger file I/O.
     @ sql/sql_truncate.cc
        Update to the new signature of tdc_remove_table().
     @ sql/sql_view.cc
        Do not require LOCK_open for view I/O.
        Use tdc_remove_table() to expel view share.
        Update comments.
     @ sql/sys_vars.cc
        Update to the new signature of close_cached_tables().

    modified:
      mysql-test/t/disabled.def
      sql/datadict.cc
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_ndbcluster_binlog.h
      sql/handler.cc
      sql/handler.h
      sql/mdl.cc
      sql/sql_base.cc
      sql/sql_base.h
      sql/sql_insert.cc
      sql/sql_parse.cc
      sql/sql_rename.cc
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sql_trigger.cc
      sql/sql_truncate.cc
      sql/sql_view.cc
      sql/sys_vars.cc
=== modified file 'mysql-test/r/schema.result'
--- a/mysql-test/r/schema.result	2010-07-19 08:27:53 +0000
+++ b/mysql-test/r/schema.result	2010-08-10 11:16:44 +0000
@@ -16,21 +16,19 @@ drop schema foo;
 # Bug #48940 MDL deadlocks against mysql_rm_db
 #
 DROP SCHEMA IF EXISTS schema1;
-DROP SCHEMA IF EXISTS schema2;
 # Connection default
 CREATE SCHEMA schema1;
-CREATE SCHEMA schema2;
 CREATE TABLE schema1.t1 (a INT);
 SET autocommit= FALSE;
 INSERT INTO schema1.t1 VALUES (1);
 # Connection 2
 DROP SCHEMA schema1;
 # Connection default
-ALTER SCHEMA schema2 DEFAULT CHARACTER SET utf8;
+ALTER SCHEMA schema1 DEFAULT CHARACTER SET utf8;
+Got one of the listed errors
 SET autocommit= TRUE;
 # Connection 2
 # Connection default
-DROP SCHEMA schema2;
 #
 # Bug #49988 MDL deadlocks with mysql_create_db, reload_acl_and_cache
 #

=== modified file 'mysql-test/t/mdl_sync.test'
--- a/mysql-test/t/mdl_sync.test	2010-08-06 11:29:37 +0000
+++ b/mysql-test/t/mdl_sync.test	2010-08-10 11:16:44 +0000
@@ -4041,7 +4041,9 @@ connection default;
 --echo # Connection con2
 connection con2;
 --echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
---error 1,1 # Wrong error pending followup patch for bug#54360
+# Error 1 is from ALTER DATABASE when the database does not exist.
+# Listing the error twice to prevent result diffences based on filename.
+--error 1,1
 --reap
 
 
@@ -4153,7 +4155,9 @@ connection default;
 --echo # Connection con2
 connection con2;
 --echo # Reaping: RENAME TABLE test.t2 TO db1.t2
---error 7, 7 # Wrong error pending followup patch for bug#54360
+# Error 7 is from RENAME TABLE where the target database does not exist.
+# Listing the error twice to prevent result diffences based on filename.
+--error 7, 7
 --reap
 DROP TABLE test.t2;
 

=== modified file 'mysql-test/t/schema.test'
--- a/mysql-test/t/schema.test	2010-08-06 11:29:37 +0000
+++ b/mysql-test/t/schema.test	2010-08-10 11:16:44 +0000
@@ -23,7 +23,6 @@ drop schema foo;
 
 --disable_warnings
 DROP SCHEMA IF EXISTS schema1;
-DROP SCHEMA IF EXISTS schema2;
 --enable_warnings
 
 connect(con2, localhost, root);
@@ -32,7 +31,6 @@ connect(con2, localhost, root);
 connection default;
 
 CREATE SCHEMA schema1;
-CREATE SCHEMA schema2;
 CREATE TABLE schema1.t1 (a INT);
 
 SET autocommit= FALSE;
@@ -48,7 +46,10 @@ let $wait_condition= SELECT COUNT(*)= 1 
                      WHERE state= 'Waiting for table metadata lock' 
                      AND info='DROP SCHEMA schema1';
 --source include/wait_condition.inc
-ALTER SCHEMA schema2 DEFAULT CHARACTER SET utf8;
+# Error 1 is from ALTER DATABASE when the database does not exist.
+# Listing the error twice to prevent result diffences based on filename.
+--error 1,1
+ALTER SCHEMA schema1 DEFAULT CHARACTER SET utf8;
 SET autocommit= TRUE;
 
 --echo # Connection 2
@@ -57,7 +58,6 @@ connection con2;
 
 --echo # Connection default
 connection default;
-DROP SCHEMA schema2;
 disconnect con2;
 
 

=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc	2010-08-09 18:33:47 +0000
+++ b/sql/sql_rename.cc	2010-08-10 11:16:44 +0000
@@ -188,8 +188,6 @@ bool mysql_rename_tables(THD *thd, TABLE
   if (!error)
     query_cache_invalidate3(thd, table_list, 0);
 
-  thd->mdl_context.release_transactional_locks();
-
 err:
   thd->global_read_lock.start_waiting_global_read_lock(thd);
   DBUG_RETURN(error || binlog_error);


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20100810111644-mw70sezkzj2j341w.bundle
Thread
bzr push into mysql-5.5-bugfixing branch (jon.hauglid:3097 to 3098) Bug#54360Jon Olav Hauglid10 Aug