Debian Codegraph @

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

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