Debian Codegraph @

mysql-test/suite/rpl/include/rpl_stop_middle_group.test

raw
1 # Proving that stopping in the middle of applying a group of events
2 # does not have immediate effect if a non-transaction table has been changed.
3 # The slave sql thread has to try to finish applying first.
4 # The tests rely on simulation of the killed status.
5 # The matter of testing correlates to some of `rpl_start_stop_slave' that does
6 # not require `have_debug'.
7
8 connection master;
9
10 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
11
12 create table tm (a int auto_increment primary key) engine=myisam;
13 create table ti (a int auto_increment primary key) engine=innodb;
14
15 sync_slave_with_master;
16 SET @saved_dbug = @@GLOBAL.debug_dbug;
17 set @@global.debug_dbug="d,stop_slave_middle_group";
18
19 connection master;
20
21 begin;
22 insert into ti set a=null;
23 insert into tm set a=null; # to simulate killed status on the slave
24 commit;
25
26 connection slave;
27 call 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");
28 call mtr.add_suppression("Slave SQL.*Slave SQL Thread stopped with incomplete event group having non-transactional changes");
29
30 # slave will catch the killed status but won't shut down immediately
31 # only after the whole group has done (commit)
32
33 source include/wait_for_slave_sql_to_stop.inc;
34
35 # checking: no error and the group is finished
36
37 let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
38 let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
39 let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
40 --disable_cursor_protocol
41 --disable_query_log
42 eval SELECT $read = $exec into @check;
43 --enable_query_log
44 --enable_cursor_protocol
45 eval SELECT "NO$error" AS Last_SQL_Error, @check as `true`;
46 select count(*) as one from tm;
47 select count(*) as one from ti;
48
49 set @@global.debug_dbug=@saved_dbug;
50
51 #
52 # bug#45940 issues around rli->last_event_start_time
53 # Testing of slave stopped after it had waited (in vain) for
54 # the group be finished.
55 # It could not be finished because of simulation of failure to
56 # receive the terminal part
57 # The test relay on simulation of the incomplete group in the relay log
58
59 # Two cases are verified: a mixed transacton and a mixed multi-table update.
60 #
61 # The mixed transacton.
62 #
63 source include/start_slave.inc;
64
65 connection master;
66
67 truncate table tm; # cleanup of former tests
68 truncate table ti;
69
70 #connection slave;
71 sync_slave_with_master;
72
73 set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log";
74
75 connection master;
76
77 begin;
78 insert into ti set a=null;
79 insert into tm set a=null;
80 commit;
81
82 connection slave;
83
84 # slave will catch the killed status, won't shut down immediately
85 # but does it eventually having the whole group unfinished (not committed)
86
87 # ER_SLAVE_FATAL_ERROR
88 --let slave_sql_errno= 1593
89 source include/wait_for_slave_sql_error.inc;
90
91 # checking: the error and group unfinished
92
93 let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
94 let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
95 let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
96 --disable_cursor_protocol
97 --disable_query_log
98 eval SELECT $read - $exec > 0 into @check;
99 --enable_query_log
100 --enable_cursor_protocol
101 eval SELECT "$error" AS Last_SQL_Error, @check as `true`;
102 select count(*) as one from tm;
103 select count(*) as zero from ti;
104
105 set @@global.debug_dbug=@saved_dbug;
106
107 #
108 # The mixed multi-table update
109 #
110 stop slave;
111 truncate table tm;
112 source include/start_slave.inc;
113
114 connection master;
115
116 #connection slave;
117 sync_slave_with_master;
118 set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log";
119
120 connection master;
121 update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2;
122
123 connection slave;
124
125 # slave will catch the killed status, won't shut down immediately
126 # but does it eventually having the whole group unfinished (not committed)
127 #
128
129 --let slave_sql_errno= 1593
130 source include/wait_for_slave_sql_error.inc;
131
132 # checking: the error and group unfinished
133
134 let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
135 let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
136 let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
137 --disable_cursor_protocol
138 --disable_query_log
139 eval SELECT $read - $exec > 0 into @check;
140 --enable_query_log
141 --enable_cursor_protocol
142 eval SELECT "$error" AS Last_SQL_Error, @check as `true`;
143 select max(a) as two from tm;
144 select max(a) as one from ti;
145
146 SET @@GLOBAL.debug_dbug = @saved_dbug;
147 #
148 # clean-up
149 #
150
151 # the sql thread has an error, so reset replication state
152 --let $rpl_only_running_threads= 1
153 --source include/rpl_reset.inc
154
155 connection master;
156 drop table tm, ti;
157 --sync_slave_with_master