Debian Codegraph @

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

raw
1 #
2 # Purpose:
3 #
4 # This test ensures the mariadb-binlog command line tool filters events
5 # by domain id (via --do-domain-ids and --ignore-domain-ids) and server id (via
6 # --ignore-server-ids) in the same way that a replica server does.
7 #
8 #
9 # Methodology:
10 #
11 # This test validates that the domain and server id filtering logic of
12 # mariadb-binlog matches that of a replica server. In particular, it validates
13 # a mariadb-binlog replay of a master's binary log is consistent with a
14 # replica's state which is configured using the same filtering configuration.
15 #
16 # It uses a repeatable process to allow for multiple test cases that span
17 # different filtering configurations. First, a master is seeded with an initial
18 # set of SQL statements with varying domain and server ids. Then, a set of
19 # filtering parameters supported by both mariadb-binlog and replica
20 # capabilities are defined. The replica is configured using these parameters
21 # and run it until it has processed all events from the primary server; it is
22 # stopped afterward. For mariadb-binlog validation, the binary log of the
23 # primary server is copied to a different location for later replay. The
24 # primary is then reset to its initial state (i.e. the tables are dropped and
25 # the logs are reset). The mariadb-binlog tool is then used to replay the
26 # copied binary log file back onto the clean primary server under the same
27 # filtering conditions as the replica. At this point, the data on the primary
28 # and replica should be exactly the same because the filtering conditions were
29 # the same, and all existing tables on both servers are compared using.
30 # checksums.
31 #
32 #
33 # References:
34 #
35 # MDEV-20119: Implement the --do-domain-ids, --ignore-domain-ids, and
36 # --ignore-server-ids options for mysqlbinlog
37 #
38 --source include/master-slave.inc
39
40 --connection slave
41 SET sql_log_bin=0;
42 call mtr.add_suppression("Slave: An attempt was made.*");
43 call mtr.add_suppression("Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists can't be non-empty at the same time");
44 SET sql_log_bin=1;
45
46 --source include/stop_slave.inc
47
48 --connection master
49 RESET MASTER;
50
51 # Save old state
52 let $ORIG_GTID_DOMAIN_ID = `select @@session.gtid_domain_id`;
53 let $ORIG_SERVER_ID = `select @@session.server_id`;
54
55 --connection slave
56 --source include/start_slave.inc
57
58 # Initial tests do not use strict mode
59 --let $strict_mode=0
60 --let $slave_sql_errno=0
61
62 --echo #
63 --echo #
64 --echo # Test Case 1: Base case to ensure that mariadb-binlog and replica
65 --echo # are consistent without any filtering
66 --echo #
67 --let $do_domain_ids=
68 --let $ignore_domain_ids=
69 --let $ignore_server_ids=
70 --let $stop_position=
71 --let $start_position=
72 --source include/mysqlbinlog_slave_consistency.inc
73
74 --echo #
75 --echo #
76 --echo # Test Case 2: Ensure filtering by a single id in --do-domain-ids is
77 --echo # consistent between mariadb-binlog and replica
78 --echo #
79 --let $do_domain_ids=0
80 --let $ignore_domain_ids=
81 --let $ignore_server_ids=
82 --let $stop_position=
83 --let $start_position=
84 --source include/mysqlbinlog_slave_consistency.inc
85
86 --echo #
87 --echo #
88 --echo # Test Case 3: Ensure filtering by multiple ids in --do-domain-ids is
89 --echo # consistent between mariadb-binlog and replica
90 --echo #
91 --let $do_domain_ids=0,1
92 --let $ignore_domain_ids=
93 --let $ignore_server_ids=
94 --let $stop_position=
95 --let $start_position=
96 --source include/mysqlbinlog_slave_consistency.inc
97
98 --echo #
99 --echo # Test Case 4: Ensure filtering by a single id in --ignore-domain-ids
100 --echo # is consistent between mariadb-binlog and replica
101 --echo #
102 --let $do_domain_ids=
103 --let $ignore_domain_ids=0
104 --let $ignore_server_ids=
105 --let $stop_position=
106 --let $start_position=
107 --source include/mysqlbinlog_slave_consistency.inc
108
109 --echo #
110 --echo #
111 --echo # Test Case 5: Ensure filtering by multiple ids in --ignore-domain-ids
112 --echo # is consistent between mariadb-binlog and replica
113 --echo #
114 --let $do_domain_ids=
115 --let $ignore_domain_ids=0,1
116 --let $ignore_server_ids=
117 --let $stop_position=
118 --let $start_position=
119 --source include/mysqlbinlog_slave_consistency.inc
120
121 --echo #
122 --echo # Test Case 6: Ensure filtering by a single id in --ignore-server-ids
123 --echo # is consistent between mariadb-binlog and replica
124 --echo #
125 --let $do_domain_ids=
126 --let $ignore_domain_ids=
127 --let $ignore_server_ids=1
128 --let $stop_position=
129 --let $start_position=
130 --source include/mysqlbinlog_slave_consistency.inc
131
132 --echo #
133 --echo #
134 --echo # Test Case 7: Ensure filtering by multiple ids in --ignore-server-ids
135 --echo # is consistent between mariadb-binlog and replica
136 --echo #
137 --let $do_domain_ids=
138 --let $ignore_domain_ids=
139 --let $ignore_server_ids=0,1
140 --let $stop_position=
141 --let $start_position=
142 --source include/mysqlbinlog_slave_consistency.inc
143
144 --echo #
145 --echo #
146 --echo # Test Case 8: Ensure stop position consistency
147 --echo #
148 --let $do_domain_ids=
149 --let $ignore_domain_ids=
150 --let $ignore_server_ids=
151 --let $stop_position=1-1-2
152 --let $start_position=
153 --source include/mysqlbinlog_slave_consistency.inc
154
155 --echo #
156 --echo #
157 --echo # Test Case 9: Ensure start position consistency
158 --echo #
159 --let $do_domain_ids=
160 --let $ignore_domain_ids=
161 --let $ignore_server_ids=
162 --let $stop_position=
163 --let $start_position=1-4-2
164 --source include/mysqlbinlog_slave_consistency.inc
165
166 --echo #
167 --echo #
168 --echo # Test Case 10: Ensure consistency when filtering by both
169 --echo # --do-domain-ids and --ignore-server-ids
170 --echo #
171 --let $do_domain_ids=0
172 --let $ignore_domain_ids=
173 --let $ignore_server_ids=1
174 --let $stop_position=
175 --let $start_position=
176 --source include/mysqlbinlog_slave_consistency.inc
177
178 --echo #
179 --echo #
180 --echo # Test Case 11: Ensure consistency when filtering by both
181 --echo # --ignore-domain-ids and --ignore-server-ids
182 --echo #
183 --let $do_domain_ids=
184 --let $ignore_domain_ids=1,2
185 --let $ignore_server_ids=1
186 --let $stop_position=
187 --let $start_position=
188 --source include/mysqlbinlog_slave_consistency.inc
189
190 --echo #
191 --echo #
192 --echo # Test Case 12: Ensure consistency when filtering by
193 --echo # --do-domain-ids with a stop position
194 --echo #
195 --let $do_domain_ids=0
196 --let $ignore_domain_ids=
197 --let $ignore_server_ids=
198 --let $stop_position=0-1-4
199 --let $start_position=
200 --source include/mysqlbinlog_slave_consistency.inc
201
202 --echo #
203 --echo #
204 --echo # Test Case 13: Ensure consistency when filtering by
205 --echo # --ignore-domain-ids with a stop position
206 --echo #
207 --let $do_domain_ids=
208 --let $ignore_domain_ids=0
209 --let $ignore_server_ids=
210 --let $stop_position=0-1-4
211 --let $start_position=
212 --source include/mysqlbinlog_slave_consistency.inc
213
214 --echo #
215 --echo #
216 --echo # Test Case 14: Ensure consistency when filtering by
217 --echo # --ignore-server-ids with a stop position
218 --echo #
219 --let $do_domain_ids=
220 --let $ignore_domain_ids=
221 --let $ignore_server_ids=3
222 --let $stop_position=0-1-4
223 --let $start_position=
224 --source include/mysqlbinlog_slave_consistency.inc
225
226 --echo #
227 --echo #
228 --echo # Test Case 15: Ensure consistency when filtering by
229 --echo # --do-domain-ids with a start position
230 --echo #
231 --let $do_domain_ids=2
232 --let $ignore_domain_ids=
233 --let $ignore_server_ids=
234 --let $stop_position=
235 --let $start_position=1-1-2
236 --source include/mysqlbinlog_slave_consistency.inc
237
238 --echo #
239 --echo #
240 --echo # Test Case 16: Ensure consistency when filtering by
241 --echo # --ignore-domain-ids with a start position
242 --echo #
243 --let $do_domain_ids=
244 --let $ignore_domain_ids=0
245 --let $ignore_server_ids=
246 --let $stop_position=
247 --let $start_position=0-1-1
248 --source include/mysqlbinlog_slave_consistency.inc
249
250 --echo #
251 --echo #
252 --echo # Test Case 17: Ensure consistency when filtering by
253 --echo # --ignore-server-ids with a start position
254 --echo #
255 --let $do_domain_ids=
256 --let $ignore_domain_ids=
257 --let $ignore_server_ids=1
258 --let $stop_position=
259 --let $start_position=0-1-1
260 --source include/mysqlbinlog_slave_consistency.inc
261
262 --echo #
263 --echo #
264 --echo # Test Case 18: Ensure consistency when filtering by
265 --echo # --do-domain-ids with both a start position and stop position that
266 --echo # all have the same domain id
267 --echo #
268 --let $do_domain_ids=0
269 --let $ignore_domain_ids=
270 --let $ignore_server_ids=
271 --let $stop_position=0-3-3
272 --let $start_position=0-1-1
273 --source include/mysqlbinlog_slave_consistency.inc
274
275 --echo #
276 --echo #
277 --echo # Test Case 19: Ensure consistency when filtering by
278 --echo # --do-domain-ids with both a start position and stop position that
279 --echo # have differing domain ids. Due to the implicit filtering in stop
280 --echo # position, the result should be empty (no tables replicated).
281 --echo #
282 --let $do_domain_ids=1
283 --let $ignore_domain_ids=
284 --let $ignore_server_ids=
285 --let $stop_position=0-3-3
286 --let $start_position=0-1-1
287 --source include/mysqlbinlog_slave_consistency.inc
288
289 --echo #
290 --echo #
291 --echo # Test Case 20: Ensure consistency when filtering by
292 --echo # --ignore-domain-ids with both a start position and stop position that
293 --echo # all have the same domain id. The result set should be empty due to
294 --echo # implicit filtering from stop position and ignoring that same domain.
295 --echo #
296 --let $do_domain_ids=
297 --let $ignore_domain_ids=0
298 --let $ignore_server_ids=
299 --let $stop_position=0-3-3
300 --let $start_position=0-1-1
301 --source include/mysqlbinlog_slave_consistency.inc
302
303 --echo #
304 --echo #
305 --echo # Test Case 21: Ensure consistency when filtering by
306 --echo # --ignore-domain-ids with both a start position and stop position that
307 --echo # have differing domain ids. The ignore domain ids should take no
308 --echo # effect due to the implicit filtering by stop position, i.e. the
309 --echo # specified domain to ignore is already being filtered.
310 --echo #
311 --let $do_domain_ids=
312 --let $ignore_domain_ids=1
313 --let $ignore_server_ids=
314 --let $stop_position=0-3-3
315 --let $start_position=0-1-1
316 --source include/mysqlbinlog_slave_consistency.inc
317
318 --echo #
319 --echo #
320 --echo # Test Case 22: Ensure consistency when filtering by
321 --echo # --ignore-server-ids with both a start position and stop position.
322 --echo #
323 --let $do_domain_ids=
324 --let $ignore_domain_ids=
325 --let $ignore_server_ids=3
326 --let $stop_position=0-3-3
327 --let $start_position=0-1-0
328 --source include/mysqlbinlog_slave_consistency.inc
329
330 --echo #
331 --echo #
332 --echo # Test Case 23: Out of order GTIDs from domains or servers which are
333 --echo # filtered out should not error
334 --echo #
335 --let $strict_mode=1
336 --let $strict_mode_err=0
337 --let $slave_sql_errno=0
338 --let $do_domain_ids=0
339 --let $ignore_domain_ids=
340 --let $ignore_server_ids=3
341 --let $stop_position=
342 --let $start_position=
343 --source include/mysqlbinlog_slave_consistency.inc
344
345 --echo #
346 --echo #
347 --echo # Test Case 24: Out of order GTIDs from included domains should error
348 --echo #
349 --let $strict_mode=1
350 --let $strict_mode_err=1
351 --let $slave_sql_errno=1950
352 --let $do_domain_ids=1
353 --let $ignore_domain_ids=
354 --let $ignore_server_ids=
355 --let $stop_position=
356 --let $start_position=
357 --source include/mysqlbinlog_slave_consistency.inc
358
359 --echo #
360 --echo #
361 --echo # Test Case 25: Out of order GTIDs from included servers should error
362 --echo #
363 --let $strict_mode=1
364 --let $strict_mode_err=1
365 --let $slave_sql_errno=1950
366 --let $do_domain_ids=
367 --let $ignore_domain_ids=
368 --let $ignore_server_ids=1
369 --let $stop_position=
370 --let $start_position=
371 --source include/mysqlbinlog_slave_consistency.inc
372
373 --echo #
374 --echo #
375 --echo # Test Case 26: Neither mysqlbinlog nor CHANGE MASTER TO should allow
376 --echo # both do domain ids and ignore domain ids to be set together
377 --echo #
378 --connection slave
379 --source include/stop_slave.inc
380
381 --error 1201
382 CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0), IGNORE_DOMAIN_IDS=(1);
383
384 --let $MYSQLD_DATADIR=`select @@datadir`
385 --let BINLOG_FILENAME= query_get_value(SHOW BINARY LOGS, Log_name, 1)
386 --let BINLOG_FILE_PARAM= $MYSQLD_DATADIR/$BINLOG_FILENAME.orig
387 --error 1
388 --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILENAME --do-domain-ids=0 --ignore-domain-ids=1
389
390 RESET MASTER;
391 set global gtid_slave_pos="";
392 CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
393 --source include/start_slave.inc
394
395 # Cleanup
396 --connection master
397 RESET MASTER;
398
399 --source include/rpl_end.inc
400
401 --echo # End of tests (rpl.rpl_mysqlbinlog_slave_consistency)