Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_checksum.test

raw
1 # WL2540 replication events checksum
2 # Testing configuration parameters
3
4 --source include/have_ndb.inc
5 --source include/have_debug.inc
6 --source include/have_binlog_format_mixed_or_row.inc
7 --source suite/ndb_rpl/ndb_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
17 # A. read/write access to the global vars:
18 # binlog_checksum source_verify_checksum replica_sql_verify_checksum
19
20 connection master;
21
22 set @master_save_binlog_checksum= @@global.binlog_checksum;
23 set @save_source_verify_checksum = @@global.source_verify_checksum;
24
25 select @@global.binlog_checksum as 'must be CRC32 because of the command line option';
26 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
27 select @@session.binlog_checksum as 'no session var';
28
29 select @@global.source_verify_checksum as 'must be zero because of default';
30 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
31 select @@session.source_verify_checksum as 'no session var';
32
33 connection slave;
34
35 set @slave_save_binlog_checksum= @@global.binlog_checksum;
36 set @save_replica_sql_verify_checksum = @@global.replica_sql_verify_checksum;
37
38 select @@global.replica_sql_verify_checksum as 'must be one because of default';
39 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
40 select @@session.replica_sql_verify_checksum as 'no session var';
41
42 connection master;
43
44 source include/show_binary_logs.inc;
45 set @@global.binlog_checksum = NONE;
46 --echo *** must be rotations seen ***
47 source include/show_binary_logs.inc;
48
49 set @@global.binlog_checksum = default;
50
51 # testing lack of side-effects in non-effective update of binlog_checksum:
52 set @@global.binlog_checksum = CRC32;
53 set @@global.binlog_checksum = CRC32;
54
55 set @@global.source_verify_checksum = 0;
56 set @@global.source_verify_checksum = default;
57
58 --error ER_WRONG_VALUE_FOR_VAR
59 set @@global.binlog_checksum = ADLER32;
60 --error ER_WRONG_VALUE_FOR_VAR
61 set @@global.source_verify_checksum = 2; # the var is of bool type
62
63 connection slave;
64
65 set @@global.replica_sql_verify_checksum = 0;
66 set @@global.replica_sql_verify_checksum = default;
67 --error ER_WRONG_VALUE_FOR_VAR
68 set @@global.replica_sql_verify_checksum = 2; # the var is of bool type
69
70 #
71 # B. Old Slave to New master conditions
72 #
73 # while master does not send a checksum-ed binlog the Old Slave can
74 # work with the New Master
75
76 connection master;
77
78 set @@global.binlog_checksum = NONE;
79 create table t1 (a int) engine=ndb;
80
81 # testing that binlog rotation preserves opt_binlog_checksum value
82 flush logs;
83 flush logs;
84 flush logs;
85
86 sync_slave_with_master;
87 #connection slave;
88 # checking that rotation on the slave side leaves slave stable
89 flush logs;
90 flush logs;
91 flush logs;
92 select count(*) as zero from t1;
93
94 source include/stop_slave.inc;
95
96 connection master;
97 set @@global.binlog_checksum = CRC32;
98 insert into t1 values (1) /* will not be applied on slave due to simulation */;
99
100 # instruction to the dump thread
101
102 connection slave;
103 set @@global.debug='d,simulate_replica_unaware_checksum';
104 start slave;
105 let $slave_io_errno= 13114; # ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG
106 --let $show_slave_io_error= 1
107 # Mask line numbers
108 --let $slave_io_error_replace= / at [0-9]*/ at XXX/
109 source include/wait_for_slave_io_error.inc;
110
111 select count(*) as zero from t1;
112
113 ###connection master;
114
115 # *always* make sure the slave threads are stopped
116 # or in waiting state before updating the global debug
117 # variable (see BUG#11765758 for details).
118 --source include/stop_slave.inc
119 set @@global.debug='';
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='';
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) engine=ndb;
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 thread
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='';
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='';
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)) engine=ndb;
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