diff options
author | Konstantin Osipov <kostja@sun.com> | 2009-11-20 22:51:12 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2009-11-20 22:51:12 +0300 |
commit | 1b34d593b5f981b523fdc8e923e2c2eb0da75a31 (patch) | |
tree | eb1d7af310172485cbf7985efd1057955f7a9385 /mysql-test/r | |
parent | fcf6c1548e6b07a2ee9924249f926fd792155418 (diff) | |
download | mariadb-git-1b34d593b5f981b523fdc8e923e2c2eb0da75a31.tar.gz |
Backport of:
------------------------------------------------------------
revno: 2476.784.3
committer: davi@moksha.local
timestamp: Tue 2007-10-02 21:27:31 -0300
message:
Bug#25858 Some DROP TABLE under LOCK TABLES can cause deadlocks
When a client (connection) holds a lock on a table and attempts to
drop (obtain a exclusive lock) on a second table that is already
held by a second client and the second client then attempts to
drop the table that is held by the first client, leads to a
circular wait deadlock. This scenario is very similar to trying to
drop (or rename) a table while holding read locks and are
correctly forbidden.
The solution is to allow a drop table operation to continue only
if the table being dropped is write (exclusively) locked, or if
the table is temporary, or if the client is not holding any
locks. Using this scheme prevents the creation of a circular
chain in which each client is waiting for one table that the
next client in the chain is holding.
This is incompatible change, as can be seen by number of tests
cases that needed to be fixed, but is consistent with respect to
behavior of the different scenarios in which the circular wait
might happen.
mysql-test/r/drop.result:
Test case result for Bug#25858
mysql-test/r/group_by.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/r/insert_notembedded.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table
mysql-test/r/lock.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/r/lock_multi.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/r/myisam.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/r/view.result:
Fix test case result wrt drop table under lock tables -- unlock tables
before dropping table.
mysql-test/t/drop.test:
Add test case for Bug#25858
mysql-test/t/group_by.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/insert_notembedded.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/lock.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/lock_multi.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/myisam.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/query_cache_notembedded.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
mysql-test/t/view.test:
Fix test case: unlock tables in preparation for a drop table. In some
circumstances, dropping tables while holding locks leads to a deadlock.
sql/lock.cc:
When trying to obtain a name lock under lock tables, ensure that the table is properly exclusively locked and fail otherwise.
Diffstat (limited to 'mysql-test/r')
-rw-r--r-- | mysql-test/r/drop.result | 20 | ||||
-rw-r--r-- | mysql-test/r/group_by.result | 3 | ||||
-rw-r--r-- | mysql-test/r/insert_notembedded.result | 1 | ||||
-rw-r--r-- | mysql-test/r/lock.result | 6 | ||||
-rw-r--r-- | mysql-test/r/lock_multi.result | 1 | ||||
-rw-r--r-- | mysql-test/r/myisam.result | 2 | ||||
-rw-r--r-- | mysql-test/r/query_cache_notembedded.result | 1 | ||||
-rw-r--r-- | mysql-test/r/view.result | 3 |
8 files changed, 36 insertions, 1 deletions
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 42739b10d50..54bd05e526f 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -86,6 +86,26 @@ select 1; 1 1 unlock tables; +drop table if exists t1,t2; +create table t1 (a int); +create table t2 (a int); +lock table t1 read; +drop table t2; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +drop table t1; +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +unlock tables; +drop table t1,t2; +create table t1 (i int); +create table t2 (i int); +lock tables t1 read; +lock tables t2 read; +drop table t1; +ERROR HY000: Table 't1' was not locked with LOCK TABLES +drop table t1,t2; +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +unlock tables; +drop table t1,t2; End of 5.0 tests create database mysql_test; create table mysql_test.t1(f1 int); diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 742d4b90807..e6063047ba4 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -107,8 +107,9 @@ SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 cid CONCAT(firstname, ' ', surname) COUNT(call_id) SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname; cid CONCAT(firstname, ' ', surname) COUNT(call_id) -drop table t1,t2; +drop table t2; unlock tables; +drop table t1; CREATE TABLE t1 ( bug_id mediumint(9) NOT NULL auto_increment, groupset bigint(20) DEFAULT '0' NOT NULL, diff --git a/mysql-test/r/insert_notembedded.result b/mysql-test/r/insert_notembedded.result index ac69cb65972..2315d695abe 100644 --- a/mysql-test/r/insert_notembedded.result +++ b/mysql-test/r/insert_notembedded.result @@ -122,5 +122,6 @@ a b connection: default select * from t1; a b +unlock tables; drop table t1; set low_priority_updates=default; diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index 7ec07fb5273..1f8f6aa04ae 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -48,6 +48,9 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +drop table t1,t2; create table t1 (c1 int); create table t2 (c1 int); create table t3 (c1 int); @@ -69,6 +72,9 @@ ERROR HY000: Table 't2' was locked with a READ lock and can't be updated delete t2 from t1,t2 where t1.a=t2.a; ERROR HY000: Table 't2' was locked with a READ lock and can't be updated drop table t1,t2; +ERROR HY000: Table 't2' was locked with a READ lock and can't be updated +unlock tables; +drop table t2,t1; End of 4.1 tests. drop table if exists t1; create table t1 (a int); diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index d8768e802ea..49e51631b91 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -27,6 +27,7 @@ update t1,t2 set c=a where b=d; select c from t2; c 2 +unlock tables; drop table t1; drop table t2; create table t1 (a int); diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 95fdc4fb93d..16e8a8e5ad1 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -529,6 +529,7 @@ select straight_join * from t1,t2 force index (primary) where t1.a=t2.a; a a b 1 1 1 2 2 1 +unlock tables; drop table t1,t2; CREATE TABLE t1 (c1 varchar(250) NOT NULL); CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1)); @@ -542,6 +543,7 @@ INSERT INTO t2 VALUES ('test000001'), ('test000005'); SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2 WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1; t1c1 t2c1 +UNLOCK TABLES; DROP TABLE t1,t2; CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM; Got one of the listed errors diff --git a/mysql-test/r/query_cache_notembedded.result b/mysql-test/r/query_cache_notembedded.result index d9bf7a6d814..25894634bf3 100644 --- a/mysql-test/r/query_cache_notembedded.result +++ b/mysql-test/r/query_cache_notembedded.result @@ -93,6 +93,7 @@ a 3 SELECT * FROM t1; a +UNLOCK TABLES; drop table t1; flush query cache; reset query cache; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 69bcf349f51..2df2b0bafa6 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1104,6 +1104,9 @@ select * from t2; ERROR HY000: Table 't2' was not locked with LOCK TABLES drop view v1; drop table t1, t2; +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +unlock tables; +drop table t1, t2; create table t1 (a int); create view v1 as select * from t1 where a < 2 with check option; insert into v1 values(1); |