Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_checksum.test

raw
1 # WL2540 replication events checksum
2 # Testing configuration parameters
3
4 --source include/not_group_replication_plugin.inc
5 --source include/have_debug.inc
6 --source include/have_binlog_format_mixed.inc
7 --source include/master-slave.inc
8
9 call mtr.add_suppression('Replica can not handle replication events with the checksum that source is configured to log');
10 call mtr.add_suppression('Replication event checksum verification failed');
11 # due to C failure simulation
12 call mtr.add_suppression('Relay log write failure: could not queue event from source');
13 call mtr.add_suppression('Event crc check failed! Most likely there is event corruption');
14 call mtr.add_suppression("Replica SQL for channel '': Error initializing relay log position: I/O error reading event at position .*, Error_code: MY-013117");
15 call mtr.add_suppression('Source is configured to log replication events with checksum, but will not send such events to replicas that cannot process');
16 # A. read/write access to the global vars:
17 # binlog_checksum source_verify_checksum replica_sql_verify_checksum
18
19 connection master;
20
21 set @master_save_binlog_checksum= @@global.binlog_checksum;
22 set @save_source_verify_checksum = @@global.source_verify_checksum;
23
24 select @@global.binlog_checksum as 'must be CRC32 because of the command line option';
25 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
26 select @@session.binlog_checksum as 'no session var';
27
28 select @@global.source_verify_checksum as 'must be zero because of default';
29 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
30 select @@session.source_verify_checksum as 'no session var';
31
32 connection slave;
33
34 set @slave_save_binlog_checksum= @@global.binlog_checksum;
35 set @save_replica_sql_verify_checksum = @@global.replica_sql_verify_checksum;
36
37 select @@global.replica_sql_verify_checksum as 'must be one because of default';
38 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
39 select @@session.replica_sql_verify_checksum as 'no session var';
40
41 connection master;
42
43 source include/show_binary_logs.inc;
44 set @@global.binlog_checksum = NONE;
45 --echo *** must be rotations seen ***
46 source include/show_binary_logs.inc;
47
48 set @@global.binlog_checksum = default;
49
50 # testing lack of side-effects in non-effective update of binlog_checksum:
51 set @@global.binlog_checksum = CRC32;
52 set @@global.binlog_checksum = CRC32;
53
54 set @@global.source_verify_checksum = 0;
55 set @@global.source_verify_checksum = default;
56
57 --error ER_WRONG_VALUE_FOR_VAR
58 set @@global.binlog_checksum = ADLER32;
59 --error ER_WRONG_VALUE_FOR_VAR
60 set @@global.source_verify_checksum = 2; # the var is of bool type
61
62 connection slave;
63
64 set @@global.replica_sql_verify_checksum = 0;
65 set @@global.replica_sql_verify_checksum = default;
66 --error ER_WRONG_VALUE_FOR_VAR
67 set @@global.replica_sql_verify_checksum = 2; # the var is of bool type
68
69 #
70 # B. Old Slave to New master conditions
71 #
72 # while master does not send a checksum-ed binlog the Old Slave can
73 # work with the New Master
74
75 connection master;
76
77 set @@global.binlog_checksum = NONE;
78 create table t1 (a int);
79
80 # testing that binlog rotation preserves opt_binlog_checksum value
81 flush logs;
82 flush logs;
83 flush logs;
84
85 sync_slave_with_master;
86 #connection slave;
87 # checking that rotation on the slave side leaves slave stable
88 flush logs;
89 flush logs;
90 flush logs;
91 select count(*) as zero from t1;
92
93 source include/stop_slave.inc;
94
95 connection master;
96 set @@global.binlog_checksum = CRC32;
97 insert into t1 values (1) /* will not be applied on slave due to simulation */;
98
99 # instruction to the dump thread
100
101 connection slave;
102 set @@global.debug='+d,simulate_replica_unaware_checksum';
103 start slave;
104 let $slave_io_errno= 13114; # ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG
105 --let $show_slave_io_error= 1
106 # Mask line numbers
107 --let $slave_io_error_replace= / at [0-9]*/ at XXX/
108 source include/wait_for_slave_io_error.inc;
109
110 select count(*) as zero from t1;
111
112 ###connection master;
113
114 # *always* make sure the slave threads are stopped
115 # or in waiting state before updating the global debug
116 # variable (see BUG#11765758 for details).
117 --source include/stop_slave.inc
118 set @@global.debug='-d,simulate_replica_unaware_checksum';
119
120
121 connection slave;
122 source include/start_slave.inc;
123
124 #
125 # C. checksum failure simulations
126 #
127
128 # C1. Failure by a client thread
129 connection master;
130 set @@global.source_verify_checksum = 1;
131 set @@session.debug='+d,simulate_checksum_test_failure';
132 --error ER_ERROR_WHEN_EXECUTING_COMMAND
133 show binlog events;
134 set @@session.debug='-d,simulate_checksum_test_failure';
135 set @@global.source_verify_checksum = default;
136
137 #connection master;
138 sync_slave_with_master;
139
140 connection slave;
141 source include/stop_slave.inc;
142
143 connection master;
144 create table t2 (a int);
145 let $pos_master= query_get_value(SHOW MASTER STATUS, Position, 1);
146
147 connection slave;
148
149 # C2. Failure by IO thread
150 # instruction to io threadwait_for_slave_param.inc
151 set @@global.debug='+d,simulate_checksum_test_failure';
152 start slave io_thread;
153 # ER_REPLICA_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
154 let $slave_io_errno= 13122, 13115;
155 --let $show_slave_io_error= 0
156 source include/wait_for_slave_io_error.inc;
157 # no need to stop the IO thread, it is already stopped
158 set @@global.debug='-d,simulate_checksum_test_failure';
159
160 # to make IO thread re-read it again w/o the failure
161 start slave io_thread;
162 --connection master
163 --source include/sync_slave_io_with_master.inc
164
165 # C3. Failure by SQL thread
166 # instruction to sql thread;
167 set @@global.replica_sql_verify_checksum = 1;
168 set @@global.debug='+d,simulate_checksum_test_failure';
169 start slave sql_thread;
170 let $slave_sql_errno= 13117; # ER_REPLICA_FATAL_ERROR
171 --let $show_slave_sql_error= 1
172 source include/wait_for_slave_sql_error.inc;
173 --source include/stop_slave.inc
174 # resuming SQL thread to parse out the event w/o the failure
175 set @@global.debug='-d,simulate_checksum_test_failure';
176 source include/start_slave.inc;
177
178 connection master;
179 sync_slave_with_master;
180
181 #connection slave;
182 select count(*) as 'must be zero' from t2;
183
184 #
185 # D. Reset slave, Change-Master, Binlog & Relay-log rotations with
186 # random value on binlog_checksum on both master and slave
187 #
188 connection slave;
189 stop slave;
190 reset slave;
191 reset master;
192
193 # randomize slave server's own checksum policy
194 set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
195 flush logs;
196
197 connection master;
198 set @@global.binlog_checksum= CRC32;
199 reset master;
200 flush logs;
201 create table t3 (a int, b char(5));
202
203 connection slave;
204 source include/start_slave.inc;
205
206 connection master;
207 sync_slave_with_master;
208
209 #connection slave;
210 select count(*) as 'must be zero' from t3;
211 source include/stop_slave.inc;
212 --replace_result $MASTER_MYPORT MASTER_PORT
213 --replace_column 2 ####
214 eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root';
215
216 connection master;
217 flush logs;
218 reset master;
219 insert into t3 value (1, @@global.binlog_checksum);
220
221 connection slave;
222 source include/start_slave.inc;
223 flush logs;
224
225 connection master;
226 sync_slave_with_master;
227
228 #connection slave;
229 select count(*) as 'must be one' from t3;
230
231 connection master;
232 set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
233 insert into t3 value (1, @@global.binlog_checksum);
234 sync_slave_with_master;
235
236 #connection slave;
237
238 #clean-up
239
240 connection master;
241 drop table t1, t2, t3;
242 set @@global.binlog_checksum = @master_save_binlog_checksum;
243 set @@global.source_verify_checksum = @save_source_verify_checksum;
244
245 #
246 # BUG#58564: flush_read_lock fails in mysql-trunk-bugfixing after merging with WL#2540
247 #
248 # Sanity check that verifies that no assertions are triggered because
249 # of old FD events (generated by versions prior to server released with
250 # checksums feature)
251 #
252 # There is no need for query log, if something wrong this should trigger
253 # an assertion
254
255 --disable_query_log
256
257 BINLOG '
258 MfmqTA8BAAAAZwAAAGsAAAABAAQANS41LjctbTMtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
259 AAAAAAAAAAAAAAAAAAAx+apMEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
260 ';
261
262 --enable_query_log
263
264 #connection slave;
265 sync_slave_with_master;
266 set @@global.binlog_checksum = @slave_save_binlog_checksum;
267 set @@global.replica_sql_verify_checksum = @save_replica_sql_verify_checksum;
268
269 --source include/rpl_end.inc