| 1 |
# |
| 2 |
# This include file is used by more than one test suite |
| 3 |
# (currently rpl and binlog_encryption). |
| 4 |
# Please check all dependent tests after modifying it |
| 5 |
# |
| 6 |
|
| 7 |
# WL2540 replication events checksum |
| 8 |
# Testing configuration parameters |
| 9 |
|
| 10 |
--source include/have_debug.inc |
| 11 |
--source include/have_binlog_format_mixed.inc |
| 12 |
--source include/master-slave.inc |
| 13 |
|
| 14 |
--connection slave |
| 15 |
--source include/stop_slave.inc |
| 16 |
CHANGE MASTER TO MASTER_USE_GTID=NO; |
| 17 |
--source include/start_slave.inc |
| 18 |
|
| 19 |
--connection master |
| 20 |
call mtr.add_suppression('Slave can not handle replication events with the checksum that master is configured to log'); |
| 21 |
call mtr.add_suppression('Replication event checksum verification failed'); |
| 22 |
# due to C failure simulation |
| 23 |
call mtr.add_suppression('Relay log write failure: could not queue event from master'); |
| 24 |
call mtr.add_suppression('Master is configured to log replication events with checksum, but will not send such events to slaves that cannot process them'); |
| 25 |
|
| 26 |
# A. read/write access to the global vars: |
| 27 |
# binlog_checksum master_verify_checksum slave_sql_verify_checksum |
| 28 |
|
| 29 |
connection master; |
| 30 |
|
| 31 |
set @master_save_binlog_checksum= @@global.binlog_checksum; |
| 32 |
set @save_master_verify_checksum = @@global.master_verify_checksum; |
| 33 |
|
| 34 |
select @@global.binlog_checksum as 'must be CRC32 because of the command line option'; |
| 35 |
--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 36 |
select @@session.binlog_checksum as 'no session var'; |
| 37 |
|
| 38 |
select @@global.master_verify_checksum as 'must be zero because of default'; |
| 39 |
--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 40 |
select @@session.master_verify_checksum as 'no session var'; |
| 41 |
|
| 42 |
connection slave; |
| 43 |
|
| 44 |
set @slave_save_binlog_checksum= @@global.binlog_checksum; |
| 45 |
set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum; |
| 46 |
|
| 47 |
select @@global.slave_sql_verify_checksum as 'must be one because of default'; |
| 48 |
--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 49 |
select @@session.slave_sql_verify_checksum as 'no session var'; |
| 50 |
|
| 51 |
connection master; |
| 52 |
|
| 53 |
source include/show_binary_logs.inc; |
| 54 |
set @@global.binlog_checksum = NONE; |
| 55 |
select @@global.binlog_checksum; |
| 56 |
--echo *** must be rotations seen *** |
| 57 |
source include/show_binary_logs.inc; |
| 58 |
|
| 59 |
set @@global.binlog_checksum = default; |
| 60 |
select @@global.binlog_checksum; |
| 61 |
|
| 62 |
# testing lack of side-effects in non-effective update of binlog_checksum: |
| 63 |
set @@global.binlog_checksum = CRC32; |
| 64 |
select @@global.binlog_checksum; |
| 65 |
set @@global.binlog_checksum = CRC32; |
| 66 |
|
| 67 |
set @@global.master_verify_checksum = 0; |
| 68 |
set @@global.master_verify_checksum = default; |
| 69 |
|
| 70 |
--error ER_WRONG_VALUE_FOR_VAR |
| 71 |
set @@global.binlog_checksum = ADLER32; |
| 72 |
--error ER_WRONG_VALUE_FOR_VAR |
| 73 |
set @@global.master_verify_checksum = 2; # the var is of bool type |
| 74 |
|
| 75 |
connection slave; |
| 76 |
|
| 77 |
set @@global.slave_sql_verify_checksum = 0; |
| 78 |
set @@global.slave_sql_verify_checksum = default; |
| 79 |
--error ER_WRONG_VALUE_FOR_VAR |
| 80 |
set @@global.slave_sql_verify_checksum = 2; # the var is of bool type |
| 81 |
|
| 82 |
# |
| 83 |
# B. Old Slave to New master conditions |
| 84 |
# |
| 85 |
# while master does not send a checksum-ed binlog the Old Slave can |
| 86 |
# work with the New Master |
| 87 |
|
| 88 |
connection master; |
| 89 |
|
| 90 |
set @@global.binlog_checksum = NONE; |
| 91 |
create table t1 (a int); |
| 92 |
|
| 93 |
# testing that binlog rotation preserves opt_binlog_checksum value |
| 94 |
flush logs; |
| 95 |
flush logs; |
| 96 |
-- source include/wait_for_binlog_checkpoint.inc |
| 97 |
flush logs; |
| 98 |
# The binlog position here is output in the error message from |
| 99 |
# wait_for_slave_io_error below, so make sure it's deterministic. |
| 100 |
-- source include/wait_for_binlog_checkpoint.inc |
| 101 |
|
| 102 |
sync_slave_with_master; |
| 103 |
#connection slave; |
| 104 |
# checking that rotation on the slave side leaves slave stable |
| 105 |
flush logs; |
| 106 |
flush logs; |
| 107 |
flush logs; |
| 108 |
select count(*) as zero from t1; |
| 109 |
|
| 110 |
source include/stop_slave.inc; |
| 111 |
|
| 112 |
connection master; |
| 113 |
set @@global.binlog_checksum = CRC32; |
| 114 |
-- source include/wait_for_binlog_checkpoint.inc |
| 115 |
insert into t1 values (1) /* will not be applied on slave due to simulation */; |
| 116 |
|
| 117 |
# instruction to the dump thread |
| 118 |
|
| 119 |
connection slave; |
| 120 |
set @saved_dbug = @@global.debug_dbug; |
| 121 |
set @@global.debug_dbug='d,simulate_slave_unaware_checksum'; |
| 122 |
start slave; |
| 123 |
--let $slave_io_errno= 1236 |
| 124 |
--let $show_slave_io_error= 1 |
| 125 |
source include/wait_for_slave_io_error.inc; |
| 126 |
|
| 127 |
select count(*) as zero from t1; |
| 128 |
|
| 129 |
set @@global.debug_dbug = @saved_dbug; |
| 130 |
|
| 131 |
connection slave; |
| 132 |
source include/start_slave.inc; |
| 133 |
|
| 134 |
# |
| 135 |
# C. checksum failure simulations |
| 136 |
# |
| 137 |
|
| 138 |
# C1. Failure by a client thread |
| 139 |
connection master; |
| 140 |
set @@global.master_verify_checksum = 1; |
| 141 |
set @save_dbug = @@session.debug_dbug; |
| 142 |
set @@session.debug_dbug='d,simulate_checksum_test_failure'; |
| 143 |
--error ER_ERROR_WHEN_EXECUTING_COMMAND |
| 144 |
show binlog events; |
| 145 |
SET debug_dbug= @save_dbug; |
| 146 |
set @@global.master_verify_checksum = default; |
| 147 |
|
| 148 |
#connection master; |
| 149 |
sync_slave_with_master; |
| 150 |
|
| 151 |
connection slave; |
| 152 |
source include/stop_slave.inc; |
| 153 |
|
| 154 |
connection master; |
| 155 |
create table t2 (a int); |
| 156 |
let $pos_master= query_get_value(SHOW MASTER STATUS, Position, 1); |
| 157 |
|
| 158 |
connection slave; |
| 159 |
|
| 160 |
# C2. Failure by IO thread |
| 161 |
# instruction to io thread |
| 162 |
set @saved_dbug = @@global.debug_dbug; |
| 163 |
set @@global.debug_dbug='d,simulate_checksum_test_failure'; |
| 164 |
start slave io_thread; |
| 165 |
# When the checksum error is detected, the slave sets error code 1913 |
| 166 |
# (ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE) in queue_event(), then immediately |
| 167 |
# sets error 1595 (ER_SLAVE_RELAY_LOG_WRITE_FAILURE) in handle_slave_io(). |
| 168 |
# So we usually get 1595, but it is occasionally possible to get 1913. |
| 169 |
--let $slave_io_errno= 1595,1913 |
| 170 |
--let $show_slave_io_error= 0 |
| 171 |
source include/wait_for_slave_io_error.inc; |
| 172 |
set @@global.debug_dbug = @saved_dbug; |
| 173 |
|
| 174 |
# to make IO thread re-read it again w/o the failure |
| 175 |
start slave io_thread; |
| 176 |
let $slave_param= Read_Master_Log_Pos; |
| 177 |
let $slave_param_value= $pos_master; |
| 178 |
source include/wait_for_slave_param.inc; |
| 179 |
|
| 180 |
# C3. Failure by SQL thread |
| 181 |
# instruction to sql thread; |
| 182 |
set @@global.slave_sql_verify_checksum = 1; |
| 183 |
|
| 184 |
set @@global.debug_dbug='d,simulate_checksum_test_failure'; |
| 185 |
|
| 186 |
start slave sql_thread; |
| 187 |
--let $slave_sql_errno= 1593 |
| 188 |
--let $show_slave_sql_error= 1 |
| 189 |
source include/wait_for_slave_sql_error.inc; |
| 190 |
|
| 191 |
# resuming SQL thread to parse out the event w/o the failure |
| 192 |
|
| 193 |
set @@global.debug_dbug = @saved_dbug; |
| 194 |
source include/start_slave.inc; |
| 195 |
|
| 196 |
connection master; |
| 197 |
sync_slave_with_master; |
| 198 |
|
| 199 |
#connection slave; |
| 200 |
select count(*) as 'must be zero' from t2; |
| 201 |
|
| 202 |
# |
| 203 |
# D. Reset slave, Change-Master, Binlog & Relay-log rotations with |
| 204 |
# random value on binlog_checksum on both master and slave |
| 205 |
# |
| 206 |
connection slave; |
| 207 |
stop slave; |
| 208 |
--let $master_use_gtid_option= No |
| 209 |
--source include/reset_slave.inc |
| 210 |
|
| 211 |
# randomize slave server's own checksum policy |
| 212 |
set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE"); |
| 213 |
flush logs; |
| 214 |
|
| 215 |
connection master; |
| 216 |
set @@global.binlog_checksum= CRC32; |
| 217 |
reset master; |
| 218 |
flush logs; |
| 219 |
create table t3 (a int, b char(5)); |
| 220 |
|
| 221 |
connection slave; |
| 222 |
source include/start_slave.inc; |
| 223 |
|
| 224 |
connection master; |
| 225 |
sync_slave_with_master; |
| 226 |
|
| 227 |
#connection slave; |
| 228 |
select count(*) as 'must be zero' from t3; |
| 229 |
source include/stop_slave.inc; |
| 230 |
--replace_result $MASTER_MYPORT MASTER_PORT |
| 231 |
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root'; |
| 232 |
|
| 233 |
connection master; |
| 234 |
flush logs; |
| 235 |
reset master; |
| 236 |
insert into t3 value (1, @@global.binlog_checksum); |
| 237 |
|
| 238 |
connection slave; |
| 239 |
source include/start_slave.inc; |
| 240 |
flush logs; |
| 241 |
|
| 242 |
connection master; |
| 243 |
sync_slave_with_master; |
| 244 |
|
| 245 |
#connection slave; |
| 246 |
select count(*) as 'must be one' from t3; |
| 247 |
|
| 248 |
connection master; |
| 249 |
set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE"); |
| 250 |
insert into t3 value (1, @@global.binlog_checksum); |
| 251 |
sync_slave_with_master; |
| 252 |
|
| 253 |
#connection slave; |
| 254 |
|
| 255 |
#clean-up |
| 256 |
|
| 257 |
connection master; |
| 258 |
drop table t1, t2, t3; |
| 259 |
set @@global.binlog_checksum = @master_save_binlog_checksum; |
| 260 |
set @@global.master_verify_checksum = @save_master_verify_checksum; |
| 261 |
|
| 262 |
# |
| 263 |
# BUG#58564: flush_read_lock fails in mysql-trunk-bugfixing after merging with WL#2540 |
| 264 |
# |
| 265 |
# Sanity check that verifies that no assertions are triggered because |
| 266 |
# of old FD events (generated by versions prior to server released with |
| 267 |
# checksums feature) |
| 268 |
# |
| 269 |
# There is no need for query log, if something wrong this should trigger |
| 270 |
# an assertion |
| 271 |
|
| 272 |
--disable_query_log |
| 273 |
|
| 274 |
BINLOG ' |
| 275 |
MfmqTA8BAAAAZwAAAGsAAAABAAQANS41LjctbTMtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA |
| 276 |
AAAAAAAAAAAAAAAAAAAx+apMEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA== |
| 277 |
'; |
| 278 |
|
| 279 |
--enable_query_log |
| 280 |
|
| 281 |
#connection slave; |
| 282 |
sync_slave_with_master; |
| 283 |
|
| 284 |
|
| 285 |
--echo *** Bug#59123 / MDEV-5799: INCIDENT_EVENT checksum written to error log as garbage characters *** |
| 286 |
|
| 287 |
--connection master |
| 288 |
|
| 289 |
--source include/wait_for_binlog_checkpoint.inc |
| 290 |
CREATE TABLE t4 (a INT PRIMARY KEY); |
| 291 |
INSERT INTO t4 VALUES (1); |
| 292 |
|
| 293 |
SET sql_log_bin=0; |
| 294 |
CALL mtr.add_suppression("\\[ERROR\\] Can't generate a unique log-filename"); |
| 295 |
SET sql_log_bin=1; |
| 296 |
SET @old_dbug= @@GLOBAL.debug_dbug; |
| 297 |
SET debug_dbug= '+d,binlog_inject_new_name_error'; |
| 298 |
--error ER_NO_UNIQUE_LOGFILE |
| 299 |
FLUSH LOGS; |
| 300 |
SET debug_dbug= @old_dbug; |
| 301 |
|
| 302 |
INSERT INTO t4 VALUES (2); |
| 303 |
|
| 304 |
--connection slave |
| 305 |
--let $slave_sql_errno= 1590 |
| 306 |
--source include/wait_for_slave_sql_error.inc |
| 307 |
|
| 308 |
# Search the error log for the error message. |
| 309 |
# The bug was that 4 garbage bytes were output in the middle of the error |
| 310 |
# message; by searching for a pattern that spans that location, we can |
| 311 |
# catch the error. |
| 312 |
let $log_error_= `SELECT @@GLOBAL.log_error`; |
| 313 |
if(!$log_error_) |
| 314 |
{ |
| 315 |
# MySQL Server on windows is started with --console and thus |
| 316 |
# does not know the location of its .err log, use default location |
| 317 |
let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err; |
| 318 |
} |
| 319 |
--let SEARCH_FILE= $log_error_ |
| 320 |
--let SEARCH_PATTERN= Slave SQL: The incident LOST_EVENTS occurred on the master\. Message: error writing to the binary log, Internal MariaDB error code: 1590 |
| 321 |
--source include/search_pattern_in_file.inc |
| 322 |
|
| 323 |
SELECT * FROM t4 ORDER BY a; |
| 324 |
STOP SLAVE IO_THREAD; |
| 325 |
SET sql_slave_skip_counter= 1; |
| 326 |
--source include/start_slave.inc |
| 327 |
|
| 328 |
--connection master |
| 329 |
--save_master_pos |
| 330 |
|
| 331 |
--connection slave |
| 332 |
--sync_with_master |
| 333 |
SELECT * FROM t4 ORDER BY a; |
| 334 |
|
| 335 |
|
| 336 |
--connection slave |
| 337 |
set @@global.binlog_checksum = @slave_save_binlog_checksum; |
| 338 |
set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum; |
| 339 |
|
| 340 |
--echo End of tests |
| 341 |
|
| 342 |
--connection master |
| 343 |
DROP TABLE t4; |
| 344 |
|
| 345 |
--source include/rpl_end.inc |