diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-01-25 15:11:46 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-01-27 17:53:02 +0200 |
commit | 2de0e42af577eb803278187e3b82a5bb17ac3b9a (patch) | |
tree | 54b38109ddf3808a2b72a55519437490bbeffa03 | |
parent | 0f34160d1dfa0efa2abfc591fc688e8076bc8a1e (diff) | |
download | mariadb-git-2de0e42af577eb803278187e3b82a5bb17ac3b9a.tar.gz |
Import and adjust the InnoDB redo log tests from MySQL 5.7.
22 files changed, 1214 insertions, 6 deletions
diff --git a/mysql-test/suite/innodb/include/log_file_cleanup.inc b/mysql-test/suite/innodb/include/log_file_cleanup.inc new file mode 100644 index 00000000000..ef57d58b788 --- /dev/null +++ b/mysql-test/suite/innodb/include/log_file_cleanup.inc @@ -0,0 +1,16 @@ +# Remove ibtmp* which are re-generated after each mysqld invocation +# skip auto generated auto.cnf from list_files +--remove_files_wildcard $bugdir ibtmp* +--remove_files_wildcard $bugdir auto.cnf +--list_files $bugdir +--remove_files_wildcard $bugdir ibdata* +--remove_files_wildcard $bugdir ib_logfile* +--remove_files_wildcard $bugdir undo00* +--copy_file $bugdir/bak_ibdata1 $bugdir/ibdata1 +--copy_file $bugdir/bak_ibdata2 $bugdir/ibdata2 +--copy_file $bugdir/bak_ib_logfile0 $bugdir/ib_logfile0 +--copy_file $bugdir/bak_ib_logfile1 $bugdir/ib_logfile1 +--copy_file $bugdir/bak_ib_logfile2 $bugdir/ib_logfile2 +--copy_file $bugdir/bak_undo001 $bugdir/undo001 +--copy_file $bugdir/bak_undo002 $bugdir/undo002 +--copy_file $bugdir/bak_undo003 $bugdir/undo003 diff --git a/mysql-test/suite/innodb/r/log_corruption.result b/mysql-test/suite/innodb/r/log_corruption.result new file mode 100644 index 00000000000..64a8824189f --- /dev/null +++ b/mysql-test/suite/innodb/r/log_corruption.result @@ -0,0 +1,19 @@ +# redo log from before MySQL 5.7.9 +# redo log from before MySQL 5.7.9, with corrupted log checkpoint +# redo log from before MySQL 5.7.9, with corrupted log block +# redo log from "after" MySQL 5.7.9, but with invalid header checksum +# distant future redo log format, with valid header checksum +# valid header, but old-format checkpoint blocks +# valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block checksum +# --innodb-force-recovery=6 (skip the entire redo log) +# valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block number +# --innodb-force-recovery=6 (skip the entire redo log) +# Test a corrupted MLOG_FILE_NAME record. +# valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2 +# Test a corrupted MLOG_FILE_NAME record. +# valid header, invalid checkpoint 1, valid checkpoint 2 +ib_logfile0 +ib_logfile1 +ibdata1 +my.cnf +my_restart.err diff --git a/mysql-test/suite/innodb/r/log_file.result b/mysql-test/suite/innodb/r/log_file.result new file mode 100644 index 00000000000..a1ebdf037fa --- /dev/null +++ b/mysql-test/suite/innodb/r/log_file.result @@ -0,0 +1,344 @@ +# Testcase for the following bugs +# Bug#16691130 - ASSERT WHEN INNODB_LOG_GROUP_HOME_DIR DOES NOT EXIST +# Bug#16418661 - CHANGING NAME IN FOR INNODB_DATA_FILE_PATH SHOULD NOT SUCCEED WITH LOG FILES +# Write tmp/log_file/my.cnf +# Start mysqld without the possibility to create innodb_undo_tablespaces +# Remove undo001,undo002,ibdata1,ibdata2,ib_logfile1,ib_logfile2,ib_logfile101 +my.cnf +my_restart.err +# Start mysqld with non existent innodb_log_group_home_dir +# Remove ibdata1 & ibdata2 +my.cnf +my_restart.err +# Start mysqld to create tablespaces according to my.cnf +# Backup tmp/logfile/* +# 1. With ibdata2, Without ibdata1 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +ibdata2 +my.cnf +my_restart.err +undo001 +undo002 +undo003 +# 2. With ibdata1, without ibdata2 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo001 +undo002 +undo003 +# 3. Without ibdata1 & ibdata2 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +my.cnf +my_restart.err +undo001 +undo002 +undo003 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +my.cnf +my_restart.err +undo001 +undo002 +undo003 +# 4. Without ibdata*, ib_logfile* and with undo00* +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +my.cnf +my_restart.err +undo001 +undo002 +undo003 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +my.cnf +my_restart.err +undo001 +undo002 +undo003 +# 5. Without ibdata*,ib_logfile* files & Without undo002 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +my.cnf +my_restart.err +undo001 +undo003 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +my.cnf +my_restart.err +undo001 +undo003 +# 6. Without ibdata*,ib_logfile* files & Without undo001, undo002 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +my.cnf +my_restart.err +undo003 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +my.cnf +my_restart.err +undo003 +# 7. With ibdata files & Without undo002 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo001 +undo003 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo001 +undo003 +# 8. With ibdata files & Without undo001, undo002 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo003 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo003 +# 9. Without ibdata*, without undo*, Without ib_logfile1 and with ib_logfile2 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile2 +my.cnf +my_restart.err +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile2 +my.cnf +my_restart.err +# 11. With ibdata*, without ib_logfile1 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile2 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo001 +undo002 +undo003 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile2 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo001 +undo002 +undo003 +# 12. With ibdata*, without ib_logfile2 +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo001 +undo002 +undo003 +# Cleanup +bak_ib_logfile0 +bak_ib_logfile1 +bak_ib_logfile2 +bak_ibdata1 +bak_ibdata2 +bak_undo001 +bak_undo002 +bak_undo003 +ib_buffer_pool +ib_logfile0 +ib_logfile1 +ib_logfile2 +ibdata1 +ibdata2 +my.cnf +my_restart.err +undo001 +undo002 +undo003 diff --git a/mysql-test/suite/innodb/r/log_file_name.result b/mysql-test/suite/innodb/r/log_file_name.result new file mode 100644 index 00000000000..84107403cf2 --- /dev/null +++ b/mysql-test/suite/innodb/r/log_file_name.result @@ -0,0 +1,77 @@ +SET GLOBAL innodb_file_per_table=ON; +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t3(a INT PRIMARY KEY) ENGINE=InnoDB; +BEGIN; +INSERT INTO t3 VALUES (33101),(347); +INSERT INTO t1 VALUES (42),(9),(101); +RENAME TABLE t1 TO t2; +UPDATE t2 SET a=347 where a=42; +COMMIT; +# Kill the server +# Fault 0 (no real fault): Orphan file with duplicate space_id. +# Fault 1: Two dirty files with the same space_id. +SELECT * FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS +# Fault 2: Wrong space_id in a dirty file, and a missing file. +SELECT * FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS +# Fault 3: Wrong space_id in a dirty file, and no missing file. +SELECT * FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS +# Fault 4: Missing data file +SELECT * FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS +# Fault 5: Wrong type of data file +SELECT * FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS +SELECT * FROM t2; +a +9 +101 +347 +SELECT * FROM t3; +a +347 +33101 +SHOW TABLES; +Tables_in_test +t2 +t3 +DROP TABLE t2,t3; +CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; +ERROR HY000: Tablespace for table '`test`.`t0`' exists. Please DISCARD the tablespace before IMPORT +CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; +DROP TABLE t0; +CREATE TABLE u1(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE u2(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE u3(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE u4(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO u4 VALUES(1); +RENAME TABLE u4 TO u5; +RENAME TABLE u5 TO u6; +INSERT INTO u6 VALUES(2); +# Kill the server +# Fault 6: All-zero data file and innodb_force_recovery +SELECT * FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS +# Fault 7: Missing or wrong data file and innodb_force_recovery +SELECT * FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS +DROP TABLE u1,u2,u3,u6; +# List of files: +SHOW TABLES; +Tables_in_test diff --git a/mysql-test/suite/innodb/r/log_file_name_debug.result b/mysql-test/suite/innodb/r/log_file_name_debug.result new file mode 100644 index 00000000000..e82feef870c --- /dev/null +++ b/mysql-test/suite/innodb/r/log_file_name_debug.result @@ -0,0 +1,8 @@ +# +# Bug#19685095 DO NOT CARE ABOUT UNRESOLVED MLOG_FILE_NAME +# IF THERE ARE NO OPERATIONS TO APPLY +# +SET GLOBAL DEBUG_DBUG='+d,fil_names_write_bogus'; +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +# Kill the server +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/log_file_size_checkpoint.result b/mysql-test/suite/innodb/r/log_file_size_checkpoint.result new file mode 100644 index 00000000000..068b1368e1e --- /dev/null +++ b/mysql-test/suite/innodb/r/log_file_size_checkpoint.result @@ -0,0 +1,4 @@ +CREATE DATABASE logtest; +USE logtest; +# Kill and restart: --innodb-log-files-in-group=2 --innodb-log-file-size=4M --innodb-buffer-pool-size=50M +DROP DATABASE logtest; diff --git a/mysql-test/suite/innodb/t/log_corruption.test b/mysql-test/suite/innodb/t/log_corruption.test new file mode 100644 index 00000000000..725c8db6360 --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption.test @@ -0,0 +1,148 @@ +--source include/have_innodb.inc +--source include/have_innodb_16k.inc + +let bugdir= $MYSQLTEST_VARDIR/tmp/log_corruption; +--mkdir $bugdir +--let SEARCH_RANGE = -50000 +--let SEARCH_FILE = $bugdir/my_restart.err +--let SEARCH_ABORT=NOT FOUND +--let $args=--defaults-file=$bugdir/my.cnf --loose-console >> $SEARCH_FILE 2>&1 + +perl; +die unless open IN, "<", "$ENV{MYSQLTEST_VARDIR}/my.cnf"; +my $found; +while (<IN>) { $found=$1 if /^(lc-messages-dir=.*)/ } +close IN; + +die unless defined $found; +die unless open OUT, ">", "$ENV{bugdir}/my.cnf"; +print OUT "[mysqld] +$found +innodb_data_home_dir = $ENV{bugdir} +datadir = $ENV{bugdir} +secure_file_priv= +skip_aria +core_file +"; +EOF + +--echo # redo log from before MySQL 5.7.9 +--exec unzip $MYSQL_TEST_DIR/suite/innodb/t/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 +--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 + +--echo # redo log from before MySQL 5.7.9, with corrupted log block +--remove_file $bugdir/ib_logfile0 +--exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption0.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, 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 $MYSQL_TEST_DIR/suite/innodb/t/log_corruption1.zip -d $bugdir > $SEARCH_FILE +--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 $MYSQL_TEST_DIR/suite/innodb/t/log_corruption2.zip -d $bugdir > $SEARCH_FILE +--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 $MYSQL_TEST_DIR/suite/innodb/t/log_corruption3.zip -d $bugdir > $SEARCH_FILE +--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 $MYSQL_TEST_DIR/suite/innodb/t/log_corruption4.zip -d $bugdir > $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 +--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; +--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; +--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 $MYSQL_TEST_DIR/suite/innodb/t/log_corruption4a.zip -d $bugdir > $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 +--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 + +--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 $MYSQL_TEST_DIR/suite/innodb/t/log_corruption5.zip -d $bugdir > $SEARCH_FILE +--error 1 +--exec $MYSQLD $args +let SEARCH_PATTERN=InnoDB: Log scan progressed past the checkpoint lsn 1213964; +--source include/search_pattern_in_file.inc +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; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN= len 22. hex 38000000000012860cb7809781e80006626f67757300. asc 8 bogus ; +--source include/search_pattern_in_file.inc +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 $MYSQL_TEST_DIR/suite/innodb/t/log_corruption6.zip -d $bugdir > $SEARCH_FILE +--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; +--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 ; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=InnoDB: Set innodb_force_recovery to ignore this error; +--source include/search_pattern_in_file.inc + +--list_files $bugdir +--remove_files_wildcard $bugdir +--rmdir $bugdir diff --git a/mysql-test/suite/innodb/t/log_corruption.zip b/mysql-test/suite/innodb/t/log_corruption.zip Binary files differnew file mode 100644 index 00000000000..6f126c2edf0 --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption.zip diff --git a/mysql-test/suite/innodb/t/log_corruption0.zip b/mysql-test/suite/innodb/t/log_corruption0.zip Binary files differnew file mode 100644 index 00000000000..c003a18a1b2 --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption0.zip diff --git a/mysql-test/suite/innodb/t/log_corruption1.zip b/mysql-test/suite/innodb/t/log_corruption1.zip Binary files differnew file mode 100644 index 00000000000..35a02adaa6d --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption1.zip diff --git a/mysql-test/suite/innodb/t/log_corruption2.zip b/mysql-test/suite/innodb/t/log_corruption2.zip Binary files differnew file mode 100644 index 00000000000..4e4180ac4a3 --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption2.zip diff --git a/mysql-test/suite/innodb/t/log_corruption3.zip b/mysql-test/suite/innodb/t/log_corruption3.zip Binary files differnew file mode 100644 index 00000000000..2337c81a80b --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption3.zip diff --git a/mysql-test/suite/innodb/t/log_corruption4.zip b/mysql-test/suite/innodb/t/log_corruption4.zip Binary files differnew file mode 100644 index 00000000000..86002d7d42a --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption4.zip diff --git a/mysql-test/suite/innodb/t/log_corruption4a.zip b/mysql-test/suite/innodb/t/log_corruption4a.zip Binary files differnew file mode 100644 index 00000000000..6d072f3029f --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption4a.zip diff --git a/mysql-test/suite/innodb/t/log_corruption5.zip b/mysql-test/suite/innodb/t/log_corruption5.zip Binary files differnew file mode 100644 index 00000000000..bbf0238efc9 --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption5.zip diff --git a/mysql-test/suite/innodb/t/log_corruption6.zip b/mysql-test/suite/innodb/t/log_corruption6.zip Binary files differnew file mode 100644 index 00000000000..04dd687e7c9 --- /dev/null +++ b/mysql-test/suite/innodb/t/log_corruption6.zip diff --git a/mysql-test/suite/innodb/t/log_file.test b/mysql-test/suite/innodb/t/log_file.test new file mode 100644 index 00000000000..c8b06ff382a --- /dev/null +++ b/mysql-test/suite/innodb/t/log_file.test @@ -0,0 +1,261 @@ +--echo # Testcase for the following bugs +--echo # Bug#16691130 - ASSERT WHEN INNODB_LOG_GROUP_HOME_DIR DOES NOT EXIST +--echo # Bug#16418661 - CHANGING NAME IN FOR INNODB_DATA_FILE_PATH SHOULD NOT SUCCEED WITH LOG FILES + +--source include/have_innodb.inc + +let bugdir= $MYSQLTEST_VARDIR/tmp/log_file; +--mkdir $bugdir + +--let SEARCH_RANGE = -50000 +--let SEARCH_FILE = $bugdir/my_restart.err +--let SEARCH_ABORT=NOT FOUND +--let $args=--defaults-file=$bugdir/my.cnf --loose-console > $SEARCH_FILE 2>&1 + +--echo # Write tmp/log_file/my.cnf + +perl; +die unless open IN, "<", "$ENV{MYSQLTEST_VARDIR}/my.cnf"; +my $found; +while (<IN>) { $found=$1 if /^(lc-messages-dir=.*)/ } +close IN; + +die unless defined $found; +die unless open OUT, ">", "$ENV{bugdir}/my.cnf"; +print OUT "[mysqld] +$found +innodb_data_home_dir = $ENV{bugdir} +datadir = $ENV{bugdir} +secure_file_priv= +skip_aria +#core_file # MDEV-11689 FIXME: add this back, and remove all ,134 below +innodb_data_file_path = ibdata1:10M;ibdata2:10M:autoextend +innodb_undo_logs = 20 +innodb_undo_tablespaces = 3 +innodb_log_files_in_group = 3 +"; +close(OUT); +EOF + +--echo # Start mysqld without the possibility to create innodb_undo_tablespaces +--mkdir $bugdir/undo002 +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=\[ERROR\] InnoDB: Could not create undo tablespace '.*undo002'; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +--echo # Remove undo001,undo002,ibdata1,ibdata2,ib_logfile1,ib_logfile2,ib_logfile101 +--remove_file $bugdir/undo001 +--rmdir $bugdir/undo002 +--remove_file $bugdir/ibdata1 +--remove_file $bugdir/ibdata2 +--remove_file $bugdir/ib_logfile1 +--remove_file $bugdir/ib_logfile2 +--remove_file $bugdir/ib_logfile101 +--list_files $bugdir + +--echo # Start mysqld with non existent innodb_log_group_home_dir +--error 1,134 +--exec $MYSQLD $args --innodb_log_group_home_dir=/path/to/non-existent/ +let SEARCH_PATTERN=File .path.to.non-existent.*ib_logfile101: 'create' returned OS error \d+; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +--echo # Remove ibdata1 & ibdata2 +--remove_file $bugdir/ibdata1 +--remove_file $bugdir/ibdata2 +--list_files $bugdir + +# Innodb creates system tablespaces according to my.cnf and aborts +# complaining about mysql.* tables. This is sufficient for testing +# missing tablespaces. +--echo # Start mysqld to create tablespaces according to my.cnf +--error 2,134 +--exec $MYSQLD $args --skip-grant-tables --innodb-unknown-parameter +let SEARCH_PATTERN=unknown option '--innodb-unknown-parameter'; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +--echo # Backup tmp/logfile/* +--copy_file $bugdir/ibdata1 $bugdir/bak_ibdata1 +--copy_file $bugdir/ibdata2 $bugdir/bak_ibdata2 +--copy_file $bugdir/ib_logfile0 $bugdir/bak_ib_logfile0 +--copy_file $bugdir/ib_logfile1 $bugdir/bak_ib_logfile1 +--copy_file $bugdir/ib_logfile2 $bugdir/bak_ib_logfile2 +--copy_file $bugdir/undo001 $bugdir/bak_undo001 +--copy_file $bugdir/undo002 $bugdir/bak_undo002 +--copy_file $bugdir/undo003 $bugdir/bak_undo003 + +--echo # 1. With ibdata2, Without ibdata1 +--remove_file $bugdir/ibdata1 +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=The innodb_system data file 'ibdata1' was not found but one of the other data files 'ibdata2' exists; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + +--echo # 2. With ibdata1, without ibdata2 +--remove_file $bugdir/ibdata2 +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=Tablespace size stored in header is \d+ pages, but; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + +--echo # 3. Without ibdata1 & ibdata2 +--remove_file $bugdir/ibdata1 +--remove_file $bugdir/ibdata2 +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=undo tablespace .*undo001.* exists\. Creating system tablespace with existing undo tablespaces is not supported\. Please delete all undo tablespaces before creating new system tablespace\.; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + +--echo # 4. Without ibdata*, ib_logfile* and with undo00* +--remove_files_wildcard $bugdir ibdata* +--remove_files_wildcard $bugdir ib_logfile* +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=undo tablespace .*undo001.* exists\. Creating system tablespace with existing undo tablespaces is not supported\. Please delete all undo tablespaces before creating new system tablespace\.; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + + +--echo # 5. Without ibdata*,ib_logfile* files & Without undo002 +--remove_files_wildcard $bugdir ibdata* +--remove_files_wildcard $bugdir ib_logfile* +--remove_file $bugdir/undo002 +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=undo tablespace .*undo001.* exists\. Creating system tablespace with existing undo tablespaces is not supported\. Please delete all undo tablespaces before creating new system tablespace\.; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + +--echo # 6. Without ibdata*,ib_logfile* files & Without undo001, undo002 +# and with undo003 +--remove_files_wildcard $bugdir ibdata* +--remove_files_wildcard $bugdir ib_logfile* +--remove_file $bugdir/undo001 +--remove_file $bugdir/undo002 +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=undo tablespace .*undo003.* exists\. Creating system tablespace with existing undo tablespaces is not supported\. Please delete all undo tablespaces before creating new system tablespace\.; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + +--echo # 7. With ibdata files & Without undo002 +--remove_file $bugdir/undo002 +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=Expected to open 3 undo tablespaces but was able; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=to find only 1 undo tablespaces; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc +# clean up & Restore +--source ../include/log_file_cleanup.inc + +--echo # 8. With ibdata files & Without undo001, undo002 +--remove_file $bugdir/undo001 +--remove_file $bugdir/undo002 +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=Expected to open 3 undo tablespaces but was able; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=to find only 0 undo tablespaces; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + +--echo # 9. Without ibdata*, without undo*, Without ib_logfile1 and with ib_logfile2 +--remove_files_wildcard $bugdir ibdata* +--remove_files_wildcard $bugdir undo00* +--remove_file $bugdir/ib_logfile1 +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=redo log file .*ib_logfile0.* exists\. Creating system tablespace with existing redo log files is not recommended\. Please delete all redo log files before creating new system tablespace\.; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + +# 10. With ibdata*, without ib_logfile0 +#--remove_file $bugdir/ib_logfile0 +# The below would start the server. Since we cannot start a parallel +# server, do not test the below case +#--error 1,134 +#--exec $MYSQLD $args + +# clean up & Restore +#--source ../include/log_file_cleanup.inc + +--echo # 11. With ibdata*, without ib_logfile1 +--remove_file $bugdir/ib_logfile1 +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=Only one log file found; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] Aborting; +--source include/search_pattern_in_file.inc + +# clean up & Restore +--source ../include/log_file_cleanup.inc + +--echo # 12. With ibdata*, without ib_logfile2 +--remove_file $bugdir/ib_logfile2 +--list_files $bugdir +--error 1,134 +--exec $MYSQLD $args +let SEARCH_PATTERN=Resizing redo log from \d+\*\d+ to \d+\*\d+ pages, LSN=\d+; +--source include/search_pattern_in_file.inc + +--echo # Cleanup +# Remove ibtmp* which are re-generated after each mysqld invocation +# skip auto generated auto.cnf from list_files +--remove_files_wildcard $bugdir auto.cnf +--remove_files_wildcard $bugdir ibtmp* +--list_files $bugdir +--remove_files_wildcard $bugdir +--rmdir $bugdir diff --git a/mysql-test/suite/innodb/t/log_file_name.test b/mysql-test/suite/innodb/t/log_file_name.test new file mode 100644 index 00000000000..c55005c0e58 --- /dev/null +++ b/mysql-test/suite/innodb/t/log_file_name.test @@ -0,0 +1,268 @@ +# WL#7142 InnoDB: Simplify tablespace discovery during crash recovery +# Test the detection of duplicate tablespaces. + +--source include/have_innodb.inc + +# Embedded server does not support crashing +--source include/not_embedded.inc + +SET GLOBAL innodb_file_per_table=ON; + +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; + +--source include/no_checkpoint_start.inc +CREATE TABLE t3(a INT PRIMARY KEY) ENGINE=InnoDB; + +BEGIN; +INSERT INTO t3 VALUES (33101),(347); +INSERT INTO t1 VALUES (42),(9),(101); +RENAME TABLE t1 TO t2; +UPDATE t2 SET a=347 where a=42; +COMMIT; + +--let CLEANUP_IF_CHECKPOINT=DROP TABLE t2,t3; +--source include/no_checkpoint_end.inc + +--echo # Fault 0 (no real fault): Orphan file with duplicate space_id. +--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t0.ibd + +--echo # Fault 1: Two dirty files with the same space_id. +--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t1.ibd + +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; +let SEARCH_RANGE= -50000; +let SEARCH_ABORT= NOT FOUND; +let $check_no_innodb=SELECT * FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); + +# This could fail to refuse InnoDB startup, in case there was a log +# checkpoint after the INSERT. That is what we checked above. +--source include/start_mysqld.inc +eval $check_no_innodb; +let SEARCH_PATTERN= InnoDB: Ignoring data file '.*t2.ibd' with space ID \d+. Another data file called .*t1.ibd exists with the same space ID; +--source include/search_pattern_in_file.inc + +--source include/shutdown_mysqld.inc + +--remove_file $MYSQLD_DATADIR/test/t1.ibd +--remove_file $SEARCH_FILE + +# This could fail to refuse InnoDB startup, in case there was a log +# checkpoint after the CREATE TABLE t3. That is what we checked above. +--echo # Fault 2: Wrong space_id in a dirty file, and a missing file. +--move_file $MYSQLD_DATADIR/test/t3.ibd $MYSQLD_DATADIR/test/t1.ibd + +--source include/start_mysqld.inc +eval $check_no_innodb; + +let SEARCH_PATTERN= InnoDB: Ignoring data file '.*t1.ibd' with space ID; +--source include/search_pattern_in_file.inc + +let SEARCH_PATTERN= InnoDB: Tablespace \d+ was not found at.*t3.ibd; +--source include/search_pattern_in_file.inc + +--source include/shutdown_mysqld.inc + +--move_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t3.ibd + +--echo # Fault 3: Wrong space_id in a dirty file, and no missing file. +# Swap t2.ibd and t3.ibd. +--move_file $MYSQLD_DATADIR/test/t3.ibd $MYSQLD_DATADIR/test/t.ibd +--move_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t3.ibd +--move_file $MYSQLD_DATADIR/test/t.ibd $MYSQLD_DATADIR/test/t2.ibd + +--source include/start_mysqld.inc +eval $check_no_innodb; + +let SEARCH_PATTERN= InnoDB: Ignoring data file '.*t[23].ibd' with space ID; +--source include/search_pattern_in_file.inc + +let SEARCH_PATTERN= InnoDB: Tablespace \d+ was not found at .*t1.ibd; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN= InnoDB: Tablespace \d+ was not found at .*t3.ibd; +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN= InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace; +--source include/search_pattern_in_file.inc + +--source include/shutdown_mysqld.inc + +# Swap back t3.ibd, but hide t2.ibd (which the redo log also knows as t1.ibd). +--move_file $MYSQLD_DATADIR/test/t3.ibd $MYSQLD_DATADIR/test/t.ibd +--move_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t3.ibd + +--echo # Fault 4: Missing data file + +--source include/start_mysqld.inc +eval $check_no_innodb; + +let SEARCH_PATTERN= InnoDB: Tablespace \d+ was not found at .*t[12].ibd. +.*InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace; +--source include/search_pattern_in_file.inc + +--source include/shutdown_mysqld.inc + +--echo # Fault 5: Wrong type of data file + +# TODO: Test the following as well once +# Bug#18131883 IMPROVE INNODB ERROR MESSAGES REGARDING FILES +# has been fixed: +# A file containing 16384 zero bytes. +# --mkdir $MYSQLD_DATADIR/test/t2.ibd + +# Create a short file. +--exec echo "" > $MYSQLD_DATADIR/test/t2.ibd + +--source include/start_mysqld.inc +eval $check_no_innodb; + +let SEARCH_PATTERN= \[ERROR\] InnoDB: Datafile .*t2.*\. Cannot determine the space ID from the first 64 pages; +--source include/search_pattern_in_file.inc + +--source include/shutdown_mysqld.inc + +# Restore t2.ibd +--remove_file $MYSQLD_DATADIR/test/t2.ibd +--move_file $MYSQLD_DATADIR/test/t.ibd $MYSQLD_DATADIR/test/t2.ibd + +--source include/start_mysqld.inc + +SELECT * FROM t2; +SELECT * FROM t3; +SHOW TABLES; +DROP TABLE t2,t3; + +--error ER_TABLESPACE_EXISTS +CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; + +# Remove the orphan file from fault 0. +--remove_file $MYSQLD_DATADIR/test/t0.ibd + +CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; +DROP TABLE t0; + +--disable_query_log +# The following are for the orphan file t0.ibd: +call mtr.add_suppression("InnoDB: Operating system error number [0-9]* in a file operation"); +call mtr.add_suppression("InnoDB: Error number [0-9]* means 'File exists'"); +call mtr.add_suppression("InnoDB: Cannot create file '.*t0.ibd'"); +call mtr.add_suppression("InnoDB: The file '.*t0\.ibd' already exists"); +# The following are for aborted startup without --innodb-force-recovery: +call mtr.add_suppression("InnoDB: Tablespace .* was not found at .*test"); +call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace"); +call mtr.add_suppression("InnoDB: Cannot read first page of '.*test.[tu]2.ibd' I/O error"); +call mtr.add_suppression("InnoDB: Cannot read first page in datafile: .*test.*ibd"); +call mtr.add_suppression("InnoDB: Datafile './test/.*ibd' is corrupted"); +call mtr.add_suppression("InnoDB: Cannot replay file rename. Remove either file and try again"); +call mtr.add_suppression("InnoDB: Cannot rename.*because the target file exists"); +call mtr.add_suppression("InnoDB: Found corrupted log"); +# The following are for the --innodb-force-recovery=1 with broken u* tables: +call mtr.add_suppression("InnoDB: Header page consists of zero bytes in datafile: .*u1.ibd"); +call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified"); +call mtr.add_suppression("InnoDB: .*you must create directories"); +call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: '.*u[1-5]\.ibd'"); +call mtr.add_suppression("InnoDB: Could not find a valid tablespace file for `test/u[1-5]`"); +call mtr.add_suppression("InnoDB: Ignoring tablespace for `test`.`u[1-3]` because it could not be opened."); +call mtr.add_suppression("InnoDB: Failed to find tablespace for table .* in the cache. Attempting to load the tablespace with space id"); +call mtr.add_suppression("InnoDB: Plugin initialization aborted"); +call mtr.add_suppression("Plugin 'InnoDB' \(init function returned error\|registration as a STORAGE ENGINE failed\)"); +FLUSH TABLES; +--enable_query_log + +--source include/no_checkpoint_start.inc + +CREATE TABLE u1(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE u2(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE u3(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE u4(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO u4 VALUES(1); +RENAME TABLE u4 TO u5; +RENAME TABLE u5 TO u6; +INSERT INTO u6 VALUES(2); + +--let CLEANUP_IF_CHECKPOINT=DROP TABLE u1,u2,u3,u6; +--source include/no_checkpoint_end.inc + +--echo # Fault 6: All-zero data file and innodb_force_recovery + +--remove_file $MYSQLD_DATADIR/test/u1.ibd +--remove_file $MYSQLD_DATADIR/test/u2.ibd +--remove_file $MYSQLD_DATADIR/test/u3.ibd + +# InnoDB: Header page consists of zero bytes +perl; +die unless open(FILE, ">$ENV{MYSQLD_DATADIR}/test/u1.ibd"); +print FILE "\0" x 16384; +close(FILE); +EOF + +--exec echo "" > $MYSQLD_DATADIR/test/u2.ibd + +# TODO: Test with this, once +# Bug#18131883 IMPROVE INNODB ERROR MESSAGES REGARDING FILES +# has been fixed: +#--mkdir $MYSQLD_DATADIR/test/u3.ibd + +--copy_file $MYSQLD_DATADIR/test/u6.ibd $MYSQLD_DATADIR/test/u4.ibd + +--let $restart_parameters= --innodb-force-recovery=1 +--source include/start_mysqld.inc +eval $check_no_innodb; + +let SEARCH_PATTERN= \[ERROR\] InnoDB: Header page consists of zero bytes in datafile: .*u1.ibd; +--source include/search_pattern_in_file.inc + +let SEARCH_PATTERN= \[ERROR\] InnoDB: Datafile .*u1.*\. Cannot determine the space ID from the first 64 pages; +--source include/search_pattern_in_file.inc + +# TODO: These errors should state the file name (u2.ibd) and be ignored +# in innodb-force-recovery mode once +# Bug#18131883 IMPROVE INNODB ERROR MESSAGES REGARDING FILES +# has been fixed: +let SEARCH_PATTERN= \[ERROR\] InnoDB: Cannot read first page of .*u2.ibd.*; +--source include/search_pattern_in_file.inc + +--source include/shutdown_mysqld.inc + +# Allow --innodb-force-recovery to start despite the broken file. +# TODO: Remove this workaround, and make --innodb-force-recovery=1 +# ignore the broken file. +--remove_file $MYSQLD_DATADIR/test/u2.ibd + +--echo # Fault 7: Missing or wrong data file and innodb_force_recovery + +--source include/start_mysqld.inc +eval $check_no_innodb; + +let SEARCH_PATTERN= \[ERROR\] InnoDB: Header page consists of zero bytes in datafile: .*u1.ibd; +--source include/search_pattern_in_file.inc + +let SEARCH_PATTERN= InnoDB: At LSN: \d+: unable to open file .*u[1-5].ibd for tablespace; +--source include/search_pattern_in_file.inc + +let SEARCH_PATTERN= \[ERROR\] InnoDB: Cannot rename '.*u5.ibd' to '.*u6.ibd' for space ID \d+ because the target file exists; +--source include/search_pattern_in_file.inc + +--remove_file $MYSQLD_DATADIR/test/u6.ibd + +--source include/restart_mysqld.inc + +let SEARCH_PATTERN= \[ERROR\] InnoDB: Header page consists of zero bytes in datafile: .*u1.ibd; +--source include/search_pattern_in_file.inc + +let SEARCH_PATTERN= InnoDB: At LSN: \d+: unable to open file .*u[1-5].ibd for tablespace; +--source include/search_pattern_in_file.inc + +let SEARCH_PATTERN= \[Warning\] InnoDB: Tablespace \d+ was not found at .*u[1-5].ibd, and innodb_force_recovery was set. All redo log for this tablespace will be ignored!; +--source include/search_pattern_in_file.inc + +--let $restart_parameters= +--source include/restart_mysqld.inc + +DROP TABLE u1,u2,u3,u6; + +--remove_file $MYSQLD_DATADIR/test/u1.ibd +--echo # List of files: +--list_files $MYSQLD_DATADIR/test + +SHOW TABLES; diff --git a/mysql-test/suite/innodb/t/log_file_name_debug.test b/mysql-test/suite/innodb/t/log_file_name_debug.test new file mode 100644 index 00000000000..41d7ec2e53e --- /dev/null +++ b/mysql-test/suite/innodb/t/log_file_name_debug.test @@ -0,0 +1,31 @@ +--source include/have_innodb.inc +# Embedded server does not support restarting +--source include/not_embedded.inc +--source include/have_debug.inc + +--echo # +--echo # Bug#19685095 DO NOT CARE ABOUT UNRESOLVED MLOG_FILE_NAME +--echo # IF THERE ARE NO OPERATIONS TO APPLY +--echo # + +SET GLOBAL DEBUG_DBUG='+d,fil_names_write_bogus'; +--disable_query_log +FLUSH TABLES; +--enable_query_log + +--source include/no_checkpoint_start.inc + +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; + +--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1; +--source include/no_checkpoint_end.inc + +--source include/start_mysqld.inc + +DROP TABLE t1; + +--let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err +--let SEARCH_PATTERN = InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either +--let SEARCH_ABORT = NOT FOUND +--let SEARCH_RANGE = -50000 +--source include/search_pattern_in_file.inc diff --git a/mysql-test/suite/innodb/t/log_file_size_checkpoint.test b/mysql-test/suite/innodb/t/log_file_size_checkpoint.test new file mode 100644 index 00000000000..26e0bdf5e2c --- /dev/null +++ b/mysql-test/suite/innodb/t/log_file_size_checkpoint.test @@ -0,0 +1,32 @@ +--source include/have_innodb.inc +--source include/not_embedded.inc +--source include/no_valgrind_without_big.inc + +CREATE DATABASE logtest; +USE logtest; +let $n=250; +let $t=veryLongTableNameToCreateMLOG_FILE_NAMErecords; + +--disable_query_log +call mtr.add_suppression("InnoDB: Resizing redo log"); +call mtr.add_suppression("InnoDB: Starting to delete and rewrite log files"); +call mtr.add_suppression("InnoDB: New log files created"); +FLUSH TABLES; + +let $i=$n; +while ($i) +{ +--eval CREATE TABLE $t$i(a INT PRIMARY KEY) ENGINE=InnoDB; +dec $i; +} + +# If we set above n to 500, this test case could fail easily, because +# the inndob buffer pool is too small, some of which would be occupied +# by the recv*. With n=250, this test case could sporadically fail too. +# So we have to set buffer pool size to 50M which should be enough for this +# test case. Once we fix the bug#22179133 and bug#22186325, we should use +# the default innodb buffer pool(or the smaller one). +let $restart_parameters = --innodb-log-files-in-group=2 --innodb-log-file-size=4M --innodb-buffer-pool-size=50M; +--source include/kill_and_restart_mysqld.inc + +DROP DATABASE logtest; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 5ed02a92e0e..b869f2d1307 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4462,12 +4462,6 @@ innobase_change_buffering_inited_ok: } */ - if (!srv_read_only_mode) { - mysql_thread_create(thd_destructor_thread_key, - &thd_destructor_thread, - NULL, thd_destructor_proxy, NULL); - } - /* Since we in this module access directly the fields of a trx struct, and due to different headers and flags it might happen that ib_mutex_t has a different size in this module and in InnoDB @@ -4489,6 +4483,10 @@ innobase_change_buffering_inited_ok: if (err != DB_SUCCESS) { DBUG_RETURN(innobase_init_abort()); + } else if (!srv_read_only_mode) { + mysql_thread_create(thd_destructor_thread_key, + &thd_destructor_thread, + NULL, thd_destructor_proxy, NULL); } /* Adjust the innodb_undo_logs config object */ diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 3403534d36b..587ffc15adb 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1299,6 +1299,7 @@ srv_shutdown_all_bg_threads() @param[in] line Line number @param[in] err Reason for aborting InnoDB startup @return DB_SUCCESS or error code. */ +MY_ATTRIBUTE((warn_unused_result, nonnull)) static dberr_t srv_init_abort_low( @@ -2411,6 +2412,7 @@ files_checked: if (err != DB_SUCCESS) { return(srv_init_abort(err)); } + /* Create the doublewrite buffer to a new tablespace */ if (buf_dblwr == NULL && !buf_dblwr_create()) { return(srv_init_abort(DB_ERROR)); |