Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate that when the monitoring worker notices that the sender to which the
3 # receiver is connected is not in the primary partition (lost quorum), then
4 # - it SHALL automatically stop the receiver,
5 # - issue an entry in the error log (ER_RPL_ASYNC_CHANNEL_STOPPED_QUORUM_LOST).
6 # As a consequence the receiver (IO thread) SHALL also automatically failover to
7 # another sender with highest weight.
8 #
9 # Test:
10 # 0. The test requires 5 servers:
11 # server1: group A primary
12 # server2: group A secondary
13 # server3: group B primary
14 # server4: group B secondary
15 # server5: single server
16 # 1. Deploy a 2 members group A in single primary mode.
17 # 2. Deploy a 2 members group B in single primary mode.
18 # 3. Configure replica to manage the asynchronous connection
19 # to groups A and B.
20 # 4. Create and start the managed channel.
21 # 5. Kill server2, group A will block due no majority.
22 # 6. Since the group A has no majority, the replica will connect
23 # to server3 on group B.
24 # 7. Assert that group A information did not change, since it
25 # lost the majority.
26 # 8. Clean up.
27 ################################################################################
28
29 --source include/big_test.inc
30 --source include/not_valgrind.inc
31 --source include/have_group_replication_plugin.inc
32 --let $rpl_skip_group_replication_start= 1
33 --let $rpl_server_count= 5
34 --source include/group_replication.inc
35
36
37 --echo
38 --echo ############################################################
39 --echo # 1. Deploy a 2 members group A in single primary mode.
40 --let $rpl_connection_name= server1
41 --source include/rpl_connection.inc
42 --let $server1_uuid= `SELECT @@server_uuid`
43 --let $group_replication_group_name= aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
44 --let $group_a= $group_replication_group_name
45 --disable_query_log
46 if ($have_xcom_stack){
47 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2"
48 }
49
50 if (!$have_xcom_stack){
51 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2"
52 }
53 --enable_query_log
54 --source include/start_and_bootstrap_group_replication.inc
55
56 --let $rpl_connection_name= server2
57 --source include/rpl_connection.inc
58 --let $server2_uuid= `SELECT @@server_uuid`
59 --disable_query_log
60 if ($have_xcom_stack){
61 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2"
62 }
63
64 if (!$have_xcom_stack){
65 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2"
66 }
67 --enable_query_log
68 --source include/start_group_replication.inc
69
70
71 --echo
72 --echo ############################################################
73 --echo # 2. Deploy a 2 members group B in single primary mode.
74 --let $rpl_connection_name= server3
75 --source include/rpl_connection.inc
76 --let $server3_uuid= `SELECT @@server_uuid`
77 --let $group_replication_group_name= bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
78 --let $group_b= $group_replication_group_name
79 --disable_query_log
80 if ($have_xcom_stack){
81 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_3,localhost:$SERVER_GR_PORT_4"
82 }
83 if (!$have_xcom_stack){
84 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_3,localhost:$SERVER_MYPORT_4"
85 }
86 --enable_query_log
87 --source include/start_and_bootstrap_group_replication.inc
88
89 --let $rpl_connection_name= server4
90 --source include/rpl_connection.inc
91 --disable_query_log
92 if ($have_xcom_stack){
93 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_3,localhost:$SERVER_GR_PORT_4"
94 }
95 if (!$have_xcom_stack){
96 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_3,localhost:$SERVER_MYPORT_4"
97 }
98 --enable_query_log
99 --source include/start_group_replication.inc
100
101
102 --echo
103 --echo ############################################################
104 --echo # 3. Configure replica to manage the asynchronous connection
105 --echo # to groups A and B.
106 --let $rpl_connection_name= server5
107 --source include/rpl_connection.inc
108
109 --replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 $group_a GROUP_A
110 --eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_a', '127.0.0.1', $SERVER_MYPORT_1, '', 90, 70);
111
112 --replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 $group_b GROUP_B
113 --eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_b', '127.0.0.1', $SERVER_MYPORT_3, '', 85, 65);
114
115 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server1'
116 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_1, count, 1] = 1
117 --source include/assert.inc
118
119 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server3'
120 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_3, count, 1] = 1
121 --source include/assert.inc
122
123 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group A'
124 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_a", count, 1] = 1
125 --source include/assert.inc
126
127 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group B'
128 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1
129 --source include/assert.inc
130
131
132 --echo
133 --echo ############################################################
134 --echo # 4. Create and start the managed channel.
135 --let $rpl_connection_name= server5
136 --source include/rpl_connection.inc
137 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
138 --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_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch1'
139
140 --let $rpl_channel_name='ch1'
141 --source include/start_slave.inc
142 --let $rpl_channel_name=
143
144 --let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server1
145 --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"
146 --source include/assert.inc
147
148 --let $wait_condition= SELECT COUNT(*)=4 FROM performance_schema.replication_asynchronous_connection_failover
149 --source include/wait_condition.inc
150
151
152 --echo
153 --echo ############################################################
154 --echo # 5. Kill server2, group A will block due no majority.
155 --let $rpl_connection_name= server2
156 --source include/rpl_connection.inc
157 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
158 --shutdown_server 0
159 --source include/wait_until_disconnected.inc
160
161 --let $rpl_connection_name= server1
162 --source include/rpl_connection.inc
163 --let $group_replication_member_state= UNREACHABLE
164 --let $group_replication_member_id= $server2_uuid
165 --source include/gr_wait_for_member_state.inc
166
167
168 --echo
169 --echo ############################################################
170 --echo # 6. Since the group A has no majority, the replica will connect
171 --echo # to server3 on group B.
172 --let $rpl_connection_name= server5
173 --source include/rpl_connection.inc
174 --echo Wait until ch1 IO_THREAD is connected to server3
175 --let $wait_condition= SELECT service_state="ON" FROM performance_schema.replication_connection_status WHERE channel_name="ch1" AND source_uuid="$server3_uuid"
176 --source include/wait_condition.inc
177
178 --let $assert_only_after = CURRENT_TEST: group_replication.gr_acf_sender_no_majority_2groups
179 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.5.err
180 --let $assert_select= 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.
181 --let $assert_count= 1
182 --let $assert_text= The ER_RPL_ASYNC_CHANNEL_STOPPED_QUORUM_LOST error is logged
183 --source include/assert_grep.inc
184
185
186 --echo
187 --echo ############################################################
188 --echo # 7. Assert that group A information did not change, since it
189 --echo # lost the majority.
190 --let $rpl_connection_name= server5
191 --source include/rpl_connection.inc
192
193 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server1'
194 --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_a" , count, 1] = 1
195 --source include/assert.inc
196
197 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server2'
198 --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_a" , count, 1] = 1
199 --source include/assert.inc
200
201
202 --echo
203 --echo ############################################################
204 --echo # 8. Clean up.
205 --let $rpl_connection_name= server5
206 --source include/rpl_connection.inc
207 --let $rpl_channel_name='ch1'
208 --source include/stop_slave.inc
209
210 --let $rpl_reset_slave_all= 1
211 --let $rpl_multi_source= 1
212 --source include/rpl_reset_slave.inc
213 --let $rpl_channel_name=
214 --let $rpl_reset_slave_all=
215 --let $rpl_multi_source=
216
217 --replace_result $group_a GROUP_A
218 --eval SELECT asynchronous_connection_failover_delete_managed('ch1', '$group_a')
219
220 --let $assert_text= 'There are 0 rows in performance_schema.replication_asynchronous_connection_failover_managed for group A'
221 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_a", count, 1] = 0
222 --source include/assert.inc
223
224 --let $assert_text= 'There is 1 row in performance_schema.replication_asynchronous_connection_failover_managed for group B'
225 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1
226 --source include/assert.inc
227
228 --let $assert_text= 'There are 0 rows in performance_schema.replication_asynchronous_connection_failover for group A'
229 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE managed_name="$group_a" , count, 1] = 0
230 --source include/assert.inc
231
232 --let $assert_text= 'There are 2 rows in performance_schema.replication_asynchronous_connection_failover for group B'
233 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE managed_name="$group_b" , count, 1] = 2
234 --source include/assert.inc
235
236 --replace_result $group_b GROUP_B
237 --eval SELECT asynchronous_connection_failover_delete_managed('ch1', '$group_b')
238
239 --let $assert_text= 'There are no rows in performance_schema.replication_asynchronous_connection_failover'
240 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 0
241 --source include/assert.inc
242
243 --let $assert_text= 'There are no rows in performance_schema.replication_asynchronous_connection_failover_managed'
244 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed, count, 1] = 0
245 --source include/assert.inc
246
247 SET SESSION sql_log_bin = 0;
248 call mtr.add_suppression("The source .* for channel 'ch1' has joined the group .*, and so added its entry into replication_asynchronous_connection_failover table.");
249 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.");
250 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.*");
251 call mtr.add_suppression("The Monitor IO thread failed to connect to the source .* for channel 'ch1', thence it will try to connect to another source.");
252 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.");
253 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.");
254 SET SESSION sql_log_bin = 1;
255
256 --let $rpl_connection_name= server1
257 --source include/rpl_connection.inc
258 --source include/stop_group_replication.inc
259
260 SET SESSION sql_log_bin = 0;
261 call mtr.add_suppression("\\[GCS\\] Timeout while waiting for the group communication engine to exit!");
262 call mtr.add_suppression("\\[GCS\\] The member has failed to gracefully leave the group.");
263 SET SESSION sql_log_bin = 1;
264
265 --let $rpl_connection_name= server2
266 --source include/rpl_connection.inc
267 --enable_reconnect
268 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
269 --source include/wait_until_connected_again.inc
270 --disable_reconnect
271 --let $rpl_server_number= 2
272 --source include/rpl_reconnect.inc
273
274 --let $rpl_connection_name= server4
275 --source include/rpl_connection.inc
276 --source include/stop_group_replication.inc
277
278 --let $rpl_connection_name= server3
279 --source include/rpl_connection.inc
280 --source include/stop_group_replication.inc
281
282 --source include/group_replication_end.inc