| 1 |
--source include/have_debug_sync.inc |
| 2 |
|
| 3 |
# This test checks scenario of recovery executed on data directory with redo |
| 4 |
# file that has broken checkpoint_lsn (pointing outside the file) |
| 5 |
|
| 6 |
# According to perl's documentation, 'Q' in (un)pack() is supported only if perl |
| 7 |
# has been compiled with support for 64bit integers. |
| 8 |
# The log_file_get_checkpoint_lsn(), which is used in this test, uses unpack('Q>'). |
| 9 |
# The log_file_get_start_lsn(), which is used in this test, uses unpack('Q>'). |
| 10 |
--source include/have_perl_64bit_int.inc |
| 11 |
|
| 12 |
let $tmp_dir = $MYSQLTEST_VARDIR/tmp; |
| 13 |
let MYSQLD_DATADIR = $tmp_dir/log_invalid_file; |
| 14 |
let MYSQLD_ERROR_LOG = $tmp_dir/my_restart.err; |
| 15 |
let MYSQLD_EXTRA_ARGS = ; |
| 16 |
let SEARCH_FILE = $MYSQLD_ERROR_LOG; |
| 17 |
|
| 18 |
--echo # Initialize new data directory... |
| 19 |
--source include/initialize_datadir.inc |
| 20 |
|
| 21 |
perl; |
| 22 |
require 'include/ib_redo_log_files.inc'; |
| 23 |
my $fpath = ''; |
| 24 |
my $n = 0; |
| 25 |
for my $f (log_get_non_tmp_files()) { |
| 26 |
$fpath = $f; |
| 27 |
$n++; |
| 28 |
} |
| 29 |
my $start_lsn = log_file_get_start_lsn($fpath); |
| 30 |
my $end_lsn = $start_lsn + (-s $fpath) - 2048; |
| 31 |
my $old_checkpoint_lsn = log_file_get_checkpoint_lsn($fpath); |
| 32 |
my $new_checkpoint_lsn = $end_lsn + 12; |
| 33 |
log_file_set_checkpoint_lsn($fpath, $new_checkpoint_lsn, $old_checkpoint_lsn+1); |
| 34 |
|
| 35 |
my $result_file_path = "$ENV{'MYSQLD_DATADIR'}/found.inc"; |
| 36 |
open my $fh, '+>', $result_file_path or die "open failed: $!\n"; |
| 37 |
if ($n > 1) { |
| 38 |
syswrite($fh, "--skip \"Initialized datadir with more than 1 redo file.\"\n") > 0 or die "write failed: $!\n"; |
| 39 |
} |
| 40 |
syswrite($fh, "let REDO_OLD_CHECKPOINT_LSN=$old_checkpoint_lsn;\n") > 0 or die "write failed: $!\n"; |
| 41 |
syswrite($fh, "let REDO_NEW_CHECKPOINT_LSN=$new_checkpoint_lsn;\n") > 0 or die "write failed: $!\n"; |
| 42 |
syswrite($fh, "let REDO_FILE_START_LSN=$start_lsn;\n") > 0 or die "write failed: $!\n"; |
| 43 |
syswrite($fh, "let REDO_FILE_END_LSN=$end_lsn;\n") > 0 or die "write failed: $!\n"; |
| 44 |
close $fh or die "close failed: $!\n"; |
| 45 |
EOF |
| 46 |
|
| 47 |
--source $MYSQLD_DATADIR/found.inc |
| 48 |
|
| 49 |
# The recovery would fail because of invalid checksum (after we corrupted checkpoint_lsn and did not update checksum) |
| 50 |
--error 1,42 |
| 51 |
--exec $MYSQLD --no-defaults $MYSQLD_ARGS --innodb-unknown-param=y |
| 52 |
let SEARCH_PATTERN = No valid checkpoint found \(corrupted redo log\). You can try --innodb-force-recovery=6 as a last resort; |
| 53 |
--source include/search_pattern.inc |
| 54 |
|
| 55 |
--move_file $SEARCH_FILE $MYSQLTEST_VARDIR/log/log_file_invalid_checkpoint-1.err |
| 56 |
|
| 57 |
let MYSQLD_EXTRA_ARGS = --debug="d,log_header_checksum_disabled"; |
| 58 |
|
| 59 |
# Now, let's assume that the invalid checkpoint_lsn was written by broken InnoDB instance (so header has valid checksum) |
| 60 |
--error 1,42 |
| 61 |
--exec $MYSQLD --no-defaults $MYSQLD_ARGS $MYSQLD_EXTRA_ARGS --innodb-unknown-param=y |
| 62 |
let SEARCH_PATTERN = Found checkpoint LSN $REDO_NEW_CHECKPOINT_LSN in a redo log file .*, but the file represents range of LSN values .*$REDO_FILE_START_LSN, $REDO_FILE_END_LSN.* so the file is corrupted.; |
| 63 |
--replace_result $REDO_NEW_CHECKPOINT_LSN REDO_NEW_CHECKPOINT_LSN $REDO_FILE_START_LSN REDO_FILE_START_LSN $REDO_FILE_END_LSN REDO_FILE_END_LSN |
| 64 |
--source include/search_pattern.inc |
| 65 |
|
| 66 |
--move_file $SEARCH_FILE $MYSQLTEST_VARDIR/log/log_file_invalid_checkpoint-2.err |
| 67 |
|
| 68 |
--force-rmdir $MYSQLD_DATADIR |
| 69 |
|
| 70 |
let MYSQLD_ARGS=; |
| 71 |
let MYSQLD_EXTRA_ARGS=; |
| 72 |
let MYSQLD_DATADIR=; |
| 73 |
let MYSQLD_ERROR_LOG=; |