diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-02-01 15:47:33 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-02-02 10:20:22 +0200 |
commit | 650ffcd3a081f0bf4e3b7de93fac72c1b67284e1 (patch) | |
tree | b26ac484a4328c7353127b7e412e75c074928f4a /mysql-test/suite/innodb/t | |
parent | 8481c70ede067b576d5b1576a9b68042e84368fb (diff) | |
download | mariadb-git-650ffcd3a081f0bf4e3b7de93fac72c1b67284e1.tar.gz |
Extend the innodb.log_corruption test.
Remove the dependency on unzip. Instead, generate the InnoDB files
with perl.
log_block_checksum_is_ok(): Correct the error message.
recv_scan_log_recs(): Remove the duplicated error message for
log block checksum mismatch.
innobase_start_or_create_for_mysql(): If the server is in read-only
mode or if innodb_force_recovery>=3, do not try to modify the system
tablespace. (If the doublewrite buffer or the non-core system tables
do not exist, do not try to create them.)
innodb_shutdown(): Relax a debug assertion. If the system tablespace
did not contain a doublewrite buffer and if we started up in
innodb_read_only mode or with innodb_force_recovery>=3, it will not
be created.
dict_create_or_check_sys_tablespace(): Set the flag
srv_sys_tablespaces_open when the tables exist.
Diffstat (limited to 'mysql-test/suite/innodb/t')
-rw-r--r-- | mysql-test/suite/innodb/t/log_corruption.test | 234 |
1 files changed, 196 insertions, 38 deletions
diff --git a/mysql-test/suite/innodb/t/log_corruption.test b/mysql-test/suite/innodb/t/log_corruption.test index 664894f2c41..0a02b4bae2b 100644 --- a/mysql-test/suite/innodb/t/log_corruption.test +++ b/mysql-test/suite/innodb/t/log_corruption.test @@ -1,4 +1,3 @@ ---source include/have_unzip.inc --source include/have_innodb.inc --source include/have_innodb_16k.inc @@ -25,95 +24,224 @@ secure_file_priv= skip_aria core_file "; +close OUT or die; +die unless open OUT, ">", "$ENV{bugdir}/ib_buffer_pool"; +close OUT or die; + +# Create a dummy system tablespace file using the default innodb_page_size=16k +die unless open OUT, ">", "$ENV{bugdir}/ibdata1"; +binmode OUT; + +# Tablespace header page with valid FSP_SIZE=768 pages. +# Also, write a dummy FSEG_MAGIC_N at offset 60 to keep fseg_inode_try_get() +# happy when fseg_n_reserved_pages() is following an invalid pointer +# from the all-zero change buffer header page (page 3). +print OUT pack("Nx[42]Nx[10]Nx[16312]Nx[4]", + 0xdeadbeef, # checksum + 768, # FSP_PAGE_SIZE + 97937874, # FSEG_MAGIC_N + 0xdeadbeef); # checksum +# Dummy pages 1..6. +print OUT chr(0) x (6 * 16384); +# Dictionary header page. +print OUT pack("NNx[62]Nx[8]Nx[16290]Nx[4]", + 0xdeadbeef, # checksum + 7, # FIL_PAGE_OFFSET + 8, # DICT_HDR_TABLES + 9, # DICT_HDR_INDEXES + 0xdeadbeef); # checksum + +# Empty SYS_TABLES page (page 8). +print OUT pack("NNNNx[8]nx[12]nnx[31]Cx[20]", + 0xdeadbeef, # checksum + 8, # FIL_PAGE_OFFSET + ~0, ~0, # FIL_PAGE_PREV, FIL_PAGE_NEXT + 17855, # FIL_PAGE_TYPE == FIL_PAGE_INDEX + 2, # PAGE_N_DIR_SLOTS + 124, # PAGE_HEAP_TOP + 1); # PAGE_INDEX_ID == DICT_TABLES_ID +print OUT pack("nxnn", 0x801, 3, 116), "infimum"; +print OUT pack("xnxnxx", 0x901, 0x803), "supremum"; +print OUT pack("x[16248]nnNx[4]", 116, 101, 0xdeadbeef); + +# Empty SYS_INDEXES page (page 9). +print OUT pack("NNNNx[8]nx[12]nnx[31]Cx[20]", + 0xdeadbeef, # checksum + 9, # FIL_PAGE_OFFSET + ~0, ~0, # FIL_PAGE_PREV, FIL_PAGE_NEXT + 17855, # FIL_PAGE_TYPE == FIL_PAGE_INDEX + 2, # PAGE_N_DIR_SLOTS + 124, # PAGE_HEAP_TOP + 3); # PAGE_INDEX_ID == DICT_INDEXES_ID + +print OUT pack("nxnn", 0x801, 3, 116), "infimum"; +print OUT pack("xnxnxx", 0x901, 0x803), "supremum"; +print OUT pack("x[16248]nnNx[4]", 116, 101, 0xdeadbeef); +print OUT chr(0) x (759 * 16384); +close OUT or die; + +# Create a dummy second redo log file +die unless open OUT, ">", "$ENV{bugdir}/ib_logfile1"; +binmode OUT; +print OUT chr(0) x 1048576; +close OUT or die; + +# Create a redo log from before MySQL 5.7.9 +die unless open OUT, ">", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +print OUT pack("x[9]nx[5]", 0x1286), " ", chr(0) x 492; +print OUT pack("x[13]nCNnxxNNx[256]", 0x1286, 12, 0x80c, 0xf0, ~0, ~0); +print OUT pack("H*x[1240]", "590DBAACFE922582"); +print OUT pack("H*x[5]", "800009440022000c0000000138"); +print OUT pack("H*x[475]H*", "12860cb7809781e80006626f677573", "089C0ADA"); +print OUT chr(0) x 1046016; +close OUT or die; EOF --echo # redo log from before MySQL 5.7.9 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption.zip -d $bugdir > $SEARCH_FILE --error 1 --exec $MYSQLD $args let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported. This redo log was created before MySQL 5\\.7\\.9\\.; --source include/search_pattern_in_file.inc --echo # redo log from before MySQL 5.7.9, with corrupted log checkpoint ---remove_file $bugdir/ib_logfile0 ---copy_file $bugdir/ib_logfile1 $bugdir/ib_logfile0 +--move_file $bugdir/ib_logfile0 $bugdir/ib_logfile +--copy_file $bugdir/ib_logfile1 $bugdir/ib_logfile0 --error 1 --exec $MYSQLD $args let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported. This redo log was created before MySQL 5\\.7\\.9, and we did not find a valid checkpoint; --source include/search_pattern_in_file.inc +let SEARCH_PATTERN=Plugin 'InnoDB' registration as a STORAGE ENGINE failed; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=Unknown/unsupported storage engine: InnoDB; +--source include/search_pattern_in_file.inc --echo # redo log from before MySQL 5.7.9, with corrupted log block --remove_file $bugdir/ib_logfile0 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption0.zip -d $bugdir > $SEARCH_FILE +--move_file $bugdir/ib_logfile $bugdir/ib_logfile0 +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +die unless seek(OUT, 0x800, 0); +print OUT pack("Nx[508]", 0xc0deba5e); +close OUT or die; +EOF + --error 1 --exec $MYSQLD $args let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported. This redo log was created before MySQL 5\\.7\\.9, and it appears corrupted; --source include/search_pattern_in_file.inc --echo # redo log from "after" MySQL 5.7.9, but with invalid header checksum ---remove_file $bugdir/ib_logfile0 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption1.zip -d $bugdir > $SEARCH_FILE +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +print OUT pack("N",2); +close OUT or die; +EOF --error 1 --exec $MYSQLD $args let SEARCH_PATTERN=InnoDB: Invalid redo log header checksum; --source include/search_pattern_in_file.inc --echo # distant future redo log format, with valid header checksum ---remove_file $bugdir/ib_logfile0 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption2.zip -d $bugdir > $SEARCH_FILE +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +print OUT pack("Nx[5]nx[5]", ~0, 0x1286); +print OUT "malicious intentions, or perhaps not"; +print OUT pack("x[456]N", 0x8a1bb475); +close OUT or die; +EOF --error 1 --exec $MYSQLD $args let SEARCH_PATTERN=InnoDB: Unsupported redo log format. The redo log was created with malicious intentions, or perhaps\. Please follow the instructions at http://dev.mysql.com/doc/refman/5.7/en/upgrading-downgrading.html; --source include/search_pattern_in_file.inc --echo # valid header, but old-format checkpoint blocks ---remove_file $bugdir/ib_logfile0 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption3.zip -d $bugdir > $SEARCH_FILE +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +# header block +print OUT pack("Nx[5]nx[5]", 1, 0x1286); +print OUT "malicious intentions, or perhaps not"; +print OUT pack("x[456]N", 0xd42d53a2); +# old-format checkpoint block 1 +print OUT pack("x[13]nCNnxxNNx[256]", 0x1286, 12, 0x80c, 0xf0, ~0, ~0); +print OUT pack("H*x[1240]", "590DBAACFE922582"); +print OUT pack("H*x[5]", "800009440022000c0000000138"); +print OUT pack("H*x[475]H*", "12860cb7809781e80006626f677573", "089C0ADA"); +close OUT or die; +EOF --error 1 --exec $MYSQLD $args let SEARCH_PATTERN=InnoDB: No valid checkpoint found .corrupted redo log; --source include/search_pattern_in_file.inc --echo # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block checksum ---remove_file $bugdir/ib_logfile0 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption4.zip -d $bugdir > $SEARCH_FILE +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +die unless seek(OUT, 0x210, 0); +print OUT pack("NNx[264]", 0, 0x80c); +print OUT pack("NNx[212]N", 0x590dbaac, 0xfe922582, 0xc72d49c4); +close OUT or die; +EOF # 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 --exec $MYSQLD $args --innodb-force-recovery=5 -let SEARCH_PATTERN=InnoDB: Log block 2372 at lsn 1213952 has valid header, but checksum field contains 144444122, should be 3362026715; +let SEARCH_PATTERN=InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122; --source include/search_pattern_in_file.inc let SEARCH_PATTERN=InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 1213964 and the end 1213952\.; --source include/search_pattern_in_file.inc -let SEARCH_PATTERN=Plugin 'InnoDB' registration as a STORAGE ENGINE failed; ---source include/search_pattern_in_file.inc --echo # --innodb-force-recovery=6 (skip the entire redo log) ---error 1 ---exec $MYSQLD $args --innodb-force-recovery=6 -let SEARCH_PATTERN=InnoDB: Cannot create sys_virtual system tables. running in read-only mode; +--error 2 +--exec $MYSQLD $args --innodb-force-recovery=6 --unknown-option +--let SEARCH_PATTERN=\\[Note\\] InnoDB: .* started; log sequence number 0 +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=\\[ERROR\\] Aborting --source include/search_pattern_in_file.inc --echo # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block number ---remove_file $bugdir/ib_logfile0 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption4a.zip -d $bugdir > $SEARCH_FILE +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +# header block +print OUT pack("Nx[5]nx[5]", 1, 0x1286); +print OUT "malicious intentions, or perhaps not"; +print OUT pack("x[456]N", 0xd42d53a2); +# checkpoint page 1 and all-zero checkpoint 2 +print OUT pack("x[13]nCNNx[264]", 0x1286, 12, 0, 0x80c); +print OUT pack("H*x[212]Nx[1024]", "590DBAACFE922582", 0xc72d49c4); +# redo log data +print OUT pack("H*x[5]", "C0DEBA5E0022000c0000000138"); +print OUT pack("H*x[475]H*", "12860cb7809781e80006626f677573", "089C0ADA"); +EOF +--copy_file $bugdir/ib_logfile0 $bugdir/ib_logfile # 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 --exec $MYSQLD $args --innodb-force-recovery=5 let SEARCH_PATTERN=InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 1213964 and the end 1213952\.; --source include/search_pattern_in_file.inc -let SEARCH_PATTERN=Plugin 'InnoDB' registration as a STORAGE ENGINE failed; ---source include/search_pattern_in_file.inc --echo # --innodb-force-recovery=6 (skip the entire redo log) ---error 1 ---exec $MYSQLD $args --innodb-force-recovery=6 -let SEARCH_PATTERN=InnoDB: Cannot create sys_virtual system tables. running in read-only mode; ---source include/search_pattern_in_file.inc +--error 2 +--exec $MYSQLD $args --innodb-force-recovery=6 --unknown-option --echo # Test a corrupted MLOG_FILE_NAME record. --echo # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2 --remove_file $bugdir/ib_logfile0 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption5.zip -d $bugdir > $SEARCH_FILE +--move_file $bugdir/ib_logfile $bugdir/ib_logfile0 +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +die unless seek(OUT, 0x800, 0); +print OUT pack("N", 0x80000944); +die unless seek(OUT, 0x9fc, 0); +print OUT pack("N", 0xc86474db); +close OUT or die; +EOF --error 1 --exec $MYSQLD $args let SEARCH_PATTERN=InnoDB: Log scan progressed past the checkpoint lsn 1213964; @@ -128,20 +256,50 @@ let SEARCH_PATTERN=InnoDB: Set innodb_force_recovery to ignore this error; --source include/search_pattern_in_file.inc --echo # Test a corrupted MLOG_FILE_NAME record. ---echo # valid header, invalid checkpoint 1, valid checkpoint 2 ---remove_file $bugdir/ib_logfile0 ---exec unzip $MTR_SUITE_DIR/std_data/log_corruption6.zip -d $bugdir > $SEARCH_FILE +--echo # valid header, invalid checkpoint 1, valid checkpoint 2, invalid block +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +# header block +print OUT pack("Nx[5]nx[5]", 1, 0x1286); +print OUT "ibbackup was here!!!1!"; +print OUT pack("x[470]N", 0x52b54540); +# invalid (all-zero) checkpoint page 1 and an empty log page +print OUT chr(0) x 1024; +# valid checkpoint block 2 +print OUT pack("x[13]nCNNx[264]", 0x1286, 12, 0, 0x80c); +print OUT pack("H*x[212]N", "590DBAACFE922582", 0xc72d49c4); +# log page +print OUT pack("H*", "800009440022000c00000001"); +# MLOG_CHECKPOINT record +print OUT pack("H*", "38000000000012860c"); +# MLOG_FILE_NAME record +print OUT pack("H*", "b7809781e80006"), "bigot"; +# padding and wrong log block checksum +print OUT pack("x[475]N", 150151); +close OUT or die; +EOF --error 1 --exec $MYSQLD $args -let SEARCH_PATTERN=InnoDB: ############### CORRUPT LOG RECORD FOUND ##################; ---source include/search_pattern_in_file.inc -let SEARCH_PATTERN=InnoDB: Log record type 55, page 151:488\. Log parsing proceeded successfully up to 1213973\. Previous log record type 56, is multi 0 Recv offset 9, prev 0; +let SEARCH_PATTERN=InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 2454333373 found: 150151; --source include/search_pattern_in_file.inc -let SEARCH_PATTERN=InnoDB: Hex dump starting 0 bytes before and ending 13 bytes after the corrupted record; ---source include/search_pattern_in_file.inc -let SEARCH_PATTERN= len 22. hex 38000000000012860cb7809781e80006626f67757300. asc 8 bogus ; +--echo # valid header, invalid checkpoint 1, valid checkpoint 2, invalid log record +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +die unless seek(OUT, 0x9fc, 0); +print OUT pack("N", 2454333373); +close OUT or die; +EOF + +--error 1 +--exec $MYSQLD $args +--let SEARCH_PATTERN= len 22; hex 38000000000012860cb7809781e800066269676f7400; asc 8 bigot ; --source include/search_pattern_in_file.inc -let SEARCH_PATTERN=InnoDB: Set innodb_force_recovery to ignore this error; + +# Catch errors when built with one of the sanitizers +--let SEARCH_ABORT=FOUND +--let SEARCH_PATTERN=Sanitizer --source include/search_pattern_in_file.inc --list_files $bugdir |