Commit cff7f022 authored by Jon Olav Hauglid's avatar Jon Olav Hauglid

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.
parent 52306698
...@@ -16,21 +16,19 @@ drop schema foo; ...@@ -16,21 +16,19 @@ drop schema foo;
# Bug #48940 MDL deadlocks against mysql_rm_db # Bug #48940 MDL deadlocks against mysql_rm_db
# #
DROP SCHEMA IF EXISTS schema1; DROP SCHEMA IF EXISTS schema1;
DROP SCHEMA IF EXISTS schema2;
# Connection default # Connection default
CREATE SCHEMA schema1; CREATE SCHEMA schema1;
CREATE SCHEMA schema2;
CREATE TABLE schema1.t1 (a INT); CREATE TABLE schema1.t1 (a INT);
SET autocommit= FALSE; SET autocommit= FALSE;
INSERT INTO schema1.t1 VALUES (1); INSERT INTO schema1.t1 VALUES (1);
# Connection 2 # Connection 2
DROP SCHEMA schema1; DROP SCHEMA schema1;
# Connection default # 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; SET autocommit= TRUE;
# Connection 2 # Connection 2
# Connection default # Connection default
DROP SCHEMA schema2;
# #
# Bug #49988 MDL deadlocks with mysql_create_db, reload_acl_and_cache # Bug #49988 MDL deadlocks with mysql_create_db, reload_acl_and_cache
# #
......
...@@ -4041,7 +4041,9 @@ connection default; ...@@ -4041,7 +4041,9 @@ connection default;
--echo # Connection con2 --echo # Connection con2
connection con2; connection con2;
--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 --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 --reap
...@@ -4153,7 +4155,9 @@ connection default; ...@@ -4153,7 +4155,9 @@ connection default;
--echo # Connection con2 --echo # Connection con2
connection con2; connection con2;
--echo # Reaping: RENAME TABLE test.t2 TO db1.t2 --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 --reap
DROP TABLE test.t2; DROP TABLE test.t2;
......
...@@ -23,7 +23,6 @@ drop schema foo; ...@@ -23,7 +23,6 @@ drop schema foo;
--disable_warnings --disable_warnings
DROP SCHEMA IF EXISTS schema1; DROP SCHEMA IF EXISTS schema1;
DROP SCHEMA IF EXISTS schema2;
--enable_warnings --enable_warnings
connect(con2, localhost, root); connect(con2, localhost, root);
...@@ -32,7 +31,6 @@ connect(con2, localhost, root); ...@@ -32,7 +31,6 @@ connect(con2, localhost, root);
connection default; connection default;
CREATE SCHEMA schema1; CREATE SCHEMA schema1;
CREATE SCHEMA schema2;
CREATE TABLE schema1.t1 (a INT); CREATE TABLE schema1.t1 (a INT);
SET autocommit= FALSE; SET autocommit= FALSE;
...@@ -48,7 +46,10 @@ let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist ...@@ -48,7 +46,10 @@ let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
WHERE state= 'Waiting for table metadata lock' WHERE state= 'Waiting for table metadata lock'
AND info='DROP SCHEMA schema1'; AND info='DROP SCHEMA schema1';
--source include/wait_condition.inc --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; SET autocommit= TRUE;
--echo # Connection 2 --echo # Connection 2
...@@ -57,7 +58,6 @@ connection con2; ...@@ -57,7 +58,6 @@ connection con2;
--echo # Connection default --echo # Connection default
connection default; connection default;
DROP SCHEMA schema2;
disconnect con2; disconnect con2;
......
...@@ -188,8 +188,6 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent) ...@@ -188,8 +188,6 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
if (!error) if (!error)
query_cache_invalidate3(thd, table_list, 0); query_cache_invalidate3(thd, table_list, 0);
thd->mdl_context.release_transactional_locks();
err: err:
thd->global_read_lock.start_waiting_global_read_lock(thd); thd->global_read_lock.start_waiting_global_read_lock(thd);
DBUG_RETURN(error || binlog_error); DBUG_RETURN(error || binlog_error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment