mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
a9d00db155
contains a bad and a good copy Clean up the InnoDB doublewrite buffer code. buf_dblwr_init_or_load_pages(): Do not add empty pages to the buffer. buf_dblwr_process(): Do consider changes to pages that are all zero. Do not abort when finding a corrupted copy of a page in the doublewrite buffer, because there could be multiple copies in the doublewrite buffer, and only one of them needs to be good.
101 lines
2.8 KiB
Text
101 lines
2.8 KiB
Text
#
|
|
# Test opening a corrupted table.
|
|
#
|
|
# Valgrind can hang or return spurious messages on DBUG_SUICIDE
|
|
source include/not_valgrind.inc;
|
|
# Avoid CrashReporter popup on Mac
|
|
source include/not_crashrep.inc;
|
|
# Restarting is not supported under embedded
|
|
source include/not_embedded.inc;
|
|
# Require InnoDB
|
|
source include/have_innodb.inc;
|
|
# Require Debug for SET DEBUG
|
|
source include/have_debug.inc;
|
|
# Not encrypted tables
|
|
source include/not_encrypted.inc;
|
|
# Test could open crash reporter on Windows
|
|
# if compiler set up
|
|
source include/not_windows.inc;
|
|
|
|
--disable_query_log
|
|
CALL mtr.add_suppression("\\[ERROR\\] \\[FATAL\\] InnoDB: Unable to read page \\[page id: space=.*, page number=.*\\] into the buffer pool after 100 attempts");
|
|
CALL mtr.add_suppression("\\[ERROR\\] InnoDB: Database page corruption on disk or a failed");
|
|
--enable_query_log
|
|
|
|
|
|
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=InnoDB;
|
|
INSERT INTO t1 (b) VALUES ('corrupt me');
|
|
--disable_query_log
|
|
--let $i = 10
|
|
while ($i)
|
|
{
|
|
INSERT INTO t1 (b) VALUES (REPEAT('abcdefghijklmnopqrstuvwxyz', 100));
|
|
dec $i;
|
|
}
|
|
--enable_query_log
|
|
INSERT INTO t1 (b) VALUES ('corrupt me');
|
|
|
|
let $MYSQLD_DATADIR=`select @@datadir`;
|
|
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
|
|
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
--echo # Backup the t1.ibd before corrupting
|
|
--copy_file $t1_IBD $MYSQLD_DATADIR/test/t1.ibd.backup
|
|
|
|
--echo # Corrupt the table
|
|
|
|
perl;
|
|
use strict;
|
|
use warnings;
|
|
use Fcntl qw(:DEFAULT :seek);
|
|
|
|
my $ibd_file = $ENV{'t1_IBD'};
|
|
|
|
my $chunk;
|
|
my $len;
|
|
|
|
sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file";
|
|
|
|
while ($len = sysread IBD_FILE, $chunk, 1024)
|
|
{
|
|
if ($chunk =~ s/corrupt me/korrupt me/)
|
|
{
|
|
print "Munged a string.\n";
|
|
sysseek IBD_FILE, -$len, SEEK_CUR;
|
|
syswrite IBD_FILE, $chunk, $len;
|
|
}
|
|
}
|
|
|
|
close IBD_FILE;
|
|
EOF
|
|
|
|
--source include/start_mysqld.inc
|
|
|
|
SET DEBUG_DBUG = '+d,innodb_page_corruption_retries';
|
|
|
|
--echo # Write file to make mysql-test-run.pl expect the "crash", but don't
|
|
--echo # start it until it's told to
|
|
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
|
|
--echo # The below SELECT query will crash the server because some pages
|
|
--echo # on the disk are corrupted
|
|
--error 2013
|
|
SELECT * FROM t1;
|
|
|
|
# The below mtr command --remove_file fails randomly on windows with
|
|
# error number 13 which is permission denied on nix systems. We sleep
|
|
# 1 second hoping that any process holding lock on t1.ibd is released.
|
|
SLEEP 1;
|
|
|
|
--echo # Restore the original t1.ibd
|
|
--remove_file $MYSQLD_DATADIR/test/t1.ibd
|
|
--move_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd
|
|
|
|
--source include/start_mysqld.inc
|
|
|
|
# Note SET DEBUG = '-d,innodb_page_corruption_retries' is not required
|
|
# because the session information is lost after server restart
|
|
|
|
--echo # Cleanup
|
|
DROP TABLE t1;
|