Debian Codegraph @

mysql-test/suite/group_replication/t/gr_stop_gr_kills_binlog_dump.test

raw
1 ################################################################################
2 # Test case to verify that binlog dump thread is stopped on:
3 # 1. STOP GR
4 # 2. Member leaves the group on error
5 #
6 # Test:
7 # 0. This test requires 3 members.
8 # M1 and M2 are connected through GR.
9 # M3 connects with M1 and M2 through asynchronous replication.
10 # 1. Start GR on M1(primary) and create table t1.
11 # 2. Start M2.
12 # 3. Create and start new channel ch3_1: M1(master), M3(slave)
13 # and ch4_1: M1(master), M4(slave).
14 # 4. Insert row on M1 and table t1 with binlog off.
15 # 5. Insert same row in M2 so that M1 stops due to primary key coflict.
16 # 6. Wait for GR to ERROR out on M1.
17 # 7. Assert channels ch3_1 and ch4_1 have errored out.
18 # Assert binlog dump thread is not present in threads table.
19 # 8. Restore M3 channel.
20 # 9. Start GR on M1 and channel ch3_1: M1(master), M3(slave)
21 # and ch4_1: M1(master), M4(slave).
22 # 10. Stop GR on M1.
23 # 11. Assert channels ch3_1 and ch4_1 have errored out.
24 # Assert binlog dump thread is not present in threads table.
25 # 12. Cleanup
26 ################################################################################
27
28 --source include/big_test.inc
29 --source include/have_group_replication_plugin.inc
30 --let $rpl_server_count=4
31 --let $rpl_skip_group_replication_start= 1
32 --let $rpl_group_replication_single_primary_mode=1
33 --source include/group_replication.inc
34
35 --echo
36 --echo # 1. Start GR on M1(primary) and create table t1.
37 --let $rpl_connection_name= server1
38 --source include/rpl_connection.inc
39 --let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
40
41 set session sql_log_bin=0;
42 call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Could not execute Write_rows event on table .*");
43 call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Worker . failed executing transaction .*");
44 call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': ... The replica coordinator and worker threads are stopped, .*");
45 call mtr.add_suppression("Replica: Duplicate entry '.' for key 't1.PRIMARY' Error_code: MY-001062");
46 call mtr.add_suppression("The applier thread execution was aborted. .*");
47 call mtr.add_suppression("Error running query, replica SQL thread aborted. .*");
48 call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
49 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
50 call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
51 set session sql_log_bin=1;
52
53 --source include/start_and_bootstrap_group_replication.inc
54 CREATE TABLE test.t1 (a INT PRIMARY KEY NOT NULL);
55 INSERT INTO test.t1 values (1);
56
57 --echo
58 --echo # 2. Start M2.
59 --let $rpl_connection_name= server2
60 --source include/rpl_connection.inc
61
62 --source include/start_group_replication.inc
63
64 --echo
65 --echo # 3. Create and start new channel ch3_1: M1(master), M3(slave)
66 --echo # and ch4_1: M1(master), M4(slave).
67
68 --let $rpl_connection_name= server3
69 --source include/rpl_connection.inc
70
71 set session sql_log_bin=0;
72 call mtr.add_suppression("Error reading packet from server for channel 'ch3_1': .*");
73 set session sql_log_bin=1;
74
75 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
76 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='localhost', SOURCE_USER='root', SOURCE_PORT=$SERVER_MYPORT_1 for channel 'ch3_1'
77
78 --let $rpl_channel_name='ch3_1'
79 --source include/start_slave.inc
80 --let $rpl_channel_name=
81
82 --let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.tables WHERE TABLE_SCHEMA="test" AND TABLE_NAME="t1"
83 --source include/wait_condition.inc
84
85 --let $wait_condition= SELECT COUNT(*)=1 FROM test.t1 WHERE a=1
86 --source include/wait_condition.inc
87
88 --let $rpl_connection_name= server4
89 --source include/rpl_connection.inc
90
91 set session sql_log_bin=0;
92 call mtr.add_suppression("Error reading packet from server for channel 'ch4_1': .*");
93 set session sql_log_bin=1;
94
95 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
96 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='localhost', SOURCE_USER='root', SOURCE_PORT=$SERVER_MYPORT_1 for channel 'ch4_1'
97
98 --let $rpl_channel_name='ch4_1'
99 --source include/start_slave.inc
100 --let $rpl_channel_name=
101
102 --let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.tables WHERE TABLE_SCHEMA="test" AND TABLE_NAME="t1"
103 --source include/wait_condition.inc
104
105 --let $wait_condition= SELECT COUNT(*)=1 FROM test.t1 WHERE a=1
106 --source include/wait_condition.inc
107
108 --echo
109 --echo # 4. Insert row on M1 and table t1 with binlog off.
110 --let $rpl_connection_name= server1
111 --source include/rpl_connection.inc
112
113 SET sql_log_bin=0;
114 INSERT INTO test.t1 values (2);
115 SET sql_log_bin=1;
116
117 --echo
118 --echo # 5. Insert same row in M2 so that M1 stops due to primary key coflict.
119 --let $rpl_connection_name= server2
120 --source include/rpl_connection.inc
121
122 SET GLOBAL super_read_only= 0;
123 INSERT INTO test.t1 values (2);
124
125 --echo
126 --echo # 6. Wait for GR to ERROR out on M1.
127 --let $rpl_connection_name= server1
128 --source include/rpl_connection.inc
129
130 --let $group_replication_member_state= ERROR
131 --source include/gr_wait_for_member_state.inc
132
133 SET GLOBAL super_read_only= FALSE;
134 SET sql_log_bin=0;
135 INSERT INTO test.t1 values (3);
136 SET sql_log_bin=1;
137 SET GLOBAL super_read_only= TRUE;
138
139 --echo
140 --echo # 7. Assert channels ch3_1 and ch4_1 have errored out.
141 --echo # Assert binlog dump thread is not present in threads table.
142
143 --let $assert_text= Thread Binlog Dump GTID is killed.
144 --let $assert_cond= "[SELECT COUNT(*) FROM information_schema.processlist WHERE COMMAND=\"Binlog Dump%\"]" = "0"
145 --source include/assert.inc
146
147 --let $rpl_connection_name= server3
148 --source include/rpl_connection.inc
149
150 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.3.err
151 --let $assert_select= Lost connection to MySQL server during query \(server_errno=2013\)
152 --let $assert_count= 1
153 --let $assert_text= Master connection is lost.
154 --source include/assert_grep.inc
155
156 --let $assert_text= Slave connection is stopped.
157 --let $assert_cond= "[SELECT COUNT(*) FROM test.t1 WHERE a=3]" = "0"
158 --source include/assert.inc
159
160 --let $rpl_connection_name= server4
161 --source include/rpl_connection.inc
162
163 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.4.err
164 --let $assert_select= Lost connection to MySQL server during query \(server_errno=2013\)
165 --let $assert_count= 1
166 --let $assert_text= Master connection is lost.
167 --source include/assert_grep.inc
168
169 --let $assert_text= Slave connection is stopped.
170 --let $assert_cond= "[SELECT COUNT(*) FROM test.t1 WHERE a=3]" = "0"
171 --source include/assert.inc
172
173 --echo
174 --echo # 8. Restore M3 channel.
175
176 --let $rpl_connection_name= server3
177 --source include/rpl_connection.inc
178
179 --let $rpl_channel_name='ch3_1'
180 --source include/stop_slave.inc
181 --let $rpl_channel_name=
182
183 --let $rpl_connection_name= server4
184 --source include/rpl_connection.inc
185
186 --let $rpl_channel_name='ch4_1'
187 --source include/stop_slave.inc
188 --let $rpl_channel_name=
189
190 --let $rpl_connection_name= server1
191 --source include/rpl_connection.inc
192
193 SET GLOBAL super_read_only= FALSE;
194 SET sql_log_bin=0;
195 DELETE FROM test.t1 WHERE a=3;
196 SET sql_log_bin=1;
197 SET GLOBAL super_read_only= TRUE;
198
199 --echo
200 --echo # 9. Start GR on M1 and channel ch3_1: M1(master), M3(slave)
201 --echo # and ch4_1: M1(master), M4(slave).
202
203 --source include/stop_group_replication.inc
204 SET sql_log_bin=0;
205 DELETE FROM test.t1 WHERE a=2;
206 SET sql_log_bin=1;
207 --source include/start_group_replication.inc
208 --replace_result $server1_uuid SERVER1_UUID
209 --eval SELECT group_replication_set_as_primary("$server1_uuid")
210 INSERT INTO test.t1 values (3);
211
212 --let $rpl_connection_name= server3
213 --source include/rpl_connection.inc
214
215 --let $rpl_channel_name='ch3_1'
216 --source include/start_slave.inc
217 --let $rpl_channel_name=
218
219 --let $wait_condition= SELECT COUNT(*)=1 FROM test.t1 WHERE a=3
220 --source include/wait_condition.inc
221
222 --let $rpl_connection_name= server4
223 --source include/rpl_connection.inc
224
225 --let $rpl_channel_name='ch4_1'
226 --source include/start_slave.inc
227 --let $rpl_channel_name=
228
229 --let $wait_condition= SELECT COUNT(*)=1 FROM test.t1 WHERE a=3
230 --source include/wait_condition.inc
231
232 --echo
233 --echo # 10. Stop GR on M1.
234 --let $rpl_connection_name= server1
235 --source include/rpl_connection.inc
236
237 --source include/stop_group_replication.inc
238
239 SET GLOBAL super_read_only= FALSE;
240 SET sql_log_bin=0;
241 INSERT INTO test.t1 values (4);
242 SET sql_log_bin=1;
243 SET GLOBAL super_read_only= TRUE;
244
245 --echo
246 --echo # 11. Assert channels ch3_1 and ch4_1 have errored out.
247 --echo # Assert binlog dump thread is not present in threads table.
248
249 --let $assert_text= Thread Binlog Dump GTID is killed.
250 --let $assert_cond= "[SELECT COUNT(*) FROM information_schema.processlist WHERE COMMAND=\"Binlog Dump%\"]" = "0"
251 --source include/assert.inc
252
253 --let $rpl_connection_name= server3
254 --source include/rpl_connection.inc
255
256 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.3.err
257 --let $assert_select= Lost connection to MySQL server during query \(server_errno=2013\)
258 --let $assert_count= 2
259 --let $assert_text= Master connection is lost.
260 --source include/assert_grep.inc
261
262 --let $assert_text= Slave connection is stopped.
263 --let $assert_cond= "[SELECT COUNT(*) FROM test.t1 WHERE a=4]" = "0"
264 --source include/assert.inc
265
266 --let $rpl_connection_name= server4
267 --source include/rpl_connection.inc
268
269 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.4.err
270 --let $assert_select= Lost connection to MySQL server during query \(server_errno=2013\)
271 --let $assert_count= 2
272 --let $assert_text= Master connection is lost.
273 --source include/assert_grep.inc
274
275 --let $assert_text= Slave connection is stopped.
276 --let $assert_cond= "[SELECT COUNT(*) FROM t1 WHERE a=4]" = "0"
277 --source include/assert.inc
278
279 --echo
280 --echo # 12. Cleanup
281 --let $rpl_connection_name= server1
282 --source include/rpl_connection.inc
283
284 SET GLOBAL super_read_only= FALSE;
285 SET sql_log_bin=0;
286 DELETE FROM test.t1 WHERE a=4;
287 SET sql_log_bin=1;
288 SET GLOBAL super_read_only= TRUE;
289
290 --source include/start_group_replication.inc
291
292 --let $rpl_connection_name= server2
293 --source include/rpl_connection.inc
294
295 DROP TABLE test.t1;
296
297 --let $rpl_connection_name= server3
298 --source include/rpl_connection.inc
299
300 --let $rpl_channel_name='ch3_1'
301 --source include/stop_slave.inc
302 --let $rpl_channel_name=
303 RESET SLAVE ALL FOR CHANNEL 'ch3_1';
304 --source include/start_group_replication.inc
305
306 --let $rpl_connection_name= server4
307 --source include/rpl_connection.inc
308
309 --let $rpl_channel_name='ch4_1'
310 --source include/stop_slave.inc
311 --let $rpl_channel_name=
312 RESET SLAVE ALL FOR CHANNEL 'ch4_1';
313 --source include/start_group_replication.inc
314
315 --source include/group_replication_end.inc