Debian Codegraph @

mysql-test/suite/group_replication/include/gr_replicate_group_to_group.inc

raw
1 ################################################################################
2 #
3 # Bug#25674926 VIEW CHANGE LOG EVENTS GENERATE NEW GTIDS
4 #
5 # Problem: When there is replication (async) between two groups,
6 # group nodes are confused when it receives view_change_log_event
7 # that is generated on the other group and the event is making
8 # infinite round trips between the groups in case if the async
9 # replication is circular replication.
10 #
11 # Scenario: Verify Group Replication behavior when we establish a
12 # circular replication connection from a server in a group
13 # to another server in the other group.
14 # Steps to reproduce:
15 # 0. The test requires six servers: M1, M2, M3, M4, M5 and M6.
16 # 1. Bootstrap start a group, GR1, on M1. Start GR on M2 and add it GR1.
17 # 2. Bootstrap start a group, GR2, on M3. Start GR on M4 and add it GR2.
18 # 3. Setup a asynchronous replication connection from M3(GR2) into M1(GR1)
19 # i.e. M3 -> M1.
20 # 4. Setup a asynchronous replication connection from M1(GR1) into M3(GR2)
21 # i.e. M1 -> M3.
22 # 5. Test view change event issue by adding/dropping nodes from the groups.
23 # Add node M5 to group GR1, and add node M6 to group GR2 and immediately
24 # drop the node from group (GR2). (This step is just to generate more
25 # VIEW_EVENTs)
26 # 6. Execute some transactions on M3.
27 # 7. Wait until transactions executed on M3 are applied on all nodes of GR1
28 # and GR2.
29 # 8. Execute some transactions on M1.
30 # 9. Wait until transactions executed on M1 are applied on all nodes of GR1
31 # and GR2.
32 # 10. Validate data on all nodes (M1, M2, M3, M4 and M5).
33 # 11. Check that GTID_EXECUTED on all servers are as expected.
34 # 12. Clean data.
35 # 13. Stop circular replication between groups.
36 # 14. Stop Group Replication on all nodes (M1, M2, M3, M4 and M5).
37 ################################################################################
38
39 # This test script needs '6' servers. Hence marking it as big test.
40 --source include/big_test.inc
41
42 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420000
43 --source include/have_group_replication_plugin.inc
44 --let $rpl_skip_group_replication_start= 1
45 --let $rpl_server_count= 6
46 --source include/group_replication.inc
47
48 --echo
49 --echo #################################################################
50 --echo # 1. Setup Group Replication on M1 and M2 and create group GR1.
51 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420000
52 --connection server1
53 --let $server1_local_address = `SELECT @@GLOBAL.group_replication_local_address;`
54 SET @@GLOBAL.group_replication_group_seeds= "";
55 --source include/start_and_bootstrap_group_replication.inc
56
57 --connection server2
58 --replace_result $server1_local_address GROUP_REPLICATION_GROUP_SEEDS
59 --eval SET @@GLOBAL.group_replication_group_seeds= "$server1_local_address"
60 --source include/start_group_replication.inc
61
62 --let $group_replication_number_of_members= 2
63 --source include/gr_wait_for_number_of_members.inc
64
65 --echo
66 --echo #################################################################
67 --echo # 2. Setup Group Replication on M1 and M2 and create group GR2.
68 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa942000d
69 --connection server3
70 --let $server3_local_address = `SELECT @@GLOBAL.group_replication_local_address;`
71 SET @@GLOBAL.group_replication_group_seeds= "";
72 --source include/start_and_bootstrap_group_replication.inc
73
74 --connection server4
75 --replace_result $server3_local_address GROUP_REPLICATION_GROUP_SEEDS
76 --eval SET @@GLOBAL.group_replication_group_seeds= "$server3_local_address"
77 --source include/start_group_replication.inc
78
79 --let $group_replication_number_of_members= 2
80 --source include/gr_wait_for_number_of_members.inc
81
82 --echo
83 --echo ###############################################################
84 --echo # 3. Setup a asynchronous replication connection from M3 (GR2)
85 --echo # to M1 (GR1).
86 --connection server1
87 --replace_result $SERVER_MYPORT_3 SERVER_3_PORT
88 --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
89 --source include/start_slave.inc
90
91 --echo
92 --echo ###############################################################
93 --echo # 4. Setup a asynchronous replication connection from M1 (GR1)
94 --echo # to M3 (GR2).
95 --connection server3
96 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
97 --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
98 --source include/start_slave.inc
99
100 --echo
101 --echo ###############################################################
102 --echo # 5. Test view change issue by adding/dropping nodes from the
103 --echo # groups (just to generate more VIEW_EVENTs).
104 --echo # 5.1. Add a node M5 to group (GR1).
105 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420000
106 --connection server5
107 --replace_result $server1_local_address GROUP_REPLICATION_GROUP_SEEDS
108 --eval SET @@GLOBAL.group_replication_group_seeds= "$server1_local_address"
109 --source include/start_group_replication.inc
110
111 --let $group_replication_number_of_members= 3
112 --source include/gr_wait_for_number_of_members.inc
113
114 --echo
115 --echo ################################################################
116 --echo # 5.2. Add and immediately drop a node M6 to group (GR2).
117 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa942000d
118 --connection server6
119 --replace_result $server3_local_address GROUP_REPLICATION_GROUP_SEEDS
120 --eval SET @@GLOBAL.group_replication_group_seeds= "$server3_local_address"
121 --source include/start_group_replication.inc
122
123 --let $group_replication_number_of_members= 3
124 --source include/gr_wait_for_number_of_members.inc
125 --source include/stop_group_replication.inc
126
127 --echo
128 --echo ############################################################
129 --echo # 6. Execute some transactions on M3 (GR2).
130 --connection server3
131 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
132 INSERT INTO t1 VALUES (0);
133 INSERT INTO t1 VALUES (1);
134 UPDATE t1 SET c1=2 WHERE c1=0;
135 DELETE FROM t1 WHERE c1=1;
136
137 --echo
138 --echo ############################################################
139 --echo # 7. Wait until transactions executed on M3 are applied
140 --echo # on all nodes in both groups.
141 --connection server3
142 --let $sync_slave_connection= server1
143 --source include/sync_slave_sql_with_master.inc
144 --connection server3
145 --let $sync_slave_connection= server2
146 --source include/sync_slave_sql_with_master.inc
147 --connection server3
148 --let $sync_slave_connection= server4
149 --source include/sync_slave_sql_with_master.inc
150 --connection server3
151 --let $sync_slave_connection= server5
152 --source include/sync_slave_sql_with_master.inc
153
154 --echo
155 --echo ############################################################
156 --echo # 8. Execute some transactions on M1 (GR1).
157 --connection server1
158 CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
159 INSERT INTO t2 VALUES (0);
160 INSERT INTO t2 VALUES (1);
161 UPDATE t2 SET c1=2 WHERE c1=0;
162 DELETE FROM t2 WHERE c1=1;
163
164 --echo
165 --echo ############################################################
166 --echo # 9. Wait until transactions executed on M1 are applied
167 --echo # on all nodes in both groups.
168 --connection server1
169 --let $sync_slave_connection= server2
170 --source include/sync_slave_sql_with_master.inc
171 --connection server1
172 --let $sync_slave_connection= server3
173 --source include/sync_slave_sql_with_master.inc
174 --connection server1
175 --let $sync_slave_connection= server4
176 --source include/sync_slave_sql_with_master.inc
177 --connection server1
178 --let $sync_slave_connection= server5
179 --source include/sync_slave_sql_with_master.inc
180
181 --echo
182 --echo #########################################################################
183 --echo # 10. Validate data on all nodes (M1, M2, M3, M4 and M5)
184 --let diff_tables=server_1:t1, server_2:t1, server_3:t1, server_4:t1, server_5:t1
185 --source include/diff_tables.inc
186
187 --let diff_tables=server_1:t2, server_2:t2, server_3:t2, server_4:t2, server_5:t2
188 --source include/diff_tables.inc
189
190 --echo
191 --echo #########################################################################
192 --echo # 11. Check that GTID_EXECUTED on all servers are as expected.
193 --let $i=1
194 while ($i <= 5)
195 {
196 --connection server$i
197 SET SESSION sql_log_bin= 0;
198 --source include/gtid_utils.inc
199 SET SESSION sql_log_bin= 1;
200 --let $expected_gtid_set= 8a94f357-aab4-11df-86ab-c80aa9420000:1-8, 8a94f357-aab4-11df-86ab-c80aa942000d:1-8
201 --let $assert_text= Check that GTID_EXECUTED set on all servers are as expected.
202 --let $assert_cond= GTID_IS_EQUAL("[SELECT @@GLOBAL.GTID_EXECUTED]", "$expected_gtid_set")
203 --source include/assert.inc
204 SET SESSION sql_log_bin= 0;
205 --source include/gtid_utils_end.inc
206 SET SESSION sql_log_bin= 1;
207 --inc $i
208 }
209
210 --echo
211 --echo ############################################################
212 --echo # 12. Clean data.
213 --connection server3
214 DROP TABLE t1;
215 DROP TABLE t2;
216
217 --let $sync_slave_connection= server1
218 --source include/sync_slave_sql_with_master.inc
219 --connection server3
220 --let $sync_slave_connection= server2
221 --source include/sync_slave_sql_with_master.inc
222 --connection server3
223 --let $sync_slave_connection= server4
224 --source include/sync_slave_sql_with_master.inc
225 --connection server3
226 --let $sync_slave_connection= server5
227 --source include/sync_slave_sql_with_master.inc
228
229 --echo
230 --echo ##############################################################
231 --echo # 13. Stop asynchronous replication between M3->M1 and M1->M3.
232 --connection server1
233 --source include/stop_slave.inc
234 CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0 FOR CHANNEL "";
235 --connection server3
236 --source include/stop_slave.inc
237 CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0 FOR CHANNEL "";
238
239 --echo
240 --echo ############################################################
241 --echo # 14. Stop Group Replication on all 5 nodes.
242 --let $i=1
243 while ($i <= 5)
244 {
245 --connection server$i
246 --source include/stop_group_replication.inc
247 --inc $i
248 }
249
250 --source include/group_replication_end.inc