Debian Codegraph @

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

raw
1 ################################################################################
2 #
3 # This test shall verify that the group_replication_paxos_single_leader system
4 # variable correctly enables/disables the single-leader behavior introduced in
5 # WL#9149 and also that a member with a different value on this system variable
6 # cannot join the group.
7 #
8 # Test:
9 # 0) Verify that the default value of group_replication_paxos_single_leader is
10 # true
11 # 1) The test requires three servers.
12 # 2) Verify that the UUID present in WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED
13 # and in WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE is the UUID of the primary
14 # 3) Change the value of group_replication_paxos_single_leader to false
15 # 4) Verify that the value of the new sysvar is false
16 # 5) The group should still be using single-leader
17 # 6) Reboot the plugin (add only 2 of the members)
18 # 7) Verify that the UUIDs contained in
19 # WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and in
20 # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE contain all the UUIDs of all the
21 # members in the group
22 # 8) Change the sysvar value on the third member to true
23 # 9) Try to add the third member
24 # 9.1) Adding the third member should fail
25 # 10) Cleanup.
26 #
27 ################################################################################
28 --source include/big_test.inc
29 --source include/have_debug.inc
30 --source include/linux.inc
31 --source include/have_group_replication_plugin.inc
32 --let $rpl_server_count = 3
33 --let $rpl_group_replication_single_primary_mode=1
34 --let $rpl_skip_group_replication_start=1
35 --source include/group_replication.inc
36
37 --let $rpl_connection_name = server3
38 --source include/rpl_connection.inc
39
40 SET sql_log_bin = 0;
41 call mtr.add_suppression("This member is configured with a group_replication_paxos_single_leader option value of*");
42 SET sql_log_bin = 1;
43
44 --echo
45 --echo ####
46 --echo # 0) Verify that the default value of
47 --echo # group_replication_paxos_single_leader is true
48 --echo ####
49 --echo
50 --let $rpl_connection_name = server1
51 --source include/rpl_connection.inc
52
53 SET @@GLOBAL.group_replication_paxos_single_leader = default;
54 --let $assert_text = The default of group_replication_paxos_single_leader should be 0
55 --let $assert_cond = [SELECT @@GLOBAL.group_replication_paxos_single_leader] = 0
56 --source include/assert.inc
57
58 --echo
59 --echo ####
60 --echo # 1) The test requires three servers.
61 --echo ####
62 --echo
63 SET @@GLOBAL.group_replication_paxos_single_leader = 1;
64 --source include/start_and_bootstrap_group_replication.inc
65
66 --let $rpl_connection_name = server2
67 --source include/rpl_connection.inc
68 --source include/start_group_replication.inc
69
70 --let $rpl_connection_name = server3
71 --source include/rpl_connection.inc
72 --source include/start_group_replication.inc
73
74 --echo
75 --echo ####
76 --echo # 2) Verify that the UUID present in
77 --echo # WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and in
78 --echo # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE is the UUID of the primary
79 --echo ####
80 --echo
81 --let $rpl_connection_name = server1
82 --source include/rpl_connection.inc
83 --let $server1_uuid = `SELECT @@server_uuid`
84 # Verify preferred and active members of member 1
85 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
86 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED FROM performance_schema.replication_group_communication_information]" = "$server1_uuid"
87 --source include/assert.inc
88 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
89 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
90 --source include/assert.inc
91 --let $assert_text = Single Leader must be enabled
92 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
93 --source include/assert.inc
94
95 # Verify preferred and active members of member 2
96 --let $rpl_connection_name= server2
97 --source include/rpl_connection.inc
98 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
99 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server1_uuid"
100 --source include/assert.inc
101 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
102 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
103 --source include/assert.inc
104 --let $assert_text = Single Leader must be enabled
105 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
106 --source include/assert.inc
107
108 # Verify preferred and active members of member 3
109 --let $rpl_connection_name= server3
110 --source include/rpl_connection.inc
111 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
112 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server1_uuid"
113 --source include/assert.inc
114 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
115 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
116 --source include/assert.inc
117 --let $assert_text = Single Leader must be enabled
118 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
119 --source include/assert.inc
120
121 --echo
122 --echo ####
123 --echo # 3) Change the value of group_replication_paxos_single_leader to false
124 --echo ####
125 --echo
126 --let $rpl_connection_name= server1
127 --source include/rpl_connection.inc
128 SET GLOBAL group_replication_paxos_single_leader = 0;
129
130 --echo
131 --echo ####
132 --echo # 4) Verify that the value of the new sysvar is false
133 --echo ####
134 --echo
135 --let $assert_text = The value of group_replication_paxos_single_leader should be 0
136 --let $assert_cond = [SELECT @@GLOBAL.group_replication_paxos_single_leader] = 0
137 --source include/assert.inc
138
139 --echo
140 --echo ####
141 --echo # 5) The group should still be using single-leader
142 --echo ####
143 --echo
144 --let $server1_uuid = `SELECT @@server_uuid`
145 # Verify preferred and active members of member 1
146 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
147 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED FROM performance_schema.replication_group_communication_information]" = "$server1_uuid"
148 --source include/assert.inc
149 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
150 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
151 --source include/assert.inc
152 --let $assert_text = Single Leader must be enabled
153 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
154 --source include/assert.inc
155
156 # Verify preferred and active members of member 2
157 --let $rpl_connection_name= server2
158 --source include/rpl_connection.inc
159 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
160 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server1_uuid"
161 --source include/assert.inc
162 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
163 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
164 --source include/assert.inc
165 --let $assert_text = Single Leader must be enabled
166 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
167 --source include/assert.inc
168
169 # Verify preferred and active members of member 3
170 --let $rpl_connection_name= server3
171 --source include/rpl_connection.inc
172 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
173 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server1_uuid"
174 --source include/assert.inc
175 --let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
176 --let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
177 --source include/assert.inc
178 --let $assert_text = Single Leader must be enabled
179 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
180 --source include/assert.inc
181
182 --echo
183 --echo ####
184 --echo # 6) Reboot the plugin (add only 2 of the members)
185 --echo ####
186 --echo
187 --let $rpl_connection_name= server3
188 --source include/rpl_connection.inc
189 --let $server3_uuid = `SELECT @@GLOBAL.server_uuid`
190 --source include/stop_group_replication.inc
191
192 --let $rpl_connection_name= server2
193 --source include/rpl_connection.inc
194 --source include/stop_group_replication.inc
195
196 --let $rpl_connection_name= server1
197 --source include/rpl_connection.inc
198 --source include/stop_group_replication.inc
199 --source include/start_and_bootstrap_group_replication.inc
200
201 --let $rpl_connection_name= server2
202 --source include/rpl_connection.inc
203 SET GLOBAL group_replication_paxos_single_leader = 0;
204 --source include/start_group_replication.inc
205
206 --echo
207 --echo ####
208 --echo # 7) Verify that the UUIDs contained in
209 --echo # WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and in
210 --echo # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE contain all the UUIDs of all
211 --echo # the members in the group
212 --echo ####
213 --echo
214 --let $rpl_connection_name= server1
215 --source include/rpl_connection.inc
216
217 # Verify preferred and active members of member 1
218 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
219 --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%'`
220 --let $assert_cond = "$num_rows" = "1"
221 --source include/assert.inc
222 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
223 --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%'`
224 --let $assert_cond = "$num_rows" = "1"
225 --source include/assert.inc
226 --let $assert_text = Single Leader must be disabled
227 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "0"
228 --source include/assert.inc
229
230 # Verify preferred and active members of member 2
231 --let $rpl_connection_name= server2
232 --source include/rpl_connection.inc
233 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
234 --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%'`
235 --let $assert_cond = "$num_rows" = "1"
236 --source include/assert.inc
237 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
238 --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%'`
239 --let $assert_cond = "$num_rows" = "1"
240 --source include/assert.inc
241 --let $assert_text = Single Leader must be disabled
242 --let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "0"
243 --source include/assert.inc
244
245 --echo
246 --echo ####
247 --echo # 8) Change the sysvar value on the third member to true
248 --echo ####
249 --echo
250 --let $rpl_connection_name= server3
251 --source include/rpl_connection.inc
252
253 SET GLOBAL group_replication_paxos_single_leader = 1;
254
255 --echo
256 --echo ####
257 --echo # 9) Try to add the third member
258 --echo ####
259 --echo
260 --error ER_GROUP_REPLICATION_CONFIGURATION
261 START GROUP_REPLICATION;
262
263 # The third member should not have been added
264 --let $rpl_connection_name= server1
265 --source include/rpl_connection.inc
266
267 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
268 --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%'`
269 --let $assert_cond = "$num_rows" = "1"
270 --source include/assert.inc
271 --let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
272 --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%'`
273 --let $assert_cond = "$num_rows" = "1"
274 --source include/assert.inc
275 --let $assert_text = Member 3 should not have been added to the group
276 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE MEMBER_ID LIKE '%$server3_uuid%'`
277 --let $assert_cond = "$num_rows" = "0"
278 --source include/assert.inc
279
280 --let $rpl_connection_name= server2
281 --source include/rpl_connection.inc
282
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%'`
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%'`
289 --let $assert_cond = "$num_rows" = "1"
290 --source include/assert.inc
291 --let $assert_text = Member 3 should not have been added to the group
292 --let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE MEMBER_ID LIKE '%$server3_uuid%'`
293 --let $assert_cond = "$num_rows" = "0"
294 --source include/assert.inc
295
296 --echo
297 --echo ####
298 --echo # 10) Cleanup.
299 --echo ####
300 --echo
301 --let $rpl_connection_name= server1
302 --source include/rpl_connection.inc
303 SET GLOBAL group_replication_paxos_single_leader = 1;
304
305 --let $rpl_connection_name= server2
306 --source include/rpl_connection.inc
307 SET GLOBAL group_replication_paxos_single_leader = 1;
308
309 --let $rpl_connection_name= server3
310 --source include/rpl_connection.inc
311 SET GLOBAL group_replication_paxos_single_leader = 1;
312
313 --let $rpl_connection_name= server1
314 --source include/rpl_connection.inc
315 --source include/group_replication_end.inc