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 List-Archive: http://lists.mysql.com/commits/115395 X-Bug: 54360 Message-Id: <201008101117.o7AAs1ZH003770@acsinet15.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3731561848611993770==" --===============3731561848611993770== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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); --===============3731561848611993770== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/jon.hauglid@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: jon.hauglid@stripped # target_branch: file:///export/home/x/mysql-5.5-runtime-bug54360/ # testament_sha1: dc73e27f6364a4f2c0666b1eb62f0d1ce9c08c0c # timestamp: 2010-08-10 13:17:24 +0200 # base_revision_id: kostja@stripped # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWWPzgJAAA+9/gEAQBABYZ/// f9feAL////BgCM+8TRoAAQIVXTVd3coFVQGSjTUepkNE2mjTUwaJowjACYAAEqRAaeoyPQmQaBkA AAAAAOaMmJgAmIwI0wIMRgmTAIwSIiEwmo00yU9TabQaT1EMg0HqeiHpqemoOaMmJgAmIwI0wIMR gmTAIwSSAQAEAmQAJNpNTynlMMoAzUeDovvwBVYc6MMSjw7jkuZylx/So0fBl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