File: gr_replicate_group_to_group.inc

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 (250 lines) | stat: -rw-r--r-- 10,051 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
################################################################################
#
# Bug#25674926 VIEW CHANGE LOG EVENTS GENERATE NEW GTIDS
#
# Problem: When there is replication (async) between two groups,
#          group nodes are confused when it receives view_change_log_event
#          that is generated on the other group and the event is making
#          infinite round trips between the groups in case if the async
#          replication is circular replication.
#
# Scenario: Verify Group Replication behavior when we establish a
#           circular replication connection from a server in a group
#           to another server in the other group.
# Steps to reproduce:
#  0. The test requires six servers: M1, M2, M3, M4, M5 and M6.
#  1. Bootstrap start a group, GR1, on M1. Start GR on M2 and add it GR1.
#  2. Bootstrap start a group, GR2, on M3. Start GR on M4 and add it GR2.
#  3. Setup a asynchronous replication connection from M3(GR2) into M1(GR1)
#     i.e. M3 -> M1.
#  4. Setup a asynchronous replication connection from M1(GR1) into M3(GR2)
#     i.e. M1 -> M3.
#  5. Test view change event issue by adding/dropping nodes from the groups.
#     Add node M5 to group GR1, and add node M6 to group GR2 and immediately
#     drop the node from group (GR2). (This step is just to generate more
#     VIEW_EVENTs)
#  6. Execute some transactions on M3.
#  7. Wait until transactions executed on M3 are applied on all nodes of GR1
#     and GR2.
#  8. Execute some transactions on M1.
#  9. Wait until transactions executed on M1 are applied on all nodes of GR1
#     and GR2.
# 10. Validate data on all nodes (M1, M2, M3, M4 and M5).
# 11. Check that GTID_EXECUTED on all servers are as expected.
# 12. Clean data.
# 13. Stop circular replication between groups.
# 14. Stop Group Replication on all nodes (M1, M2, M3, M4 and M5).
################################################################################

# This test script needs '6' servers. Hence marking it as big test.
--source include/big_test.inc

--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420000
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--let $rpl_server_count= 6
--source include/group_replication.inc

--echo
--echo #################################################################
--echo #  1. Setup Group Replication on M1 and M2 and create group GR1.
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420000
--connection server1
--let $server1_local_address = `SELECT @@GLOBAL.group_replication_local_address;`
SET @@GLOBAL.group_replication_group_seeds= "";
--source include/start_and_bootstrap_group_replication.inc

--connection server2
--replace_result $server1_local_address GROUP_REPLICATION_GROUP_SEEDS
--eval SET @@GLOBAL.group_replication_group_seeds= "$server1_local_address"
--source include/start_group_replication.inc

--let $group_replication_number_of_members= 2
--source include/gr_wait_for_number_of_members.inc

--echo
--echo #################################################################
--echo #  2. Setup Group Replication on M1 and M2 and create group GR2.
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa942000d
--connection server3
--let $server3_local_address = `SELECT @@GLOBAL.group_replication_local_address;`
SET @@GLOBAL.group_replication_group_seeds= "";
--source include/start_and_bootstrap_group_replication.inc

--connection server4
--replace_result $server3_local_address GROUP_REPLICATION_GROUP_SEEDS
--eval SET @@GLOBAL.group_replication_group_seeds= "$server3_local_address"
--source include/start_group_replication.inc

--let $group_replication_number_of_members= 2
--source include/gr_wait_for_number_of_members.inc

--echo
--echo ###############################################################
--echo #  3. Setup a asynchronous replication connection from M3 (GR2)
--echo #     to M1 (GR1).
--connection server1
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_USER="root", SOURCE_PASSWORD="", SOURCE_PORT=$SERVER_MYPORT_3, SOURCE_AUTO_POSITION=1
--source include/start_slave.inc

--echo
--echo ###############################################################
--echo #  4. Setup a asynchronous replication connection from M1 (GR1)
--echo #     to M3 (GR2).
--connection server3
--replace_result $SERVER_MYPORT_1 SERVER_1_PORT
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_USER="root", SOURCE_PASSWORD="", SOURCE_PORT=$SERVER_MYPORT_1, SOURCE_AUTO_POSITION=1
--source include/start_slave.inc

--echo
--echo ###############################################################
--echo #  5. Test view change issue by adding/dropping nodes from the
--echo #     groups (just to generate more VIEW_EVENTs).
--echo # 5.1. Add a node M5 to group (GR1).
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420000
--connection server5
--replace_result $server1_local_address GROUP_REPLICATION_GROUP_SEEDS
--eval SET @@GLOBAL.group_replication_group_seeds= "$server1_local_address"
--source include/start_group_replication.inc

--let $group_replication_number_of_members= 3
--source include/gr_wait_for_number_of_members.inc

--echo
--echo ################################################################
--echo # 5.2. Add and immediately drop a node M6 to group (GR2).
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa942000d
--connection server6
--replace_result $server3_local_address GROUP_REPLICATION_GROUP_SEEDS
--eval SET @@GLOBAL.group_replication_group_seeds= "$server3_local_address"
--source include/start_group_replication.inc

--let $group_replication_number_of_members= 3
--source include/gr_wait_for_number_of_members.inc
--source include/stop_group_replication.inc

--echo
--echo ############################################################
--echo #  6. Execute some transactions on M3 (GR2).
--connection server3
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0);
INSERT INTO t1 VALUES (1);
UPDATE t1 SET c1=2 WHERE c1=0;
DELETE FROM t1 WHERE c1=1;

--echo
--echo ############################################################
--echo #  7. Wait until transactions executed on M3 are applied
--echo #     on all nodes in both groups.
--connection server3
--let $sync_slave_connection= server1
--source include/sync_slave_sql_with_master.inc
--connection server3
--let $sync_slave_connection= server2
--source include/sync_slave_sql_with_master.inc
--connection server3
--let $sync_slave_connection= server4
--source include/sync_slave_sql_with_master.inc
--connection server3
--let $sync_slave_connection= server5
--source include/sync_slave_sql_with_master.inc

--echo
--echo ############################################################
--echo #  8. Execute some transactions on M1 (GR1).
--connection server1
CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t2 VALUES (0);
INSERT INTO t2 VALUES (1);
UPDATE t2 SET c1=2 WHERE c1=0;
DELETE FROM t2 WHERE c1=1;

--echo
--echo ############################################################
--echo #  9. Wait until transactions executed on M1 are applied
--echo #     on all nodes in both groups.
--connection server1
--let $sync_slave_connection= server2
--source include/sync_slave_sql_with_master.inc
--connection server1
--let $sync_slave_connection= server3
--source include/sync_slave_sql_with_master.inc
--connection server1
--let $sync_slave_connection= server4
--source include/sync_slave_sql_with_master.inc
--connection server1
--let $sync_slave_connection= server5
--source include/sync_slave_sql_with_master.inc

--echo
--echo #########################################################################
--echo # 10. Validate data on all nodes (M1, M2, M3, M4 and M5)
--let diff_tables=server_1:t1, server_2:t1, server_3:t1, server_4:t1, server_5:t1
--source include/diff_tables.inc

--let diff_tables=server_1:t2, server_2:t2, server_3:t2, server_4:t2, server_5:t2
--source include/diff_tables.inc

--echo
--echo #########################################################################
--echo # 11. Check that GTID_EXECUTED on all servers are as expected.
--let $i=1
while ($i <= 5)
{
  --connection server$i
  SET SESSION sql_log_bin= 0;
  --source include/gtid_utils.inc
  SET SESSION sql_log_bin= 1;
  --let $expected_gtid_set= 8a94f357-aab4-11df-86ab-c80aa9420000:1-8, 8a94f357-aab4-11df-86ab-c80aa942000d:1-8
  --let $assert_text= Check that GTID_EXECUTED set on all servers are as expected.
  --let $assert_cond= GTID_IS_EQUAL("[SELECT @@GLOBAL.GTID_EXECUTED]", "$expected_gtid_set")
  --source include/assert.inc
  SET SESSION sql_log_bin= 0;
  --source include/gtid_utils_end.inc
  SET SESSION sql_log_bin= 1;
  --inc $i
}

--echo
--echo ############################################################
--echo #  12. Clean data.
--connection server3
DROP TABLE t1;
DROP TABLE t2;

--let $sync_slave_connection= server1
--source include/sync_slave_sql_with_master.inc
--connection server3
--let $sync_slave_connection= server2
--source include/sync_slave_sql_with_master.inc
--connection server3
--let $sync_slave_connection= server4
--source include/sync_slave_sql_with_master.inc
--connection server3
--let $sync_slave_connection= server5
--source include/sync_slave_sql_with_master.inc

--echo
--echo ##############################################################
--echo # 13. Stop asynchronous replication between M3->M1 and M1->M3.
--connection server1
--source include/stop_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0 FOR CHANNEL "";
--connection server3
--source include/stop_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0 FOR CHANNEL "";

--echo
--echo ############################################################
--echo # 14. Stop Group Replication on all 5 nodes.
--let $i=1
while ($i <= 5)
{
  --connection server$i
  --source include/stop_group_replication.inc
  --inc $i
}

--source include/group_replication_end.inc