summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/rpl/t/rpl_mysqlbinlog_slave_consistency.test
blob: d2918e3a890f15455d954fbab71c29d8d18fc3e5 (plain)
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#
# Purpose:
#
# This test ensures the mariadb-binlog command line tool filters events
# by domain id (via --do-domain-ids and --ignore-domain-ids) and server id (via
# --ignore-server-ids) in the same way that a replica server does.
#
#
# Methodology:
#
# This test validates that the domain and server id filtering logic of
# mariadb-binlog matches that of a replica server. In particular, it validates
# a mariadb-binlog replay of a master's binary log is consistent with a
# replica's state which is configured using the same filtering configuration.
#
# It uses a repeatable process to allow for multiple test cases that span
# different filtering configurations. First, a master is seeded with an initial
# set of SQL statements with varying domain and server ids. Then, a set of
# filtering parameters supported by both mariadb-binlog and replica
# capabilities are defined. The replica is configured using these parameters
# and run it until it has processed all events from the primary server; it is
# stopped afterward. For mariadb-binlog validation, the binary log of the
# primary server is copied to a different location for later replay. The
# primary is then reset to its initial state (i.e. the tables are dropped and
# the logs are reset). The mariadb-binlog tool is then used to replay the
# copied binary log file back onto the clean primary server under the same
# filtering conditions as the replica. At this point, the data on the primary
# and replica should be exactly the same because the filtering conditions were
# the same, and all existing tables on both servers are compared using.
# checksums.
#
#
# References:
#
#   MDEV-20119: Implement the --do-domain-ids, --ignore-domain-ids, and
#               --ignore-server-ids options for mysqlbinlog
#
--source include/master-slave.inc

--connection slave
SET sql_log_bin=0;
call mtr.add_suppression("Slave: An attempt was made.*");
call mtr.add_suppression("Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists can't be non-empty at the same time");
SET sql_log_bin=1;

--source include/stop_slave.inc

--connection master
RESET MASTER;

# Save old state
let $ORIG_GTID_DOMAIN_ID = `select @@session.gtid_domain_id`;
let $ORIG_SERVER_ID = `select @@session.server_id`;

--connection slave
--source include/start_slave.inc

# Initial tests do not use strict mode
--let $strict_mode=0
--let $slave_sql_errno=0

--echo #
--echo #
--echo #  Test Case 1: Base case to ensure that mariadb-binlog and replica
--echo #  are consistent without any filtering
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 2: Ensure filtering by a single id in --do-domain-ids is
--echo #  consistent between mariadb-binlog and replica
--echo #
--let $do_domain_ids=0
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 3: Ensure filtering by multiple ids in --do-domain-ids is
--echo #  consistent between mariadb-binlog and replica
--echo #
--let $do_domain_ids=0,1
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #  Test Case 4: Ensure filtering by a single id in --ignore-domain-ids
--echo #  is consistent between mariadb-binlog and replica
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=0
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 5: Ensure filtering by multiple ids in --ignore-domain-ids
--echo #  is consistent between mariadb-binlog and replica
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=0,1
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #  Test Case 6: Ensure filtering by a single id in --ignore-server-ids
--echo #  is consistent between mariadb-binlog and replica
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=1
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 7: Ensure filtering by multiple ids in --ignore-server-ids
--echo #  is consistent between mariadb-binlog and replica
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=0,1
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 8: Ensure stop position consistency
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=1-1-2
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 9: Ensure start position consistency
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=1-4-2
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 10: Ensure consistency when filtering by both
--echo #  --do-domain-ids and --ignore-server-ids
--echo #
--let $do_domain_ids=0
--let $ignore_domain_ids=
--let $ignore_server_ids=1
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 11: Ensure consistency when filtering by both
--echo #  --ignore-domain-ids and --ignore-server-ids
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=1,2
--let $ignore_server_ids=1
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 12: Ensure consistency when filtering by
--echo #  --do-domain-ids with a stop position
--echo #
--let $do_domain_ids=0
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=0-1-4
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 13: Ensure consistency when filtering by
--echo #  --ignore-domain-ids with a stop position
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=0
--let $ignore_server_ids=
--let $stop_position=0-1-4
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 14: Ensure consistency when filtering by
--echo #  --ignore-server-ids with a stop position
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=3
--let $stop_position=0-1-4
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 15: Ensure consistency when filtering by
--echo #  --do-domain-ids with a start position
--echo #
--let $do_domain_ids=2
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=1-1-2
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 16: Ensure consistency when filtering by
--echo #  --ignore-domain-ids with a start position
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=0
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=0-1-1
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 17: Ensure consistency when filtering by
--echo #  --ignore-server-ids with a start position
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=1
--let $stop_position=
--let $start_position=0-1-1
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 18: Ensure consistency when filtering by
--echo #  --do-domain-ids with both a start position and stop position that
--echo # all have the same domain id
--echo #
--let $do_domain_ids=0
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=0-3-3
--let $start_position=0-1-1
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 19: Ensure consistency when filtering by
--echo #  --do-domain-ids with both a start position and stop position that
--echo #  have differing domain ids. Due to the implicit filtering in stop
--echo #  position, the result should be empty (no tables replicated).
--echo #
--let $do_domain_ids=1
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=0-3-3
--let $start_position=0-1-1
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 20: Ensure consistency when filtering by
--echo #  --ignore-domain-ids with both a start position and stop position that
--echo #  all have the same domain id. The result set should be empty due to
--echo #  implicit filtering from stop position and ignoring that same domain.
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=0
--let $ignore_server_ids=
--let $stop_position=0-3-3
--let $start_position=0-1-1
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 21: Ensure consistency when filtering by
--echo #  --ignore-domain-ids with both a start position and stop position that
--echo #  have differing domain ids. The ignore domain ids should take no
--echo #  effect due to the implicit filtering by stop position, i.e. the
--echo #  specified domain to ignore is already being filtered.
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=1
--let $ignore_server_ids=
--let $stop_position=0-3-3
--let $start_position=0-1-1
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 22: Ensure consistency when filtering by
--echo #  --ignore-server-ids with both a start position and stop position.
--echo #
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=3
--let $stop_position=0-3-3
--let $start_position=0-1-0
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 23: Out of order GTIDs from domains or servers which are
--echo #  filtered out should not error
--echo #
--let $strict_mode=1
--let $strict_mode_err=0
--let $slave_sql_errno=0
--let $do_domain_ids=0
--let $ignore_domain_ids=
--let $ignore_server_ids=3
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 24: Out of order GTIDs from included domains should error
--echo #
--let $strict_mode=1
--let $strict_mode_err=1
--let $slave_sql_errno=1950
--let $do_domain_ids=1
--let $ignore_domain_ids=
--let $ignore_server_ids=
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 25: Out of order GTIDs from included servers should error
--echo #
--let $strict_mode=1
--let $strict_mode_err=1
--let $slave_sql_errno=1950
--let $do_domain_ids=
--let $ignore_domain_ids=
--let $ignore_server_ids=1
--let $stop_position=
--let $start_position=
--source include/mysqlbinlog_slave_consistency.inc

--echo #
--echo #
--echo #  Test Case 26: Neither mysqlbinlog nor CHANGE MASTER TO should allow
--echo #  both do domain ids and ignore domain ids to be set together
--echo #
--connection slave
--source include/stop_slave.inc

--error 1201
CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(0), IGNORE_DOMAIN_IDS=(1);

--let $MYSQLD_DATADIR=`select @@datadir`
--let BINLOG_FILENAME= query_get_value(SHOW BINARY LOGS, Log_name, 1)
--let BINLOG_FILE_PARAM= $MYSQLD_DATADIR/$BINLOG_FILENAME.orig
--error 1
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILENAME --do-domain-ids=0 --ignore-domain-ids=1

RESET MASTER;
set global gtid_slave_pos="";
CHANGE MASTER TO MASTER_USE_GTID=slave_pos, DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=();
--source include/start_slave.inc

# Cleanup
--connection master
RESET MASTER;

--source include/rpl_end.inc

--echo # End of tests (rpl.rpl_mysqlbinlog_slave_consistency)