Commit 97d2a923 authored by Konstantin Osipov's avatar Konstantin Osipov

Merge with next-4284.

parents 463dcbb5 5ce2421b
#
# Bug #22876 Four-way deadlock
#
DROP TABLE IF EXISTS t1;
# Connection 1
set @@autocommit=0;
CREATE TABLE t1(s1 INT UNIQUE) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
# Connection 2
set @@autocommit=0;
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (1);
# Connection 3
set @@autocommit=0;
DROP TABLE t1;
# Connection 1
# Connection 1 is now holding the lock.
# Issuing insert from connection 1 while connection 2&3
# is waiting for the lock should give a deadlock error.
INSERT INTO t1 VALUES (2);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Cleanup
commit;
commit;
...@@ -319,5 +319,27 @@ alter table t1 add column j int; ...@@ -319,5 +319,27 @@ alter table t1 add column j int;
unlock tables; unlock tables;
drop table t1; drop table t1;
# #
# Bug#45066 FLUSH TABLES WITH READ LOCK deadlocks against
# LOCK TABLE
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT);
LOCK TABLE t1 READ;
FLUSH TABLES;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
LOCK TABLE t1 WRITE;
FLUSH TABLES;
#
# If you allow the next combination, you reintroduce bug Bug#45066
#
LOCK TABLE t1 READ;
FLUSH TABLES WITH READ LOCK;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
LOCK TABLE t1 WRITE;
FLUSH TABLES WITH READ LOCK;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
DROP TABLE t1;
#
# End of 6.0 tests. # End of 6.0 tests.
# #
...@@ -82,3 +82,48 @@ FLUSH LOGS; ...@@ -82,3 +82,48 @@ FLUSH LOGS;
FLUSH LOGS; FLUSH LOGS;
DROP DATABASE mysqltest1; DROP DATABASE mysqltest1;
End of 5.1 tests End of 5.1 tests
#
# Bug#39675 rename tables on innodb tables with pending
# transactions causes slave data issue.
#
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
CREATE TABLE t1 (
id INT PRIMARY KEY auto_increment,
b INT DEFAULT NULL
) ENGINE=InnoDB;
CREATE TABLE t2 (
id INT PRIMARY KEY auto_increment,
b INT DEFAULT NULL
) ENGINE=InnoDB;
INSERT INTO t1 (b) VALUES (1),(2),(3);
BEGIN;
INSERT INTO t1(b) VALUES (4);
-------- switch to master1 --------
RENAME TABLE t1 TO t3, t2 TO t1;;
-------- switch to master --------
COMMIT;
-------- switch to master1 --------
-------- switch to master --------
SELECT * FROM t1;
id b
SELECT * FROM t3;
id b
1 1
2 2
3 3
4 4
-------- switch to slave --------
SELECT * FROM t1;
id b
SELECT * FROM t3;
id b
1 1
2 2
3 3
4 4
-------- switch to master --------
DROP TABLE t1;
DROP TABLE t3;
End of 6.0 tests
...@@ -120,6 +120,71 @@ connection master; ...@@ -120,6 +120,71 @@ connection master;
FLUSH LOGS; FLUSH LOGS;
DROP DATABASE mysqltest1; DROP DATABASE mysqltest1;
-- source include/master-slave-end.inc
--echo End of 5.1 tests --echo End of 5.1 tests
--echo #
--echo # Bug#39675 rename tables on innodb tables with pending
--echo # transactions causes slave data issue.
--echo #
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
--enable_warnings
CREATE TABLE t1 (
id INT PRIMARY KEY auto_increment,
b INT DEFAULT NULL
) ENGINE=InnoDB;
CREATE TABLE t2 (
id INT PRIMARY KEY auto_increment,
b INT DEFAULT NULL
) ENGINE=InnoDB;
INSERT INTO t1 (b) VALUES (1),(2),(3);
BEGIN;
INSERT INTO t1(b) VALUES (4);
--echo -------- switch to master1 --------
connection master1;
--send RENAME TABLE t1 TO t3, t2 TO t1;
--echo -------- switch to master --------
connection master;
# Need to wait until RENAME is received
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE info = "RENAME TABLE t1 TO t3, t2 TO t1" and
state = "Waiting for table";
--source include/wait_condition.inc
COMMIT;
--echo -------- switch to master1 --------
connection master1;
--reap
--echo -------- switch to master --------
connection master;
SELECT * FROM t1;
SELECT * FROM t3;
sync_slave_with_master;
--echo -------- switch to slave --------
connection slave;
SELECT * FROM t1;
SELECT * FROM t3;
--echo -------- switch to master --------
connection master;
DROP TABLE t1;
DROP TABLE t3;
--echo End of 6.0 tests
--source include/master-slave-end.inc
--innodb_lock_wait_timeout=300
-- source include/have_innodb.inc
--echo #
--echo # Bug #22876 Four-way deadlock
--echo #
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connect (con3,localhost,root,,);
--echo # Connection 1
connection con1;
set @@autocommit=0;
CREATE TABLE t1(s1 INT UNIQUE) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
--echo # Connection 2
connection con2;
set @@autocommit=0;
INSERT INTO t1 VALUES (2);
--send INSERT INTO t1 VALUES (1)
--echo # Connection 3
connection con3;
set @@autocommit=0;
--send DROP TABLE t1
--echo # Connection 1
connection con1;
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE info = "INSERT INTO t1 VALUES (1)" and
state = "update";
--source include/wait_condition.inc
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE info = "DROP TABLE t1" and
state = "Waiting for table";
--source include/wait_condition.inc
--echo # Connection 1 is now holding the lock.
--echo # Issuing insert from connection 1 while connection 2&3
--echo # is waiting for the lock should give a deadlock error.
--error ER_LOCK_DEADLOCK
INSERT INTO t1 VALUES (2);
--echo # Cleanup
connection con2;
--reap
commit;
connection con1;
commit;
connection con3;
--reap
connection default;
...@@ -385,6 +385,38 @@ alter table t1 add column j int; ...@@ -385,6 +385,38 @@ alter table t1 add column j int;
unlock tables; unlock tables;
drop table t1; drop table t1;
--echo #
--echo # Bug#45066 FLUSH TABLES WITH READ LOCK deadlocks against
--echo # LOCK TABLE
--echo #
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1(a INT);
LOCK TABLE t1 READ;
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
FLUSH TABLES;
LOCK TABLE t1 WRITE;
FLUSH TABLES;
--echo #
--echo # If you allow the next combination, you reintroduce bug Bug#45066
--echo #
LOCK TABLE t1 READ;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
FLUSH TABLES WITH READ LOCK;
LOCK TABLE t1 WRITE;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;
DROP TABLE t1;
--echo # --echo #
--echo # End of 6.0 tests. --echo # End of 6.0 tests.
--echo # --echo #
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