Debian Codegraph @

mysql-test/suite/rpl/t/rpl_cloned_slave_relay_log_info.test

raw
1 # ==== Purpose ====
2 #
3 # This script verifies that when cloning, replication info about
4 # - PRIVILEGE_CHECKS_USER
5 # - REQUIRE_ROW_FORMAT
6 # is preserved from the donor to the server invoking clone.
7 #
8 # ==== Implementation ====
9 #
10 # 1. Set up masters server_1 and server_3 with server_2 being a slave.
11 # 2. Create some tables for testing
12 # 3. On the slave
13 # Make channel_1 have PRIVILEGE_CHECKS_USER and REQUIRE_ROW_FORMAT
14 # Make channel_3 have REQUIRE_ROW_FORMAT
15 # 4. Install clone on server 2
16 # Configure server 4 to invoke clone
17 # 5. Verify replication info was cloned. Check:
18 # - PRIVILEGE_CHECKS_USER
19 # - REQUIRE_ROW_FORMAT
20 # 6. Verify other replication info was cleaned
21 # 7. Verify channels work when started
22 # 8. Cleanup
23 #
24 # ==== References ====
25 #
26 # Bug#29995256: PRIVILEGE_CHECKS_USER NOT CLONED FOR RECOVERY CHANNEL
27 #
28
29 --source include/big_test.inc
30 --source include/have_mysqld_monitoring_process.inc
31 --source include/have_clone_plugin.inc
32 --source include/not_have_privilege_checks_user.inc
33 --source include/have_binlog_format_row.inc
34 # Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE
35 --source include/have_slave_repository_type_table.inc
36
37 --echo #
38 --echo # 1. Set up masters server_1 and server_3 with server_2 being a slave.
39
40 --let $rpl_multi_source= 1
41 --let $rpl_topology= 1->2,3->2
42 --source include/rpl_init.inc
43
44 --connect(server_4,127.0.0.1,root,,test,$SERVER_MYPORT_4,)
45 --connect(server_4_1,127.0.0.1,root,,test,$SERVER_MYPORT_4,)
46
47 --echo #
48 --echo # 2. Create some tables for testing
49
50 --let $rpl_connection_name= server_1
51 --source include/rpl_connection.inc
52
53 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
54
55 --let $sync_slave_connection= server_2
56 --let $rpl_channel_name= 'channel_1'
57 --source include/sync_slave_sql_with_master.inc
58
59 --let $rpl_connection_name= server_3
60 --source include/rpl_connection.inc
61
62 CREATE TABLE t3 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
63
64 --let $sync_slave_connection= server_2
65 --let $rpl_channel_name= 'channel_3'
66 --source include/sync_slave_sql_with_master.inc
67
68 --echo #
69 --echo # 3. On the slave
70 --echo # Make channel_1 have PRIVILEGE_CHECKS_USER and REQUIRE_ROW_FORMAT
71 --echo # Make channel_3 have REQUIRE_ROW_FORMAT
72
73 # On slave
74 --let $rpl_connection_name= server_2
75 --source include/rpl_connection.inc
76
77 --let $rpl_channel_name= 'channel_1'
78 --source include/stop_slave.inc
79 CREATE USER 'u1'@'localhost';
80 GRANT SESSION_VARIABLES_ADMIN, REPLICATION_APPLIER ON *.* TO 'u1'@'localhost';
81 GRANT CREATE,INSERT,DROP ON *.* TO 'u1'@'localhost';
82 CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = 'u1'@'localhost', REQUIRE_ROW_FORMAT = 1 FOR CHANNEL 'channel_1';
83 --source include/start_slave.inc
84
85 --let $rpl_channel_name= 'channel_3'
86 --source include/stop_slave.inc
87 CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 1 FOR CHANNEL 'channel_3';
88 --source include/start_slave.inc
89
90 --echo #
91 --echo # 4. Install clone on server 2
92 --echo # Configure server 4 to invoke clone
93
94 --let $rpl_connection_name= server_2
95 --source include/rpl_connection.inc
96
97 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
98 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
99
100 --let $rpl_connection_name= server_4
101 --source include/rpl_connection.inc
102
103 # Make server 4 run with mysqld_safe
104 --let $mysqld_extra_settings=--skip-replica-start=1
105 --source include/spawn_monitoring_process.inc
106
107 # Install clone
108 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
109 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
110
111 # Set the clone valid donor list to include server 2
112 --replace_result $SERVER_MYPORT_2 SERVER2_PORT
113 --eval SET GLOBAL clone_valid_donor_list = 'localhost:$SERVER_MYPORT_2'
114
115 # Clone server 4 from server 2
116 --replace_result $SERVER_MYPORT_2 SERVER2_PORT
117 --eval CLONE INSTANCE FROM root@localhost:$SERVER_MYPORT_2 IDENTIFIED BY ''
118 --source include/wait_until_disconnected.inc
119
120 --let $rpl_server_number= 4
121 --source include/rpl_reconnect.inc
122
123 --echo #
124 --echo # 5. Verify replication info was cloned. Check:
125 --echo # - PRIVILEGE_CHECKS_USER
126 --echo # - REQUIRE_ROW_FORMAT
127
128 --let $channel_1_count = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE channel_name="channel_1" AND Privilege_checks_username = "u1" AND Privilege_checks_hostname="localhost" AND Require_row_format=1`
129 --let $assert_text= channel 1 was properly cloned
130 --let $assert_cond= $channel_1_count = 1
131 --source include/assert.inc
132
133 --let $channel_3_count = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE channel_name="channel_3" AND Require_row_format=1`
134 --let $assert_text= channel 3 was properly cloned
135 --let $assert_cond= $channel_3_count = 1
136 --source include/assert.inc
137
138 --let $channel_1_count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE channel_name= "channel_1" AND privilege_checks_user = "'u1'@'localhost'" AND require_row_format=1`
139 --let $assert_text= Performance schema values are correct for channel 1
140 --let $assert_cond= $channel_1_count = 1
141 --source include/assert.inc
142
143 --let $channel_3_count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE channel_name= "channel_3" AND privilege_checks_user IS NULL AND require_row_format=1`
144 --let $assert_text= Performance schema values are correct for channel 3
145 --let $assert_cond= $channel_3_count = 1
146 --source include/assert.inc
147
148 --echo #
149 --echo # 6. Verify other replication info was cleaned
150
151 --let $channel_1_count = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE channel_name="channel_1" AND Relay_log_pos = 4`
152 --let $assert_text= channel 1 was properly cleaned
153 --let $assert_cond= $channel_1_count = 1
154 --source include/assert.inc
155
156 --let $channel_3_count = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE channel_name="channel_3" AND Relay_log_pos = 4`
157 --let $assert_text= channel 3 was properly cleaned
158 --let $assert_cond= $channel_3_count = 1
159 --source include/assert.inc
160
161 --let $channel_mts_info = `SELECT COUNT(*) FROM mysql.slave_worker_info WHERE Relay_log_pos <> 0`
162 --let $assert_text= If present, info on MTS workers is clean
163 --let $assert_cond= $channel_mts_info = 0
164 --source include/assert.inc
165
166 --echo #
167 --echo # 7. Verify channels work when started
168
169 --let $rpl_channel_name=
170 --source include/start_slave.inc
171
172 --let $rpl_connection_name= server_1
173 --source include/rpl_connection.inc
174
175 INSERT INTO t1 VALUES (1);
176
177 --let $sync_slave_connection= server_4
178 --let $rpl_channel_name= 'channel_1'
179 --source include/sync_slave_sql_with_master.inc
180
181 --let $rpl_connection_name= server_3
182 --source include/rpl_connection.inc
183
184 INSERT INTO t3 VALUES (1);
185
186 --let $sync_slave_connection= server_4
187 --let $rpl_channel_name= 'channel_3'
188 --source include/sync_slave_sql_with_master.inc
189
190 --let $rpl_connection_name= server_4
191 --source include/rpl_connection.inc
192
193 --let $server_1_data = `SELECT COUNT(*) FROM test.t1`
194 --let $assert_text= All info from server 1 is present
195 --let $assert_cond= $server_1_data = 1
196 --source include/assert.inc
197
198 --let $server_3_data = `SELECT COUNT(*) FROM test.t3`
199 --let $assert_text= All info from server 3 is present
200 --let $assert_cond= $server_3_data = 1
201 --source include/assert.inc
202
203 --echo #
204 --echo # 8. Cleanup
205
206 --let $rpl_connection_name= server_1
207 --source include/rpl_connection.inc
208
209 DROP TABLE t1;
210
211 --let $sync_slave_connection= server_4
212 --let $rpl_channel_name= 'channel_1'
213 --source include/sync_slave_sql_with_master.inc
214
215 --let $rpl_connection_name= server_1
216 --source include/rpl_connection.inc
217
218 --let $sync_slave_connection= server_2
219 --let $rpl_channel_name= 'channel_1'
220 --source include/sync_slave_sql_with_master.inc
221
222
223 --let $rpl_connection_name= server_3
224 --source include/rpl_connection.inc
225
226 DROP TABLE t3;
227
228 --let $sync_slave_connection= server_4
229 --let $rpl_channel_name= 'channel_3'
230 --source include/sync_slave_sql_with_master.inc
231
232 --let $rpl_connection_name= server_3
233 --source include/rpl_connection.inc
234
235 --let $sync_slave_connection= server_2
236 --let $rpl_channel_name= 'channel_3'
237 --source include/sync_slave_sql_with_master.inc
238
239 --let $rpl_connection_name= server_2
240 --source include/rpl_connection.inc
241
242 DROP USER 'u1'@'localhost';
243
244 UNINSTALL PLUGIN clone;
245
246 --let $rpl_connection_name= server_4
247 --source include/rpl_connection.inc
248
249 UNINSTALL PLUGIN clone;
250
251 --source include/clean_monitoring_process.inc
252
253 # mysqld_safe restarts but does not start slave channels
254 --disable_warnings
255 --let $rpl_channel_name=
256 --source include/stop_slave.inc
257 --enable_warnings
258
259 RESET SLAVE ALL;
260
261 DROP USER 'u1'@'localhost';
262
263 set session sql_log_bin=0;
264 call mtr.add_suppression("Clone removing all user data for provisioning: Started");
265 call mtr.add_suppression("Clone removing all user data for provisioning: Finished");
266 call mtr.add_suppression("Recovery from source pos [0-9]+ and file [a-zA-Z-]+\.[0-9]+ for channel 'channel_1'*");
267 call mtr.add_suppression("Recovery from source pos [0-9]+ and file [a-zA-Z-]+\.[0-9]+ for channel 'channel_3'*");
268 call mtr.add_suppression("Applier metadata information for channel 'channel_1' was found after a clone operation. Relay log recovery*");
269 call mtr.add_suppression("Applier metadata information for channel 'channel_3' was found after a clone operation. Relay log recovery*");
270 call mtr.add_suppression("Relay log recovery on channel with GTID_ONLY=1*");
271 set session sql_log_bin=1;
272
273 --let $rpl_skip_sync= 1
274 --source include/rpl_end.inc