1source include/have_innodb.inc;
2source include/have_debug.inc;
3source include/have_debug_sync.inc;
4source include/have_binlog_format_mixed_or_statement.inc;
5source include/master-slave.inc;
6
7--echo
8--echo # BUG#56118 STOP SLAVE does not wait till trx with CREATE TMP TABLE ends
9--echo #
10--echo # If a temporary table is created or dropped, the transaction should be
11--echo # regarded similarly that a non-transactional table is modified. So
12--echo # STOP SLAVE should wait until the transaction has finished.
13
14CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
15CREATE TABLE t2(c1 INT) ENGINE=InnoDB;
16
17sync_slave_with_master;
18SET DEBUG_SYNC= 'RESET';
19source include/stop_slave.inc;
20
21--echo
22--echo # Suspend the INSERT statement in current transaction on SQL thread.
23--echo # It guarantees that SQL thread is applying the transaction when
24--echo # STOP SLAVE command launchs.
25SET @saved_dbug = @@GLOBAL.debug_dbug;
26set global debug_dbug= '+d,after_mysql_insert';
27source include/start_slave.inc;
28
29--echo
30--echo # CREATE TEMPORARY TABLE with InnoDB engine
31--echo # -----------------------------------------
32let $tmp_table_stm= CREATE TEMPORARY TABLE tt1(c1 INT) ENGINE = InnoDB;
33source include/rpl_stop_slave.test;
34
35--echo
36--echo # CREATE TEMPORARY TABLE ... SELECT with InnoDB engine
37--echo # ----------------------------------------------------
38let $tmp_table_stm= CREATE TEMPORARY TABLE tt1(c1 INT) ENGINE = InnoDB
39                    SELECT c1 FROM t2;
40source include/rpl_stop_slave.test;
41
42# Don't need to verify 'CREATE TEMPORARY TABLE' with MyIASM engine, as it
43# never is binlogged into a transaction since 5.5.
44
45--echo
46--echo # Test end
47SET @@GLOBAL.debug_dbug = @saved_dbug;
48source include/restart_slave_sql.inc;
49
50connection slave;
51call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
52connection master;
53
54DROP TABLE t1, t2;
55
56--echo
57--echo # Bug#58546 test rpl_packet timeout failure sporadically on PB
58--echo # ----------------------------------------------------------------------
59--echo # STOP SLAVE stopped IO thread first and then stopped SQL thread. It was
60--echo # possible that IO thread stopped after replicating part of a transaction
61--echo # which SQL thread was executing. SQL thread would be hung if the
62--echo # transaction could not be rolled back safely.
63--echo # It caused some sporadic failures on PB2.
64--echo #
65--echo # This test verifies that when 'STOP SLAVE' is issued by a user, IO
66--echo # thread will continue to fetch the rest events of the transaction which
67--echo # is being executed by SQL thread and is not able to be rolled back safely.
68
69CREATE TABLE t1 (c1 INT KEY, c2 INT) ENGINE=InnoDB;
70CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
71INSERT INTO t1 VALUES(1, 1);
72
73sync_slave_with_master;
74--source include/stop_slave.inc
75
76connection master;
77# make sure that there are no zombie threads
78--source include/stop_dump_threads.inc
79
80SET @saved_dbug = @@GLOBAL.debug_dbug;
81set global debug_dbug= '+d,dump_thread_wait_before_send_xid';
82
83connection slave;
84--source include/start_slave.inc
85
86BEGIN;
87UPDATE t1 SET c2 = 2 WHERE c1 = 1;
88
89connection master;
90BEGIN;
91INSERT INTO t1 VALUES(2, 2);
92INSERT INTO t2 VALUES(1);
93UPDATE t1 SET c2 = 3 WHERE c1 = 1;
94COMMIT;
95
96# wait for the dump thread reach the sync point
97--let $wait_condition= select count(*)=1 from information_schema.processlist where state LIKE '%debug sync point%' and command='Binlog Dump'
98--source include/wait_condition.inc
99
100connection slave1;
101let $show_statement= SHOW PROCESSLIST;
102let $field= Info;
103let $condition= = 'UPDATE t1 SET c2 = 3 WHERE c1 = 1';
104source include/wait_show_condition.inc;
105
106send STOP SLAVE;
107
108connection slave;
109ROLLBACK;
110
111connection master;
112
113SET DEBUG_SYNC= 'now SIGNAL signal.continue';
114SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
115
116connection slave;
117source include/wait_for_slave_to_stop.inc;
118
119connection slave1;
120reap;
121
122# Slave has stopped, thence lets make sure that
123# we kill the zombie dump threads. Also, make
124# sure that we disable the DBUG_EXECUTE_IF
125# that would set the dump thread to wait
126connection master;
127SET @@GLOBAL.debug_dbug = @saved_dbug;
128# make sure that there are no zombie threads
129--source include/stop_dump_threads.inc
130
131connection slave1;
132# now the dump thread on the master will start
133# from a clean slate, i.e. without the
134# DBUG_EXECUTE_IF set
135source include/start_slave.inc;
136
137connection master;
138DROP TABLE t1, t2;
139--source include/rpl_end.inc
140SET DEBUG_SYNC= 'RESET';
141