File: gr_acf_receiver_network_partition.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (323 lines) | stat: -rw-r--r-- 16,324 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
###############################################################################
# Validate that whenever the primary loses contact with the majority, if there
# is a running Monitor IO thread, the Monitor IO thread will not monitor
# sources until the primary returns to the group majority.
#
# Test:
#   0. This test requires 4 servers:
#        server1: group A primary
#        server2: group A secondary
#        server3: group B primary
#        server4: group B secondary
#   1. Deploy group A in single-primary mode on server1 and server2.
#   2. Deploy group B in single-primary mode on server3.
#      Configure server4 as part of group B but not join it to
#      the group.
#   3. Configure a failover channel on server1 that replicates
#      from server3.
#   4. Suspend server2, server1 will see it UNREACHABLE.
#   5. Add server4 to group B.
#   6. Since group A does not have a ONLINE majority, server1
#      will not detect the membership changes on group B.
#   7. Resume server2.
#   8. server1 will update group B membership.
#   9. server2 will also update group B membership.
#  10. Clean up.
###############################################################################
--source include/linux.inc
--source include/big_test.inc
--source include/have_group_replication_plugin.inc
--let $rpl_group_replication_single_primary_mode=1
--let $rpl_skip_group_replication_start= 1
--let $rpl_server_count= 4
--source include/group_replication.inc

# Use the appropriate XCom port, that does depend on
# `group_replication_communication_stack`.
--let $have_xcom_stack= `SELECT @@group_replication_communication_stack LIKE 'XCOM'`
--let $group_a_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2"
--let $group_b_group_seeds= "localhost:$SERVER_GR_PORT_3,localhost:$SERVER_GR_PORT_4"
if (!$have_xcom_stack) {
  --let $group_a_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2"
  --let $group_b_group_seeds= "localhost:$SERVER_MYPORT_3,localhost:$SERVER_MYPORT_4"
}

--echo
--echo ############################################################
--echo # 1. Deploy group A in single-primary mode on server1 and server2.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

SET SESSION sql_log_bin = 0;
call mtr.add_suppression("This server is not able to reach a majority of members in the group. This server will skip the replication failover channels handling until this server is back to the group majority.");
call mtr.add_suppression("This server is back to the group majority. Replication failover channels handling is resumed.");
SET SESSION sql_log_bin = 1;

--let $group_replication_group_name= aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
--let $group_a= $group_replication_group_name
--disable_query_log
--eval SET GLOBAL group_replication_group_seeds= $group_a_group_seeds
--enable_query_log
--source include/start_and_bootstrap_group_replication.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $server2_uuid= `SELECT @@server_uuid`

# Get server2 pid.
SET SESSION sql_log_bin= 0;
CREATE TABLE pid_table(pid_no INT);
--let $pid_file= `SELECT @@GLOBAL.pid_file`
--replace_result $pid_file pid_file
--eval LOAD DATA LOCAL INFILE '$pid_file' INTO TABLE pid_table
--let $server2_pid=`SELECT pid_no FROM pid_table`
DROP TABLE pid_table;
SET SESSION sql_log_bin= 1;

# Replication failover channels must be created on all group members.
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT
--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_3, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch1'

--disable_query_log
--eval SET GLOBAL group_replication_group_seeds= $group_a_group_seeds
--enable_query_log
--source include/start_group_replication.inc


--echo
--echo ############################################################
--echo # 2. Deploy group B in single-primary mode on server3.
--echo #    Configure server4 as part of group B but not join it to
--echo #    the group.
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $server3_uuid= `SELECT @@server_uuid`
--let $group_replication_group_name= bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
--let $group_b= $group_replication_group_name
--disable_query_log
--eval SET GLOBAL group_replication_group_seeds= $group_b_group_seeds
--enable_query_log
--source include/start_and_bootstrap_group_replication.inc

--let $rpl_connection_name= server4
--source include/rpl_connection.inc
--disable_query_log
--eval SET GLOBAL group_replication_group_seeds= $group_b_group_seeds
--enable_query_log


--echo
--echo ############################################################
--echo # 3. Configure a failover channel on server1 that replicates
--echo #    from server3.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT
--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_3, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch1'

--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 $group_b GROUP_B
--eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_b', '127.0.0.1', $SERVER_MYPORT_3, '', 85, 65);

--let $rpl_channel_name='ch1'
--source include/start_slave.inc

--let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server3
--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"
--source include/assert.inc

--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover'
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1
--source include/assert.inc

--let $failover_version_step3= `SELECT version FROM performance_schema.replication_group_configuration_version WHERE name='replication_asynchronous_connection_failover'`

--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1 or greater'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] >= 1
--source include/assert.inc

--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group B'
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1
--source include/assert.inc

--let $assert_text= 'The version of replication_asynchronous_connection_failover_managed must be 1'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover_managed\', version, 1] = 1
--source include/assert.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover'
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1
--source include/assert.inc

--let $assert_text= 'The version of replication_asynchronous_connection_failover must be equal or greater than the one on server1'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] >= $failover_version_step3
--source include/assert.inc

--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group B'
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1
--source include/assert.inc

--let $assert_text= 'The version of replication_asynchronous_connection_failover_managed must be 1'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover_managed\', version, 1] = 1
--source include/assert.inc


--echo
--echo ############################################################
--echo # 4. Suspend server2, server1 will see it UNREACHABLE.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--exec kill -19 $server2_pid

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $group_replication_member_state= UNREACHABLE
--let $group_replication_member_id= $server2_uuid
--source include/gr_wait_for_member_state.inc

--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.error_log WHERE error_code='MY-013788' AND PRIO='Warning' AND data LIKE "This server is not able to reach a majority of members in the group. This server will skip the replication failover channels handling until this server is back to the group majority."
--source include/wait_condition.inc


--echo
--echo ############################################################
--echo # 5. Add server4 to group B.
--let $rpl_connection_name= server4
--source include/rpl_connection.inc
--source include/start_group_replication.inc

--let $wait_condition=SELECT COUNT(*)=2 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE"
--source include/wait_condition.inc


--echo
--echo ############################################################
--echo # 6. Since group A does not have a ONLINE majority, server1
--echo #    will not detect the membership changes on group B.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $failover_version_step6= `SELECT version FROM performance_schema.replication_group_configuration_version WHERE name='replication_asynchronous_connection_failover'`

# Give some time to Monitor IO thread to attempt reach group B
--sleep 15

--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover'
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1
--source include/assert.inc

--let $assert_text= 'The version of replication_asynchronous_connection_failover must remain the same'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = $failover_version_step6
--source include/assert.inc

--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let $assert_select= This server is not able to reach a majority of members in the group. This server will skip the replication failover channels handling until this server is back to the group majority.
--let $assert_count= 1
--let $assert_text= Only one majority loss warning is logged
--source include/assert_grep.inc


--echo
--echo ############################################################
--echo # 7. Resume server2.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--exec kill -18 $server2_pid

--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $wait_condition=SELECT COUNT(*)=2 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE"
--source include/wait_condition.inc

--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.error_log WHERE error_code='MY-013789' AND PRIO='Warning' AND data LIKE "This server is back to the group majority. Replication failover channels handling is resumed."
--source include/wait_condition.inc


--echo
--echo ############################################################
--echo # 8. server1 will update group B membership.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover
--source include/wait_condition.inc

--let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server3
--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"
--source include/assert.inc

--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 2 or greater'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] >= 2
--source include/assert.inc
--let $failover_version_step8= `SELECT version FROM performance_schema.replication_group_configuration_version WHERE name='replication_asynchronous_connection_failover'`

--let $assert_text= 'The version of replication_asynchronous_connection_failover must be equal or greater than the one on server1 on step 6'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] >= $failover_version_step6
--source include/assert.inc

--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group B'
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1
--source include/assert.inc

--let $assert_text= 'The version of replication_asynchronous_connection_failover_managed must be 1'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover_managed\', version, 1] = 1
--source include/assert.inc


--echo
--echo ############################################################
--echo # 9. server2 will also update group B membership.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover
--source include/wait_condition.inc

--let $assert_text= 'The version of replication_asynchronous_connection_failover must be equal or greater than the one on server1'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] >= $failover_version_step8
--source include/assert.inc

--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group B'
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1
--source include/assert.inc

--let $assert_text= 'The version of replication_asynchronous_connection_failover_managed must be 1'
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover_managed\', version, 1] = 1
--source include/assert.inc


--echo
--echo ############################################################
--echo # 10. Clean up.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/stop_group_replication.inc

--let $rpl_channel_name='ch1'
--let $rpl_multi_source= 1
--let $rpl_reset_slave_all= 1
--source include/rpl_reset_slave.inc
--let $rpl_channel_name=
--let $rpl_multi_source=

--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/stop_group_replication.inc

--let $rpl_channel_name='ch1'
--let $rpl_multi_source= 1
--let $rpl_reset_slave_all= 1
--source include/rpl_reset_slave.inc
--let $rpl_channel_name=
--let $rpl_multi_source=

--let $rpl_connection_name= server4
--source include/rpl_connection.inc
--source include/stop_group_replication.inc

--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--source include/stop_group_replication.inc

--source include/group_replication_end.inc