Debian Codegraph @

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

raw
1 ################################################################################
2 #
3 # Starting from communication protocol version 8.0.22, XCom will use a single
4 # leader consensus algorithm based on Multi-Paxos when running GR in SPM.
5 #
6 # This test shall verify that, upon switching the group mode from MPM to SPM,
7 # when on communication protocol v8.0.22, a single leader is used. It will also
8 # test that when switching from MPM to SPM while using a previous communication
9 # protocol, the previous consensus algorithm is used (i.e. all members as
10 # leaders).
11 #
12 # Test:
13 # 0) The test requires three servers.
14 # 1) Switch to SPM on every member. For each member that was elected as primary
15 # in SPM, the WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and
16 # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE fields of the
17 # performance_schema.replication_group_communication_information PFS table
18 # should contain *only* the UUID of that member.
19 # 2) Change the communication protocol to 8.0.21.
20 # 3) Switch to SPM on every member. For each member that was elected as primary
21 # in SPM the WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and
22 # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE fields of the
23 # performance_schema.replication_group_communication_information PFS table
24 # should contain the UUIDs of *all* the members in the group.
25 # 4) Cleanup.
26 #
27 ################################################################################
28 --source include/big_test.inc
29 --source include/have_group_replication_plugin.inc
30
31 --echo
32 --echo ####
33 --echo # 0) The test requires three servers.
34 --echo ####
35 --echo
36 --let $rpl_server_count = 3
37 --let $rpl_group_replication_single_primary_mode=0
38 --source include/group_replication.inc
39
40 SET SESSION sql_log_bin = 0;
41 call mtr.add_suppression("A member is joining the group while a group configuration operation is occurring*");
42 SET SESSION sql_log_bin = 1;
43
44 --let $rpl_connection_name= server2
45 --source include/rpl_connection.inc
46 SET SESSION sql_log_bin = 0;
47 call mtr.add_suppression("A member is joining the group while a group configuration operation is occurring*");
48 SET SESSION sql_log_bin = 1;
49
50 --let $rpl_connection_name= server3
51 --source include/rpl_connection.inc
52 SET SESSION sql_log_bin = 0;
53 call mtr.add_suppression("A member is joining the group while a group configuration operation is occurring*");
54 SET SESSION sql_log_bin = 1;
55
56 --echo
57 --echo ####
58 --echo # 1) Switch to SPM on every member. For each member that was elected as
59 --echo # primary in SPM, the WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and
60 --echo # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE fields of the
61 --echo # performance_schema.replication_group_communication_information PFS
62 --echo # table should contain *only* the UUID of that member.
63 --echo ####
64 --echo
65 --let $rpl_connection_name= server1
66 --source include/rpl_connection.inc
67
68 # Elect member 1
69 --let $server1_uuid = `SELECT @@server_uuid`
70 --replace_result $server1_uuid MEMBER1_UUID
71 --eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid")
72
73 # Verify preferred and active members of member 1
74 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
75 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED FROM performance_schema.replication_group_communication_information]" = "$server1_uuid"
76 --source include/assert.inc
77 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
78 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
79 --source include/assert.inc
80 --let $assert_text = Single Leader must be enabled
81 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
82 --source include/assert.inc
83
84 # Verify preferred and active members of member 2
85 --let $rpl_connection_name= server2
86 --source include/rpl_connection.inc
87 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
88 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server1_uuid"
89 --source include/assert.inc
90 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
91 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
92 --source include/assert.inc
93 --let $assert_text = Single Leader must be enabled
94 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
95 --source include/assert.inc
96
97 # Verify preferred and active members of member 3
98 --let $rpl_connection_name= server3
99 --source include/rpl_connection.inc
100 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
101 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server1_uuid"
102 --source include/assert.inc
103 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
104 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
105 --source include/assert.inc
106 --let $assert_text = Single Leader must be enabled
107 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
108 --source include/assert.inc
109
110 --let $rpl_connection_name= server3
111 --source include/rpl_connection.inc
112 --source include/stop_group_replication.inc
113
114 --let $rpl_connection_name= server2
115 --source include/rpl_connection.inc
116 --source include/stop_group_replication.inc
117
118 --let $rpl_connection_name= server1
119 --source include/rpl_connection.inc
120 --source include/stop_group_replication.inc
121
122 --let $rpl_connection_name= server1
123 --source include/rpl_connection.inc
124 --source include/start_and_bootstrap_group_replication.inc
125
126 --let $rpl_connection_name= server2
127 --source include/rpl_connection.inc
128 --source include/start_group_replication.inc
129
130 --let $rpl_connection_name= server3
131 --source include/rpl_connection.inc
132 --source include/start_group_replication.inc
133
134 # Elect member 2
135 --let $rpl_connection_name= server2
136 --source include/rpl_connection.inc
137 --let $server2_uuid = `SELECT @@server_uuid`
138
139 --eval SELECT group_replication_switch_to_multi_primary_mode()
140 --replace_result $server2_uuid MEMBER2_UUID
141 --eval SELECT group_replication_switch_to_single_primary_mode("$server2_uuid")
142
143 --let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server2_uuid" AND MEMBER_ROLE = 'PRIMARY'
144 --source include/wait_condition.inc
145
146 # Verify preferred and active members of member 2
147 --let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
148 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server2_uuid"
149 --source include/assert.inc
150 --let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
151 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server2_uuid"
152 --source include/assert.inc
153
154 # Verify preferred and active members of member 1
155 --let $rpl_connection_name= server1
156 --source include/rpl_connection.inc
157 --let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
158 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server2_uuid"
159 --source include/assert.inc
160 --let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
161 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server2_uuid"
162 --source include/assert.inc
163
164 # Verify preferred and active members of member 3
165 --let $rpl_connection_name= server3
166 --source include/rpl_connection.inc
167 --let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
168 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server2_uuid"
169 --source include/assert.inc
170 --let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
171 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server2_uuid"
172 --source include/assert.inc
173
174 # Elect member 3
175 --let $rpl_connection_name= server3
176 --source include/rpl_connection.inc
177 --let $server3_uuid = `SELECT @@server_uuid`
178
179 --eval SELECT group_replication_switch_to_multi_primary_mode()
180 --replace_result $server3_uuid MEMBER3_UUID
181 --eval SELECT group_replication_switch_to_single_primary_mode("$server3_uuid")
182
183 --let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server3_uuid" AND MEMBER_ROLE = 'PRIMARY'
184 --source include/wait_condition.inc
185
186 # Verify preferred and active members of member 3
187 --let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
188 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server3_uuid"
189 --source include/assert.inc
190 --let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
191 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server3_uuid"
192 --source include/assert.inc
193
194 # Verify preferred and active members of member 1
195 --let $rpl_connection_name= server1
196 --source include/rpl_connection.inc
197 --let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
198 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server3_uuid"
199 --source include/assert.inc
200 --let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
201 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server3_uuid"
202 --source include/assert.inc
203
204 # Verify preferred and active members of member 2
205 --let $rpl_connection_name= server2
206 --source include/rpl_connection.inc
207 --let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
208 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server3_uuid"
209 --source include/assert.inc
210 --let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
211 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server3_uuid"
212 --source include/assert.inc
213
214 --echo
215 --echo ####
216 --echo # 2) Change the communication protocol to 8.0.21. Must restart the group.
217 --echo ####
218 --echo
219
220 --let $rpl_connection_name= server3
221 --source include/rpl_connection.inc
222
223 --source include/stop_group_replication.inc
224 --eval SET GLOBAL group_replication_paxos_single_leader = "OFF"
225
226 --let $rpl_connection_name= server2
227 --source include/rpl_connection.inc
228
229 --source include/stop_group_replication.inc
230 --eval SET GLOBAL group_replication_paxos_single_leader = "OFF"
231
232 --let $rpl_connection_name= server1
233 --source include/rpl_connection.inc
234
235 --source include/stop_group_replication.inc
236 --eval SET GLOBAL group_replication_paxos_single_leader = "OFF"
237
238 --source include/start_and_bootstrap_group_replication.inc
239
240 --let $rpl_connection_name= server2
241 --source include/rpl_connection.inc
242
243 --source include/start_group_replication.inc
244
245 --let $rpl_connection_name= server3
246 --source include/rpl_connection.inc
247
248 --source include/start_group_replication.inc
249
250 --let $rpl_connection_name= server2
251 --source include/rpl_connection.inc
252
253 --eval SELECT group_replication_set_communication_protocol("8.0.21")
254
255 --echo
256 --echo ####
257 --echo # 3) Switch to SPM on every member. For each member that was elected as
258 --echo # primary in SPM the WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and
259 --echo # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE fields of the
260 --echo # performance_schema.replication_group_communication_information PFS
261 --echo # table should contain the UUIDs of *all* the members in the group.
262 --echo ####
263 --echo
264
265 # Elect member 1
266 --let $rpl_connection_name= server1
267 --source include/rpl_connection.inc
268
269 # Wait until the communication protocol change is effective on this member,
270 # only one group action can run at a time.
271 # When changing to 8.0.21, the protocol will change to 8.0.16.
272 --let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_communication_information WHERE PROTOCOL_VERSION = '8.0.16'
273 --source include/wait_condition_or_abort.inc
274
275 --eval SELECT group_replication_switch_to_multi_primary_mode()
276 --replace_result $server1_uuid MEMBER1_UUID
277 --eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid")
278
279 --let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server1_uuid" AND MEMBER_ROLE = 'PRIMARY'
280 --source include/wait_condition.inc
281
282 # Verify preferred and active members of member 1
283 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
284 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
285 --let $assert_cond = "$num_rows" = "1"
286 --source include/assert.inc
287 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
288 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
289 --let $assert_cond = "$num_rows" = "1"
290 --source include/assert.inc
291 --let $assert_text = Single Leader must be disabled
292 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "0"
293 --source include/assert.inc
294
295 # Verify preferred and active members of member 2
296 --let $rpl_connection_name= server2
297 --source include/rpl_connection.inc
298 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
299 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
300 --let $assert_cond = "$num_rows" = "1"
301 --source include/assert.inc
302 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
303 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
304 --let $assert_cond = "$num_rows" = "1"
305 --source include/assert.inc
306 --let $assert_text = Single Leader must be disabled
307 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "0"
308 --source include/assert.inc
309
310 # Verify preferred and active members of member 3
311 --let $rpl_connection_name= server3
312 --source include/rpl_connection.inc
313 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
314 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
315 --let $assert_cond = "$num_rows" = "1"
316 --source include/assert.inc
317 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
318 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
319 --let $assert_cond = "$num_rows" = "1"
320 --source include/assert.inc
321 --let $assert_text = Single Leader must be disabled
322 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "0"
323 --source include/assert.inc
324
325 # Elect member 2
326 --let $rpl_connection_name= server2
327 --source include/rpl_connection.inc
328 --let $server2_uuid = `SELECT @@server_uuid`
329
330 --eval SELECT group_replication_switch_to_multi_primary_mode()
331 --replace_result $server2_uuid MEMBER2_UUID
332 --eval SELECT group_replication_switch_to_single_primary_mode("$server2_uuid")
333
334 --let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server2_uuid" AND MEMBER_ROLE = 'PRIMARY'
335 --source include/wait_condition.inc
336
337 # Verify preferred and active members of member 2
338 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
339 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
340 --let $assert_cond = "$num_rows" = "1"
341 --source include/assert.inc
342 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
343 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
344 --let $assert_cond = "$num_rows" = "1"
345 --source include/assert.inc
346
347 # Verify preferred and active members of member 1
348 --let $rpl_connection_name= server1
349 --source include/rpl_connection.inc
350 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
351 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
352 --let $assert_cond = "$num_rows" = "1"
353 --source include/assert.inc
354 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
355 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
356 --let $assert_cond = "$num_rows" = "1"
357 --source include/assert.inc
358
359 # Verify preferred and active members of member 3
360 --let $rpl_connection_name= server3
361 --source include/rpl_connection.inc
362 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
363 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
364 --let $assert_cond = "$num_rows" = "1"
365 --source include/assert.inc
366 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
367 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
368 --let $assert_cond = "$num_rows" = "1"
369 --source include/assert.inc
370
371 # Elect member 3
372 --let $rpl_connection_name= server3
373 --source include/rpl_connection.inc
374 --let $server3_uuid = `SELECT @@server_uuid`
375
376 --eval SELECT group_replication_switch_to_multi_primary_mode()
377 --replace_result $server3_uuid MEMBER3_UUID
378 --eval SELECT group_replication_switch_to_single_primary_mode("$server3_uuid")
379
380 --let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server3_uuid" AND MEMBER_ROLE = 'PRIMARY'
381 --source include/wait_condition.inc
382
383 # Verify preferred and active members of member 3
384 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
385 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
386 --let $assert_cond = "$num_rows" = "1"
387 --source include/assert.inc
388 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
389 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
390 --let $assert_cond = "$num_rows" = "1"
391 --source include/assert.inc
392
393 # Verify preferred and active members of member 1
394 --let $rpl_connection_name= server1
395 --source include/rpl_connection.inc
396 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
397 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
398 --let $assert_cond = "$num_rows" = "1"
399 --source include/assert.inc
400 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
401 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
402 --let $assert_cond = "$num_rows" = "1"
403 --source include/assert.inc
404
405 # Verify preferred and active members of member 2
406 --let $rpl_connection_name= server2
407 --source include/rpl_connection.inc
408 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
409 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
410 --let $assert_cond = "$num_rows" = "1"
411 --source include/assert.inc
412 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
413 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
414 --let $assert_cond = "$num_rows" = "1"
415 --source include/assert.inc
416
417 --echo
418 --echo ####
419 --echo # 4) Cleanup.
420 --echo ####
421 --echo
422
423 --let $rpl_connection_name= server3
424 --source include/rpl_connection.inc
425 --eval SET GLOBAL group_replication_paxos_single_leader = "ON"
426
427 --let $rpl_connection_name= server2
428 --source include/rpl_connection.inc
429 --eval SET GLOBAL group_replication_paxos_single_leader = "ON"
430
431 --let $rpl_connection_name= server1
432 --source include/rpl_connection.inc
433 --eval SET GLOBAL group_replication_paxos_single_leader = "ON"
434
435 --let $rpl_connection_name= server1
436 --source include/rpl_connection.inc
437 --source include/stop_group_replication.inc
438 --let $rpl_group_replication_single_primary_mode=1
439 --let $rpl_group_replication_reset_persistent_vars=1
440 --source include/group_replication_end.inc