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--source include/have_log_bin.inc
7
8# And it requires InnoDB
9--source include/have_log_bin.inc
10--source include/have_innodb.inc
11
12--echo # Save the initial number of concurrent sessions
13--source include/count_sessions.inc
14
15
16connect (con1,localhost,root,,);
17connect (con2,localhost,root,,);
18
19# FLUSH TABLES WITH READ LOCK should block writes to binlog too
20connection con1;
21CREATE TABLE t1 (a INT) ENGINE=innodb;
22RESET MASTER;
23SET AUTOCOMMIT=0;
24SELECT 1;
25connection con2;
26FLUSH TABLES WITH READ LOCK;
27--source include/show_binlog_events.inc
28connection con1;
29send INSERT INTO t1 VALUES (1);
30connection con2;
31sleep 1;
32--source include/show_binlog_events.inc
33UNLOCK TABLES;
34connection con1;
35reap;
36DROP TABLE t1;
37SET AUTOCOMMIT=1;
38
39# GLR blocks new transactions
40create table t1 (a int) engine=innodb;
41connection con1;
42flush tables with read lock;
43connection con2;
44begin;
45--send insert into t1 values (1);
46connection con1;
47let $wait_condition=
48  select count(*) = 1 from information_schema.processlist
49  where state = "Waiting for backup lock" and
50        info = "insert into t1 values (1)";
51--source include/wait_condition.inc
52unlock tables;
53connection con2;
54--reap
55commit;
56drop table t1;
57
58connection default;
59disconnect con1;
60disconnect con2;
61
62--echo # Wait till all disconnects are completed
63--source include/wait_until_count_sessions.inc
64
65