let newdir= $MYSQLTEST_VARDIR/tmp/log_corruption; --mkdir $newdir --mkdir $newdir/mysql write_file $newdir/mysql/plugin.frm; EOF let SEARCH_FILE = $newdir/my_restart.err; let $args=--no-defaults --innodb_dedicated_server=OFF --datadir=$newdir --secure-file-priv="" --loose-skip-auto-generate-certs --loose-skip-sha256-password-auto-generate-rsa-keys --loose-console --loose-skip-log-bin --log-error-verbosity=3 > $SEARCH_FILE 2>&1 ; --echo # redo log from before we started versioning in MySQL 5.7.9 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args let SEARCH_PATTERN=Unsupported redo log format \(0\). The redo log was created before MySQL 5\.7\.9.*; --source include/search_pattern.inc --echo # redo log from before MySQL 8.0.3, with corrupted log block --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption0.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args let SEARCH_PATTERN=Upgrade after a crash is not supported.*; --source include/search_pattern.inc --echo # redo log from MySQL 8.0.3, but with invalid header checksum --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption1.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args let SEARCH_PATTERN=Invalid redo log header checksum; --source include/search_pattern.inc --echo # distant future redo log format, with valid header checksum --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption2.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args let SEARCH_PATTERN=Unknown redo log format \(4294967295\).*; --source include/search_pattern.inc --echo # redo log from MySQL 8.0.3, with corrupted log checkpoint --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption3.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args let SEARCH_PATTERN=No valid checkpoint found.*corrupted redo log; --source include/search_pattern.inc --echo # valid 5.7.9 header, valid checkpoint 1, all-zero (invalid) checkpoint 2, --echo # invalid block checksum, --echo # thus we cannot determine if the redo log is logically clean. --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption4.zip -d $newdir > $SEARCH_FILE # Anything below innodb_force_recovery=6 must find a valid redo log. # Missing tablespace files are tolerated already with innodb_force_recovery=1. --error 1,42 --exec $MYSQLD $args --innodb-force-recovery=5 let SEARCH_PATTERN=Database upgrade cannot be accomplished with innodb_force_recovery > 0; --source include/search_pattern.inc --echo # --innodb-force-recovery=6 (skip the entire redo log) --error 1,42 --exec $MYSQLD $args --innodb-force-recovery=6 let SEARCH_PATTERN=Database upgrade cannot be accomplished in read-only mode; --source include/search_pattern.inc --echo # valid 5.7.9 header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block number --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption4a.zip -d $newdir > $SEARCH_FILE # Anything below innodb_force_recovery=6 must find a valid redo log. # Missing tablespace files are tolerated already with innodb_force_recovery=1. --echo # Start with innodb-force-recovery=5 --error 1,42 --exec $MYSQLD $args --innodb-force-recovery=5 let SEARCH_PATTERN=Database upgrade cannot be accomplished with innodb_force_recovery > 0; --source include/search_pattern.inc --echo # Start with --innodb-force-recovery=6 (skip the entire redo log) --error 1,42 --exec $MYSQLD $args --innodb-force-recovery=6 let SEARCH_PATTERN=Database upgrade cannot be accomplished in read-only mode; --source include/search_pattern.inc --echo # valid 8.0.3 header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block checksum --remove_file $newdir/ib_logfile0 # Make server believe this is 8.0 datadir --move_file $newdir/mysql/plugin.frm $newdir/mysql/plugin.frm.old write_file $newdir/mysql.ibd; EOF --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption4b.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args --innodb-force-recovery=5 let SEARCH_PATTERN=Log block 2372 at lsn 1213952 has valid header, but checksum field contains 144444122, should be 3362026715; --source include/search_pattern.inc let SEARCH_PATTERN=Data Dictionary initialization failed; --source include/search_pattern.inc --remove_file $newdir/mysql.ibd --move_file $newdir/mysql/plugin.frm.old $newdir/mysql/plugin.frm --echo # --innodb-force-recovery=6 (skip the entire redo log) --error 1,42 --exec $MYSQLD $args --innodb-force-recovery=6 let SEARCH_PATTERN=Database upgrade cannot be accomplished in read-only mode; --source include/search_pattern.inc --echo # valid 5.7.9 header, valid checkpoint 1, no matching MLOG_CHECKSUM --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption4c.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args let SEARCH_PATTERN=Upgrade after a crash is not supported\\. This redo log was created with malicious intentions, or perhaps\\.; --source include/search_pattern.inc let SEARCH_PATTERN=Data Dictionary initialization failed; --source include/search_pattern.inc --echo # --innodb-force-recovery=6 (skip the entire redo log) --error 1,42 --exec $MYSQLD $args --innodb-force-recovery=6 let SEARCH_PATTERN=Database upgrade cannot be accomplished in read-only mode; --source include/search_pattern.inc --echo # upgrade: valid 5.7.9 header, valid checkpoint 1, logically non empty --echo # redo log --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption4d.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args --innodb-log-file-size=4M let SEARCH_PATTERN=Upgrade after a crash is not supported.*; --source include/search_pattern.inc # Replace database with 1M redo logs from before MySQL 8.0.3 --remove_file $newdir/ib_logfile0 --remove_file $newdir/ib_logfile1 --remove_file $newdir/ibdata1 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption.zip -d $newdir > $SEARCH_FILE --echo # Test a corrupted record. --echo # current header, valid checkpoint 1, all-zero (invalid) checkpoint 2 --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption5.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args let SEARCH_PATTERN=############### CORRUPT LOG RECORD FOUND ###############; --source include/search_pattern.inc let SEARCH_PATTERN=Log record type 56, page 0:0\\. Log parsing proceeded successfully up to 1213964\\. Previous log record type 128, is multi 0 Recv offset 0, prev 0; --source include/search_pattern.inc let SEARCH_PATTERN= len 22. hex 38000000000012860cb7809781e80006626f67757300. asc 8 bogus ; --source include/search_pattern.inc let SEARCH_PATTERN=Set innodb_force_recovery to ignore this error; --source include/search_pattern.inc --echo # Test a corrupted record. --echo # valid header, invalid checkpoint 1, valid checkpoint 2 --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption6.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args let SEARCH_PATTERN=The log file was created by mysqlbackup --apply-log at MEB was here!!!1!\\. The following crash recovery is part of a normal restore\\.; --source include/search_pattern.inc let SEARCH_PATTERN=############### CORRUPT LOG RECORD FOUND ###############; --source include/search_pattern.inc let SEARCH_PATTERN=Log record type 56, page 0:0\\. Log parsing proceeded successfully up to 1213964\\. Previous log record type 128, is multi 0 Recv offset 0, prev 0; --source include/search_pattern.inc let SEARCH_PATTERN=Hex dump starting 0 bytes before and ending 22 bytes after the corrupted record; --source include/search_pattern.inc let SEARCH_PATTERN= len 22. hex 38000000000012860cb7809781e80006626f67757300. asc 8 bogus ; --source include/search_pattern.inc let SEARCH_PATTERN=Set innodb_force_recovery to ignore this error; --source include/search_pattern.inc --echo # Test a corrupted record with creator field very long. # This file was created in such a way that checksums agree, but the creator field # and all subsequent bytes are non-zero, which might cause buffer overrun if one # simply tried to copy the creator string in a way which expects '\0'-terminated string --remove_file $newdir/ib_logfile0 --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption6b.zip -d $newdir > $SEARCH_FILE --error 1,42 --exec $MYSQLD $args # The important thing here is that the field for creator has 32 bytes, and the file actually contains # MEB45678901234567890123456789012 # which is 32 non-zero bytes (the string is thus not '\0'-terminated). # Moreover the following bytes, up to 2k-byte boundary are also non-zero, which means that # the whole read portion of header does not contain '\0'. # We expect this last '2' to be replaced with '\0' for safety. # If it is not replaced by '\0' then the output will contain the rest of header # and also a part of stack variables until first '\0'. let SEARCH_PATTERN=The log file was created by mysqlbackup --apply-log at MEB4567890123456789012345678901\\. The following crash recovery is part of a normal restore\\.; --source include/search_pattern.inc --echo # Upgrade: valid 5.7.9 header, valid checkpoint 1, logically empty --echo # redo log --force-rmdir $newdir --mkdir $newdir --mkdir $newdir/mysql write_file $newdir/mysql/plugin.frm; EOF --exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption7.zip -d $newdir > $SEARCH_FILE --error 1 --exec $MYSQLD $args let SEARCH_PATTERN=Upgrading redo log: 2\\*.* bytes, LSN=1319985; --source include/search_pattern.inc --force-rmdir $newdir