Debian Codegraph @

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

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