Debian Codegraph @

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

raw
1 #
2 # Test case to verify that source which is part of group replication is removed
3 # if in ERROR state.
4 #
5 # Test:
6 # 0. This test needs 4 servers.
7 # 1. Start GR on M1(primary), M2 and M3
8 # 2. Add asynchronous connection failover servers and
9 # verify that they are inserted successfully in
10 # performance_schema.replication_asynchronous_connection_failover.
11 # 3. Create and start new channel ch1_4: M4(replica), M1(source)
12 # and verify channel ch1_4 IO and SQL THREADS are ON.
13 # 4. Verify 3 senders are added automatically to
14 # replication_asynchronous_connection_failover table.
15 # 5. Put M2(secondary) in error state.
16 # 6. Verify M2 is not present in
17 # performance_schema.replication_asynchronous_connection_failover
18 # 7. Bring M2 back ONLINE.
19 # 8. Put M1(primary) in error state.
20 # 9. Verify M1 is not present in
21 # performance_schema.replication_asynchronous_connection_failover
22 # Verify M2 is new source.
23 # 10. Cleanup.
24 #
25
26 --source include/big_test.inc
27 --source include/have_debug.inc
28 --source include/have_group_replication_plugin.inc
29 --let $rpl_skip_group_replication_start= 1
30 --let $rpl_group_replication_single_primary_mode=1
31 --let $rpl_server_count= 4
32 --source include/group_replication.inc
33
34
35 --echo
36 --echo # 1. Start GR on M1(primary), M2 and M3
37 --echo
38
39 --let $rpl_connection_name= server1
40 --source include/rpl_connection.inc
41
42 --let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
43
44 SET SESSION sql_log_bin= 0;
45 call mtr.add_suppression("Failed to fetch Transaction_context_log_event containing required transaction info for certification");
46 call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
47 call mtr.add_suppression("Error at event handling! Got error: 1");
48 call mtr.add_suppression("The member is leaving a group without being on one");
49 call mtr.add_suppression("Due to a plugin error, some transactions were unable to be certified and will now rollback.");
50 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
51 call mtr.add_suppression("Error while waiting for conflict detection procedure to finish on session .*");
52 call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
53 call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
54 SET SESSION sql_log_bin= 1;
55
56 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
57
58 --source include/start_and_bootstrap_group_replication.inc
59
60 --let $rpl_connection_name= server2
61 --source include/rpl_connection.inc
62
63 SET sql_log_bin=0;
64 CALL mtr.add_suppression("Could not execute Write_rows event on table test.t1");
65 CALL mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group.");
66 CALL mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
67 CALL mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
68 CALL mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
69 CALL mtr.add_suppression("The replica coordinator and worker threads are stopped");
70 SET sql_log_bin=1;
71
72 SET @member_weight2_save= @@GLOBAL.group_replication_member_weight;
73 SET GLOBAL group_replication_member_weight= 90;
74
75 --source include/start_group_replication.inc
76
77 --let $rpl_connection_name= server3
78 --source include/rpl_connection.inc
79
80 --source include/start_group_replication.inc
81
82 --let $rpl_connection_name= server4
83 --source include/rpl_connection.inc
84
85 SET SESSION sql_log_bin = 0;
86 call mtr.add_suppression("The source.*for channel.*has joined the group.*and so added its entry into replication_asynchronous_connection_failover table");
87 call mtr.add_suppression("The .* for channel 'ch1_4' has left the group .*, and so removed its entry from replication_asynchronous_connection_failover table.");
88 call mtr.add_suppression("The Monitor IO thread detected that the source .* does not belong to the group majority, thence the channel .* will try to connect to another source.");
89 call mtr.add_suppression("The IO thread detected that the source .* does not belong to the group majority, thence the channel .* will try to connect to another source.");
90 call mtr.add_suppression("The group .* for the channel .* has been removed, and so removed its entry from replication_asynchronous_connection_failover_managed and all the group members from replication_asynchronous_connection_failover table.");
91 call mtr.add_suppression("The group .* for the channel .* has been added, and so added its entry in replication_asynchronous_connection_failover_managed and source to replication_asynchronous_connection_failover table.");
92 SET SESSION sql_log_bin = 1;
93
94 --echo
95 --echo # 2. Add asynchronous connection failover servers and
96 --echo # verify that they are inserted successfully in
97 --echo # performance_schema.replication_asynchronous_connection_failover.
98 --echo
99
100 --let $rpl_connection_name= server1
101 --source include/rpl_connection.inc
102 --let $_tmp_gr_group_name1= `SELECT @@GLOBAL.group_replication_group_name`
103
104 --let $rpl_connection_name= server4
105 --source include/rpl_connection.inc
106 --replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 $_tmp_gr_group_name1 GROUP_NAME
107 --eval SELECT asynchronous_connection_failover_add_managed('ch1_4', 'GroupReplication', '$_tmp_gr_group_name1', '127.0.0.1', $SERVER_MYPORT_1, '', 70, 60);
108
109 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover'
110 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1
111 --source include/assert.inc
112
113 --echo
114 --echo # 3. Create and start new channel ch1_4: M4(replica), M1(source)
115 --echo # and verify channel ch1_4 IO and SQL THREADS are ON.
116 --echo
117 --let $rpl_connection_name= server4
118 --source include/rpl_connection.inc
119 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
120
121 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_AUTO_POSITION=1, SOURCE_CONNECTION_AUTO_FAILOVER=1, SOURCE_PORT=$SERVER_MYPORT_1, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=2 for channel 'ch1_4'
122 --let $rpl_channel_name='ch1_4'
123 --source include/start_slave.inc
124 --let $rpl_channel_name=
125
126 --let $assert_text= Verify channel ch1_4 IO_THREAD is ON
127 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name = \'ch1_4\', SERVICE_STATE, 1]" = "ON"
128 --source include/assert.inc
129
130 --let $assert_text= Verify channel ch1_4 SQL_THREAD is ON
131 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch1_4\', SERVICE_STATE, 1]" = "ON"
132 --source include/assert.inc
133
134 --echo
135 --echo # 4. Verify 3 senders are added automatically to
136 --echo # replication_asynchronous_connection_failover table.
137 --echo
138
139 --let $rpl_connection_name= server4
140 --source include/rpl_connection.inc
141
142 --let $wait_condition= SELECT COUNT(*)=3 FROM performance_schema.replication_asynchronous_connection_failover;
143 --source include/wait_condition.inc
144
145 --let $assert_text= 'Connected to server1 now.'
146 --let $assert_cond= [SELECT Port FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME = \'ch1_4\', Port, 1] = $SERVER_MYPORT_1
147 --source include/assert.inc
148
149 --echo
150 --echo # 5. Put M2(secondary) in error state.
151 --echo
152
153 --let $rpl_connection_name= server2
154 --source include/rpl_connection.inc
155
156 SET SESSION sql_log_bin= 0;
157 SET GLOBAL read_only= FALSE;
158 INSERT INTO t1 VALUES (1);
159 SET GLOBAL read_only= TRUE;
160 SET SESSION sql_log_bin= 1;
161
162 --let $rpl_connection_name= server1
163 --source include/rpl_connection.inc
164
165 INSERT INTO t1 VALUES (1);
166
167 --let $rpl_connection_name= server2
168 --source include/rpl_connection.inc
169
170 --let $group_replication_member_state= ERROR
171 --source include/gr_wait_for_member_state.inc
172
173 --echo
174 --echo # 6. Verify M2 is not present in
175 --echo # performance_schema.replication_asynchronous_connection_failover
176 --echo
177
178 --let $rpl_connection_name= server4
179 --source include/rpl_connection.inc
180
181 --let $wait_condition= SELECT COUNT(*)=0 FROM performance_schema.replication_connection_configuration WHERE HOST = '127.0.0.1' AND PORT = $SERVER_MYPORT_2
182 --source include/wait_condition.inc
183
184 --let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover;
185 --source include/wait_condition.inc
186
187 --let $assert_text= 'Connected to server1.'
188 --let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.replication_connection_configuration WHERE HOST = \'127.0.0.1\' AND PORT = $SERVER_MYPORT_1, count, 1] = 1
189 --source include/assert.inc
190
191 --echo
192 --echo # 7. Bring M2 back ONLINE.
193 --echo
194
195 --let $rpl_connection_name= server2
196 --source include/rpl_connection.inc
197
198 --source include/stop_group_replication.inc
199
200 SET SESSION sql_log_bin= 0;
201 SET GLOBAL read_only= FALSE;
202 DELETE FROM t1;
203 SET GLOBAL read_only= TRUE;
204 SET SESSION sql_log_bin= 1;
205
206 --source include/start_group_replication.inc
207
208 --let $rpl_connection_name= server4
209 --source include/rpl_connection.inc
210
211 --let $wait_condition= SELECT COUNT(*)=3 FROM performance_schema.replication_asynchronous_connection_failover;
212 --source include/wait_condition.inc
213
214 --echo
215 --echo # 8. Put M1(primary) in error state.
216 --echo
217
218 --let $rpl_connection_name= server1
219 --source include/rpl_connection.inc
220
221 SET @@GLOBAL.DEBUG= '+d,certification_handler_force_error_on_pipeline';
222
223 --error ER_TRANSACTION_ROLLBACK_DURING_COMMIT, ER_RUN_HOOK_ERROR
224 INSERT INTO t1 VALUES (2);
225
226
227 --let $group_replication_member_state= ERROR
228 --source include/gr_wait_for_member_state.inc
229
230 --echo
231 --echo # 9. Verify M1 is not present in
232 --echo # performance_schema.replication_asynchronous_connection_failover
233 --echo # Verify M2 is new source.
234 --echo
235
236 --let $rpl_connection_name= server4
237 --source include/rpl_connection.inc
238
239 --let $wait_condition= SELECT COUNT(*)=0 FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT = $SERVER_MYPORT_1;
240 --source include/wait_condition.inc
241
242 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_configuration WHERE HOST = '127.0.0.1' AND PORT = $SERVER_MYPORT_2
243 --source include/wait_condition.inc
244
245 --let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover;
246 --source include/wait_condition.inc
247
248 --let $wait_condition= SELECT COUNT(*)=0 FROM performance_schema.replication_asynchronous_connection_failover WHERE HOST = '127.0.0.1' AND PORT = $SERVER_MYPORT_1
249 --source include/wait_condition.inc
250
251 --let $assert_only_after = CURRENT_TEST: group_replication.gr_acf_error_state_handling
252 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.4.err
253 --let $assert_select= The source .* for channel 'ch1_4' has left the group .*, and so removed its entry from replication_asynchronous_connection_failover table.
254 --let $assert_count= 2
255 --let $assert_text= Source removed message is logged.
256 --source include/assert_grep.inc
257
258 --echo
259 --echo # 10. Cleanup.
260 --echo
261
262 --let $rpl_connection_name= server2
263 --source include/rpl_connection.inc
264
265 SET GLOBAL group_replication_member_weight= @member_weight2_save;
266 DROP TABLE t1;
267
268 --let $rpl_connection_name= server1
269 --source include/rpl_connection.inc
270
271 SET @@GLOBAL.DEBUG= '-d,certification_handler_force_error_on_pipeline';
272
273 --source include/stop_group_replication.inc
274 --source include/start_group_replication.inc
275
276 --replace_result $server1_uuid MEMBER1_UUID
277 --eval SELECT group_replication_set_as_primary("$server1_uuid")
278
279
280 --let $rpl_connection_name= server4
281 --source include/rpl_connection.inc
282
283 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_configuration WHERE HOST = '127.0.0.1' AND PORT = $SERVER_MYPORT_1
284 --source include/wait_condition.inc
285
286 # Wait until server4 has the same data as server1
287 --let $rpl_connection_name= server1
288 --source include/rpl_connection.inc
289 --let $sync_slave_connection= server4
290 --source include/sync_slave_sql_with_master.inc
291
292 --let $rpl_connection_name= server4
293 --source include/rpl_connection.inc
294 --let $rpl_channel_name='ch1_4'
295 --source include/stop_slave.inc
296
297 --let $rpl_reset_slave_all= 1
298 --let $rpl_multi_source= 1
299 --source include/rpl_reset_slave.inc
300 --let $rpl_channel_name=
301 --let $rpl_reset_slave_all=
302 --let $rpl_multi_source=
303
304 --replace_result $group_replication_group_name GROUP_NAME
305 --eval SELECT asynchronous_connection_failover_delete_managed('ch1_4', '$group_replication_group_name')
306
307 --let $skip_recovery_configuration= 1
308 --source include/group_replication_end.inc