Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate that when the sender to which the receiver is connected loses
3 # majority, the receiver will switch to another healthy sender. Also validate
4 # that the sender which lost majority still has its connection details in
5 # replication_asynchronous_connection_failover table.
6 #
7 # Test:
8 # 0. The test requires 4 servers:
9 # server1: group primary
10 # server2: group secondary
11 # server3: single server
12 # server4: replica server
13 # 1. Deploy a 2 members group in single primary mode.
14 # 2. Configure replica to manage the asynchronous connection
15 # to group and server3.
16 # 3. Create and start the managed channel connected to server1.
17 # 4. Kill server1, the group will block due no majority.
18 # 5. Despite server2 has the second biggest weight, since
19 # the group has no majority, the replica will connect
20 # to server3.
21 # 6. Wait 30 seconds and validate that replica is still connected
22 # to server3.
23 # 7. Assert that group information did not change, since it
24 # lost the majority.
25 # 8. Restore the majority on the group by forcing its membership
26 # to only server2.
27 # 9. Since server2 has bigger weight than server3, the managed
28 # channel must reconnect to server2 now that the group has
29 # majority.
30 # 10. Clean up.
31 ################################################################################
32 --source include/big_test.inc
33 --source include/not_valgrind.inc
34 --source include/have_group_replication_plugin.inc
35 --let $rpl_skip_group_replication_start= 1
36 --let $rpl_server_count= 4
37 --let $group_replication_group_name= aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
38 --source include/group_replication.inc
39
40
41 --echo
42 --echo ############################################################
43 --echo # 1. Deploy a 2 members group in single primary mode.
44 --let $rpl_connection_name= server1
45 --source include/rpl_connection.inc
46 --let $server1_uuid= `SELECT @@server_uuid`
47 --source include/start_and_bootstrap_group_replication.inc
48
49 --let $rpl_connection_name= server2
50 --source include/rpl_connection.inc
51 --let $server2_uuid= `SELECT @@server_uuid`
52 --source include/start_group_replication.inc
53
54
55 --echo
56 --echo ############################################################
57 --echo # 2. Configure replica to manage the asynchronous connection
58 --echo # to group and server3.
59 --let $rpl_connection_name= server4
60 --source include/rpl_connection.inc
61
62 --replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 $group_replication_group_name GROUP_NAME
63 --eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_replication_group_name', '127.0.0.1', $SERVER_MYPORT_1, '', 90, 70);
64
65 --replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
66 --eval SELECT asynchronous_connection_failover_add_source('ch1', '127.0.0.1', $SERVER_MYPORT_3, '', 50);
67
68 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server1'
69 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_1, count, 1] = 1
70 --source include/assert.inc
71
72 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server3'
73 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_3, count, 1] = 1
74 --source include/assert.inc
75
76 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for server1'
77 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_replication_group_name", count, 1] = 1
78 --source include/assert.inc
79
80
81 --echo
82 --echo ############################################################
83 --echo # 3. Create and start the managed channel connected to server1.
84 --let $rpl_connection_name= server4
85 --source include/rpl_connection.inc
86 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
87 --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_RETRY_COUNT=0 FOR CHANNEL 'ch1'
88
89 --let $rpl_channel_name='ch1'
90 --source include/start_slave.inc
91 --let $rpl_channel_name=
92
93 --let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server1
94 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch1\' AND source_uuid=\'$server1_uuid\', SERVICE_STATE, 1]" = "ON"
95 --source include/assert.inc
96
97 --let $wait_condition= SELECT COUNT(*)=3 FROM performance_schema.replication_asynchronous_connection_failover
98 --source include/wait_condition.inc
99
100
101 --echo
102 --echo ############################################################
103 --echo # 4. Kill server1, the group will block due no majority.
104 --let $rpl_connection_name= server1
105 --source include/rpl_connection.inc
106 --source include/kill_and_restart_mysqld.inc
107
108 --let $rpl_server_number= 1
109 --source include/rpl_reconnect.inc
110
111 --let $rpl_connection_name= server2
112 --source include/rpl_connection.inc
113 --let $group_replication_member_state= UNREACHABLE
114 --let $group_replication_member_id= $server1_uuid
115 --source include/gr_wait_for_member_state.inc
116
117
118 --echo
119 --echo ############################################################
120 --echo # 5. Despite server2 has the second biggest weight, since
121 --echo # the group has no majority, the replica will connect
122 --echo # to server3.
123 --let $rpl_connection_name= server3
124 --source include/rpl_connection.inc
125 --let $server3_uuid= `SELECT @@server_uuid`
126
127 --let $rpl_connection_name= server4
128 --source include/rpl_connection.inc
129 --echo Wait until ch1 IO_THREAD is connected to server3
130 --let $wait_condition= SELECT service_state="ON" FROM performance_schema.replication_connection_status WHERE channel_name="ch1" AND source_uuid="$server3_uuid"
131 --source include/wait_condition.inc
132
133
134 --let $wait_condition= SELECT COUNT(*)>=1 FROM performance_schema.error_log WHERE (error_code='MY-013682' OR error_code='MY-013683') AND data LIKE 'The % thread detected that the source % does not belong to the group majority, thence the channel % will try to connect to another source.'
135 --source include/wait_condition.inc
136
137
138 --echo
139 --echo ############################################################
140 --echo # 6. Wait 30 seconds and validate that replica is still connected
141 --echo # to server3.
142 --let $rpl_connection_name= server4
143 --source include/rpl_connection.inc
144 --sleep 30
145 --let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server3
146 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch1\' AND source_uuid=\'$server3_uuid\', SERVICE_STATE, 1]" = "ON"
147 --source include/assert.inc
148
149
150 --echo
151 --echo ############################################################
152 --echo # 7. Assert that group information did not change, since it
153 --echo # lost the majority.
154 --let $rpl_connection_name= server4
155 --source include/rpl_connection.inc
156
157 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server1'
158 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_1 AND weight=90 AND managed_name="$group_replication_group_name" , count, 1] = 1
159 --source include/assert.inc
160
161 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server2'
162 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_2 AND weight=70 AND managed_name="$group_replication_group_name" , count, 1] = 1
163 --source include/assert.inc
164
165
166 --echo
167 --echo ############################################################
168 --echo # 8. Restore the majority on the group by forcing its membership
169 --echo # to only server2.
170 --let $rpl_connection_name= server2
171 --source include/rpl_connection.inc
172 --let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address`
173 --replace_result $local_address_server2 GROUP_REPLICATION_LOCAL_ADDR_SERVER2
174 --eval SET GLOBAL group_replication_force_members= "$local_address_server2"
175
176 # Check for the primary member after the group is unblocked
177 --let $server1_uuid= `SELECT @@server_uuid`
178 --let $group_replication_expected_uuid= $server2_uuid
179 --source include/gr_wait_primary_member_uuid.inc
180
181 --let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE"
182 --source include/wait_condition.inc
183
184 SET GLOBAL group_replication_force_members= "";
185
186
187 --echo
188 --echo ############################################################
189 --echo # 9. Since server2 has bigger weight than server3, the managed
190 --echo # channel must reconnect to server2 now that the group has
191 --echo # majority.
192 --let $rpl_connection_name= server4
193 --source include/rpl_connection.inc
194 --echo Wait until ch1 IO_THREAD is connected to server2
195 --let $wait_condition= SELECT service_state="ON" FROM performance_schema.replication_connection_status WHERE channel_name="ch1" AND source_uuid="$server2_uuid"
196 --source include/wait_condition.inc
197
198
199 --echo
200 --echo ############################################################
201 --echo # 10. Clean up.
202 --let $rpl_connection_name= server4
203 --source include/rpl_connection.inc
204 --let $rpl_channel_name='ch1'
205 --source include/stop_slave.inc
206
207 --let $rpl_reset_slave_all= 1
208 --let $rpl_multi_source= 1
209 --source include/rpl_reset_slave.inc
210 --let $rpl_channel_name=
211 --let $rpl_reset_slave_all=
212 --let $rpl_multi_source=
213
214 --replace_result $group_replication_group_name GROUP_NAME
215 --eval SELECT asynchronous_connection_failover_delete_managed('ch1', '$group_replication_group_name')
216
217 --let $assert_text= 'There are 0 rows in performance_schema.replication_asynchronous_connection_failover_managed for group'
218 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_replication_group_name", count, 1] = 0
219 --source include/assert.inc
220
221 --let $assert_text= 'There are 0 rows in performance_schema.replication_asynchronous_connection_failover for group'
222 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE managed_name="$group_replication_group_name" , count, 1] = 0
223
224 --replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
225 --eval SELECT asynchronous_connection_failover_delete_source('ch1', '127.0.0.1', $SERVER_MYPORT_3, '');
226
227 --let $assert_text= 'There are no rows in performance_schema.replication_asynchronous_connection_failover'
228 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 0
229 --source include/assert.inc
230
231 --let $assert_text= 'There are no rows in performance_schema.replication_asynchronous_connection_failover_managed'
232 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed, count, 1] = 0
233 --source include/assert.inc
234
235 SET SESSION sql_log_bin = 0;
236 call mtr.add_suppression("The source .* for channel 'ch1' has joined the group .*, and so added its entry into replication_asynchronous_connection_failover table.");
237 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.*");
238 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.");
239 call mtr.add_suppression("The source .* for channel 'ch1' has left the group .*, and so removed its entry from replication_asynchronous_connection_failover table.");
240 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.");
241 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.");
242 call mtr.add_suppression("The Monitor IO thread failed to detect if the source belongs to the group majority on the source.*");
243 SET SESSION sql_log_bin = 1;
244
245 --let $rpl_connection_name= server2
246 --source include/rpl_connection.inc
247 --source include/stop_group_replication.inc
248
249 --source include/group_replication_end.inc