Debian Codegraph @

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

raw
1 ################################################################################
2 # This test verifies that group replication channels are not affect by global
3 # RESET SLAVE commands when the group replication is running.
4 # If a command is used directly in a group channel it should work.
5 # If a command is used when group replication is stopped it should work.
6 #
7 # Test:
8 # 0. The test requires two servers: M1, M2 and M3.
9 #
10 # 1. Phase 1: Setup a 2 server group.
11 # a) Check that the applier files are not there before start GR.
12 # b) Bootstrap start group on M1. Add some data for recovery.
13 # c) Start GR on M2.
14 # d) Create a slave channel on M1 with M3 i.e. M3 -> M1.
15 #
16 # 2. Phase 2: Check that the group replication applier files are present.
17 # a) On M1, group applier files should now be present with the channel.
18 # b) On M1, slave files should be present.
19 # c) On M2, group applier files should now be present with the channel.
20 # b) On M2, recovery files should be present.
21 #
22 # 3. Phase 3: Check that the RESET SLAVE command doesn't affect GR specific
23 # channels when the GR member is ONLINE.
24 # a) Execute RESET SLAVE ALL command on M1.
25 # b) Validate that group applier files are still present on M1.
26 # c) Check that slave files are removed on M1.
27 #
28 # 4. Phase 4: After a direct reset command all files should disappear.
29 # a) RESET SLAVE ALL command should fail on an ONLINE member M1.
30 # b) Stop GR on M1.
31 # c) Execute RESET SLAVE ALL command on M1.
32 # d) Validate that group applier files are removed.
33 #
34 # 5. Phase 5: Restart server 1 plugin, all should be fine.
35 # a) Add some data for recovery on M2.
36 # b) Start GR on M1.
37 # c) Add some data on M1 to check if all is fine.
38 # d) Validate that both members have all the data.
39 #
40 # 6. Phase 6: When GR is stopped, after global reset command all files
41 # should disappear.
42 # a) Stop GR on M2.
43 # b) Execute RESET SLAVE command on M2
44 # c) Validate that slave_master_info and slave_relay_log_info tables are
45 # cleared.
46 # d) Start GR on M2. The node should be ONLINE.
47 #
48 # 7. Phase 7: When GR is stopped, after global RESET SLAVE ALL command all
49 # files should disappear including recovery channel specific credentials.
50 # a) Stop GR on M2.
51 # b) Execute RESET SLAVE ALL command on M2
52 # c) Validate that slave_master_info and slave_relay_log_info tables are
53 # cleared.
54 # d) Execute CHANGE MASTER command to provide recovery channel credentials.
55 # f) Start GR on M2. The node should be ONLINE.
56 #
57 # 6. Phase 6: Cleanup.
58 ################################################################################
59
60 --source include/not_have_privilege_checks_user.inc
61 --source include/have_group_replication_plugin.inc
62 --let $rpl_skip_group_replication_start= 1
63 --let $rpl_server_count= 3
64 --source include/group_replication.inc
65
66 #
67 # Phase 1: Setup a 2 server group
68 # Check that the applier files are not there before start
69 # Create also a slave channel on server
70 #
71
72 --connection server1
73 --echo server1
74
75 --let $datadir_1= `SELECT @@GLOBAL.datadir`
76
77 --let $relay_log_file=`SELECT CONCAT('$datadir_1','mgr-group_replication_applier.000001')`
78 --error 1
79 --file_exists $relay_log_file
80
81 --let $relay_log_index= `SELECT CONCAT('$datadir_1', 'mgr-group_replication_applier.index')`
82 --error 1
83 --file_exists $relay_log_index
84
85 --source include/start_and_bootstrap_group_replication.inc
86
87 # Add some data for recovery
88 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
89 BEGIN;
90 INSERT INTO t1 VALUES (1);
91 INSERT INTO t1 VALUES (2);
92 COMMIT;
93 INSERT INTO t1 VALUES (3);
94
95 --connection server2
96 --echo server2
97 --source include/start_group_replication.inc
98
99 --connection server1
100 --let $group_replication_number_of_members= 2
101 --source include/gr_wait_for_number_of_members.inc
102
103 # Create a slave channel with server 3
104
105 --disable_warnings
106 --replace_result $SERVER_MYPORT_3 SERVER_3_PORT
107 --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 FOR CHANNEL "channel_1"
108 --enable_warnings
109
110 #
111 # Phase 2: Check that the group replication applier files are present.
112 # Recovery files should be present on the recovered server as they were only
113 # reset.
114 #
115
116 --connection server1
117
118 # Group applier files should now be there with the channel
119
120 --file_exists $relay_log_file
121 --file_exists $relay_log_index
122
123 --let $assert_text= 'The group replication applier channel is present'
124 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_applier", count, 1] = 1
125 --source include/assert.inc
126
127 # Slave files should be there
128
129 --let $slave_relay_log_file=`SELECT CONCAT('$datadir_1','mgr-channel_1.000001')`
130 --file_exists $slave_relay_log_file
131
132 --let $slave_relay_log_index= `SELECT CONCAT('$datadir_1', 'mgr-channel_1.index')`
133 --file_exists $slave_relay_log_index
134
135 --let $assert_text= 'The slave channel is present'
136 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="channel_1", count, 1] = 1
137 --source include/assert.inc
138
139 --connection server2
140
141 --let $datadir_2= `SELECT @@GLOBAL.datadir`
142
143 --let $relay_log_file=`SELECT CONCAT('$datadir_2','mgr-group_replication_applier.000001')`
144 --file_exists $relay_log_file
145
146 --let $relay_log_index= `SELECT CONCAT('$datadir_2', 'mgr-group_replication_applier.index')`
147 --file_exists $relay_log_index
148
149 # Recovery files are also there
150
151 --let $recovery_relay_log_file= `SELECT CONCAT('$datadir_2', 'mgr-group_replication_recovery.000001')`
152 --file_exists $recovery_relay_log_file
153
154 --let $recovery_relay_log_index= `SELECT CONCAT('$datadir_2', 'mgr-group_replication_recovery.index')`
155 --file_exists $recovery_relay_log_index
156
157 #
158 # Phase 3: Check that the RESET SLAVE command doesn't affect group replication
159 # specific channels when the GR member is ONLINE. Only the slave channel should
160 # not be there
161 #
162
163 --connection server1
164
165 # Global RESET SLAVE ALL command will not work on group replication channels
166 # when the group memeber is ONLINE.
167 --error ER_REPLICA_CHANNEL_OPERATION_NOT_ALLOWED
168 RESET SLAVE ALL;
169
170 --let $relay_log_file=`SELECT CONCAT('$datadir_1','mgr-group_replication_applier.000001')`
171 --file_exists $relay_log_file
172
173 --let $relay_log_index= `SELECT CONCAT('$datadir_1', 'mgr-group_replication_applier.index')`
174 --file_exists $relay_log_index
175
176 --let $assert_text= 'The group replication applier channel is still present'
177 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_applier", count, 1] = 1
178 --source include/assert.inc
179
180 --let $assert_text= 'The group replication applier channel is ON'
181 --let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_status where CHANNEL_NAME="group_replication_applier" and SERVICE_STATE="ON", count, 1] = 1
182 --source include/assert.inc
183
184 # The slave channel was removed
185
186 --error 1
187 --file_exists $slave_relay_log_file
188
189 --error 1
190 --file_exists $slave_relay_log_index
191
192 --let $assert_text= 'The slave channel is not present'
193 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="channel_1", count, 1] = 0
194 --source include/assert.inc
195
196 #
197 # Phase 4: After a direct reset command all files should disappear
198 # The command should not be allowed on group replication is running
199 #
200
201 --error ER_REPLICA_CHANNEL_OPERATION_NOT_ALLOWED
202 RESET SLAVE ALL FOR CHANNEL "group_replication_applier";
203
204 --source include/stop_group_replication.inc
205
206 RESET SLAVE ALL FOR CHANNEL "group_replication_applier";
207
208 --let $relay_log_file_mgr=`SELECT CONCAT('$datadir_1','mgr-group_replication_applier.000001')`
209 --error 1
210 --file_exists $relay_log_file_mgr
211
212 --let $relay_log_index_mgr= `SELECT CONCAT('$datadir_1', 'mgr-group_replication_applier.index')`
213 --error 1
214 --file_exists $relay_log_index_mgr
215
216 --let $assert_text= 'The group replication applier channel is not present'
217 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_applier", count, 1] = 0
218 --source include/assert.inc
219
220 #
221 # Phase 5: Restart server 1 plugin, all should be fine
222 #
223
224 --connection server2
225 --echo server2
226
227 INSERT INTO t1 VALUES (4);
228
229 --connection server1
230 --echo server1
231 --source include/start_group_replication.inc
232
233 INSERT INTO t1 VALUES (5);
234
235 --let $sync_slave_connection= server2
236 --source include/rpl_sync.inc
237
238 --let $assert_text= The table should contain 5 elements
239 --let $assert_cond= [select count(*) from t1] = 5;
240 --source include/assert.inc
241
242 #
243 # Phase 6: After a global reset command all files should disappear
244 #
245 --connection server2
246 --echo server2
247
248 --echo Vefiry that group replication channels are present
249 --let $assert_text= 'The group replication applier channel is present'
250 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_applier", count, 1] = 1
251 --source include/assert.inc
252
253 --let $assert_text= 'The group replication recovery channel is present'
254 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_recovery", count, 1] = 1
255 --source include/assert.inc
256 --let $datadir_2= `SELECT @@GLOBAL.datadir`
257
258 --source include/stop_group_replication.inc
259
260 --echo RESET SLAVE command clears master and slave info repositories and will flush master info
261 RESET SLAVE;
262
263 --let $assert_text= 'mysql.slave_relay_log_info contains flushed group replication channel information'
264 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name like "group_replication%", count, 1] = 2
265 --source include/assert.inc
266
267 --let $assert_text= 'mysql.slave_master_info contains flushed group replication channel information'
268 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_master_info WHERE channel_name like "group_replication%", count, 1] = 2
269 --source include/assert.inc
270
271 # Applier files are recreated
272 --let $relay_log_index= `SELECT CONCAT('$datadir_2', 'mgr-group_replication_applier.index')`
273 --file_exists $relay_log_index
274
275 # Recovery files are recreated
276 --let $recovery_relay_log_index= `SELECT CONCAT('$datadir_2', 'mgr-group_replication_recovery.index')`
277 --file_exists $recovery_relay_log_index
278
279 --source include/start_group_replication.inc
280
281 --let $assert_text= 'The group replication applier and recovery channel are present'
282 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name like "group_replication%", count, 1] = 2
283 --source include/assert.inc
284
285 #
286 # Phase 7: After a global reset slave all command, all files should disappear
287 # Executed the CHANGE MASTER command to create recovery channel and enable
288 # group replication.
289 #
290
291 --source include/stop_group_replication.inc
292 RESET SLAVE ALL;
293
294 --let $assert_text= 'mysql.slave_relay_log_info does not contrain group replication channel information'
295 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name like "group_replication%", count, 1] = 0
296 --source include/assert.inc
297
298 --let $assert_text= 'mysql.slave_master_info does not contrain group replication channel information'
299 --let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_master_info WHERE channel_name like "group_replication%", count, 1] = 0
300 --source include/assert.inc
301
302 --let $relay_log_index= `SELECT CONCAT('$datadir_2', 'mgr-group_replication_applier.index')`
303 --error 1
304 --file_exists $relay_log_index
305
306 # Recovery files are also removed
307
308 --let $recovery_relay_log_index= `SELECT CONCAT('$datadir_2', 'mgr-group_replication_recovery.index')`
309 --error 1
310 --file_exists $recovery_relay_log_index
311
312 CHANGE REPLICATION SOURCE TO SOURCE_USER="root" FOR CHANNEL "group_replication_recovery";
313
314 --source include/start_group_replication.inc
315
316 #
317 # Phase 8: Cleanup
318 #
319
320 DROP TABLE t1;
321
322 --source include/group_replication_end.inc