~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/flush_block_commit.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Let's see if FLUSH TABLES WITH READ LOCK blocks COMMIT of existing
 
2
# transactions.
 
3
# We verify that we did not introduce a deadlock.
 
4
# This is intended to mimick how mysqldump and innobackup work.
 
5
 
 
6
# And it requires InnoDB
 
7
--source include/have_innodb.inc
 
8
 
 
9
# Save the initial number of concurrent sessions
 
10
--source include/count_sessions.inc
 
11
 
 
12
--echo # Establish connection con1 (user=root)
 
13
connect (con1,localhost,root,,);
 
14
--echo # Establish connection con2 (user=root)
 
15
connect (con2,localhost,root,,);
 
16
--echo # Establish connection con3 (user=root)
 
17
connect (con3,localhost,root,,);
 
18
--echo # Switch to connection con1
 
19
connection con1;
 
20
 
 
21
--disable_warnings
 
22
DROP TABLE IF EXISTS t1;
 
23
--enable_warnings
 
24
CREATE TABLE t1 (a INT) ENGINE=innodb;
 
25
 
 
26
# blocks COMMIT ?
 
27
 
 
28
BEGIN;
 
29
INSERT INTO t1 VALUES(1);
 
30
--echo # Switch to connection con2
 
31
connection con2;
 
32
FLUSH TABLES WITH READ LOCK;
 
33
SELECT * FROM t1;
 
34
--echo # Switch to connection con1
 
35
connection con1;
 
36
send COMMIT; # blocked by con2
 
37
sleep 1;
 
38
--echo # Switch to connection con2
 
39
connection con2;
 
40
SELECT * FROM t1; # verify con1 was blocked and data did not move
 
41
UNLOCK TABLES;
 
42
--echo # Switch to connection con1
 
43
connection con1;
 
44
reap;
 
45
 
 
46
# No deadlock ?
 
47
 
 
48
--echo # Switch to connection con1
 
49
connection con1;
 
50
BEGIN;
 
51
SELECT * FROM t1 FOR UPDATE;
 
52
--echo # Switch to connection con2
 
53
connection con2;
 
54
BEGIN;
 
55
send SELECT * FROM t1 FOR UPDATE; # blocked by con1
 
56
sleep 1;
 
57
--echo # Switch to connection con3
 
58
connection con3;
 
59
send FLUSH TABLES WITH READ LOCK; # blocked by con2
 
60
--echo # Switch to connection con1
 
61
connection con1;
 
62
COMMIT; # should not be blocked by con3
 
63
--echo # Switch to connection con2
 
64
connection con2;
 
65
reap;
 
66
--echo # Switch to connection con3
 
67
connection con3;
 
68
reap;
 
69
UNLOCK TABLES;
 
70
 
 
71
# Bug#6732 FLUSH TABLES WITH READ LOCK + COMMIT hangs later FLUSH TABLES
 
72
#          WITH READ LOCK
 
73
 
 
74
--echo # Switch to connection con2
 
75
connection con2;
 
76
COMMIT; # unlock InnoDB row locks to allow insertions
 
77
--echo # Switch to connection con1
 
78
connection con1;
 
79
BEGIN;
 
80
INSERT INTO t1 VALUES(10);
 
81
FLUSH TABLES WITH READ LOCK;
 
82
COMMIT;
 
83
UNLOCK TABLES;
 
84
--echo # Switch to connection con2
 
85
connection con2;
 
86
FLUSH TABLES WITH READ LOCK; # bug caused hang here
 
87
UNLOCK TABLES;
 
88
 
 
89
# Bug#7358 SHOW CREATE DATABASE fails if open transaction
 
90
 
 
91
BEGIN;
 
92
SELECT * FROM t1;
 
93
SHOW CREATE DATABASE test;
 
94
 
 
95
DROP TABLE t1;
 
96
 
 
97
 
 
98
# Cleanup
 
99
--echo # Switch to connection default and close connections con1, con2, con3
 
100
connection default;
 
101
disconnect con1;
 
102
disconnect con2;
 
103
disconnect con3;
 
104
 
 
105
# End of 4.1 tests
 
106
 
 
107
# Wait till all disconnects are completed
 
108
--source include/wait_until_count_sessions.inc
 
109