Commit 195241e1 authored by Marko Mäkelä's avatar Marko Mäkelä

Port the test innodb.doublewrite from MySQL 5.7.

parent 44da95e5
--let $_server_id= `SELECT @@server_id`
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
--echo # Kill the server
--exec echo "wait" > $_expect_file_name
--shutdown_server 0
--source include/wait_until_disconnected.inc
# Check that the latest checkpoint in the redo log files
# is not newer than the checkpoint sampled by no_checkpoint_start.inc
--source include/kill_mysqld.inc
perl;
my $cp = $ENV{CHECKPOINT_LSN};
$cp =~ s/^InnoDB\t\t//;
my $log = "$ENV{MYSQLD_DATADIR}ib_logfile0";
open(LOG, "<$log") || die "Unable to open $log";
seek(LOG, 512, 0) || die "Unable to seek $log";
die unless read(LOG, $_, 16) == 16;
my ($no1hi,$no1lo,$cp1hi,$cp1lo) = unpack("N*", $_);
seek(LOG, 3 * 512, 0) || die "Unable to seek $log";
die unless read(LOG, $_, 16) == 16;
my ($no2hi,$no2lo,$cp2hi,$cp2lo) = unpack("N*", $_);
close(LOG);
my $cp1 = $cp1hi << 32 | $cp1lo;
my $cp2 = $cp2hi << 32 | $cp2lo;
open(OUT, ">$ENV{MYSQLTEST_VARDIR}/log/check.txt") || die;
if ($cp1 > $cp || $cp2 > $cp) {
print OUT "--source include/start_mysqld.inc\n";
print OUT "$ENV{CLEANUP_IF_CHECKPOINT}\n";
print OUT "--skip Extra checkpoint 1 after $cp";
print OUT " ($no1hi:$no1lo=$cp1,$no2hi:$no2lo=$cp2)\n";
}
close(OUT);
EOF
--source $MYSQLTEST_VARDIR/log/check.txt
--remove_file $MYSQLTEST_VARDIR/log/check.txt
# Preparation for using no_checkpoint_end.inc
let MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /.*Last checkpoint at[ ]*([0-9]+).*/\1/
let CHECKPOINT_LSN=`SHOW ENGINE INNODB STATUS`;
#
# Bug #17335427 INNODB CAN NOT USE THE DOUBLEWRITE BUFFER PROPERLY
# Bug #18144349 INNODB CANNOT USE THE DOUBLEWRITE BUFFER FOR THE FIRST
# PAGE OF SYSTEM TABLESPACE
#
SET GLOBAL innodb_fast_shutdown = 0;
show variables like 'innodb_doublewrite';
Variable_name Value
innodb_doublewrite ON
show variables like 'innodb_fil_make_page_dirty_debug';
Variable_name Value
innodb_fil_make_page_dirty_debug 0
show variables like 'innodb_saved_page_number_debug';
Variable_name Value
innodb_saved_page_number_debug 0
create table t1 (f1 int primary key, f2 blob) engine=innodb;
start transaction;
insert into t1 values(1, repeat('#',12));
insert into t1 values(2, repeat('+',12));
insert into t1 values(3, repeat('/',12));
insert into t1 values(4, repeat('-',12));
insert into t1 values(5, repeat('.',12));
commit work;
# ---------------------------------------------------------------
# Test Begin: Test if recovery works if first page of user
# tablespace is full of zeroes.
select space from information_schema.innodb_sys_tables
where name = 'test/t1' into @space_id;
# Ensure that dirty pages of table t1 is flushed.
flush tables t1 for export;
unlock tables;
begin;
insert into t1 values (6, repeat('%', 12));
# Make the first page dirty for table t1
set global innodb_saved_page_number_debug = 0;
set global innodb_fil_make_page_dirty_debug = @space_id;
# Ensure that dirty pages of table t1 are flushed.
set global innodb_buf_flush_list_now = 1;
# Kill the server
# Make the first page (page_no=0) of the user tablespace
# full of zeroes.
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select f1, f2 from t1;
f1 f2
1 ############
2 ++++++++++++
3 ////////////
4 ------------
5 ............
# Test End
# ---------------------------------------------------------------
# Test Begin: Test if recovery works if first page of user
# tablespace is corrupted.
select space from information_schema.innodb_sys_tables
where name = 'test/t1' into @space_id;
# Ensure that dirty pages of table t1 is flushed.
flush tables t1 for export;
unlock tables;
begin;
insert into t1 values (6, repeat('%', 12));
# Make the first page dirty for table t1
set global innodb_saved_page_number_debug = 0;
set global innodb_fil_make_page_dirty_debug = @space_id;
# Ensure that dirty pages of table t1 are flushed.
set global innodb_buf_flush_list_now = 1;
# Kill the server
# Corrupt the first page (page_no=0) of the user tablespace.
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select f1, f2 from t1;
f1 f2
1 ############
2 ++++++++++++
3 ////////////
4 ------------
5 ............
# Test End
# ---------------------------------------------------------------
# Test Begin: Test if recovery works if 2nd page of user
# tablespace is full of zeroes.
select space from information_schema.innodb_sys_tables
where name = 'test/t1' into @space_id;
# Ensure that dirty pages of table t1 is flushed.
flush tables t1 for export;
unlock tables;
begin;
insert into t1 values (6, repeat('%', 400));
# Make the 2nd page dirty for table t1
set global innodb_saved_page_number_debug = 1;
set global innodb_fil_make_page_dirty_debug = @space_id;
# Ensure that dirty pages of table t1 are flushed.
set global innodb_buf_flush_list_now = 1;
# Kill the server
# Make the 2nd page (page_no=1) of the tablespace all zeroes.
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select f1, f2 from t1;
f1 f2
1 ############
2 ++++++++++++
3 ////////////
4 ------------
5 ............
# Test End
# ---------------------------------------------------------------
# Test Begin: Test if recovery works if 2nd page of user
# tablespace is corrupted.
select space from information_schema.innodb_sys_tables
where name = 'test/t1' into @space_id;
# Ensure that dirty pages of table t1 is flushed.
flush tables t1 for export;
unlock tables;
begin;
insert into t1 values (6, repeat('%', 400));
# Make the 2nd page dirty for table t1
set global innodb_saved_page_number_debug = 1;
set global innodb_fil_make_page_dirty_debug = @space_id;
# Ensure that the dirty pages of table t1 are flushed.
set global innodb_buf_flush_list_now = 1;
# Kill the server
# Corrupt the 2nd page (page_no=1) of the user tablespace.
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select f1, f2 from t1;
f1 f2
1 ############
2 ++++++++++++
3 ////////////
4 ------------
5 ............
# Test End
# ---------------------------------------------------------------
# Test Begin: Test if recovery works if first page of
# system tablespace is full of zeroes.
begin;
insert into t1 values (6, repeat('%', 400));
# Ensure that all dirty pages in the system are flushed.
set global innodb_buf_flush_list_now = 1;
# Make the first page dirty for system tablespace
set global innodb_saved_page_number_debug = 0;
set global innodb_fil_make_page_dirty_debug = 0;
# Ensure that the dirty page of system tablespace is also flushed.
set global innodb_buf_flush_list_now = 1;
# Kill the server
# Make the first page (page_no=0) of the system tablespace
# all zeroes.
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select f1, f2 from t1;
f1 f2
1 ############
2 ++++++++++++
3 ////////////
4 ------------
5 ............
# Test End
# ---------------------------------------------------------------
# Test Begin: Test if recovery works if first page of
# system tablespace is corrupted.
begin;
insert into t1 values (6, repeat('%', 400));
# Ensure that all dirty pages in the system are flushed.
set global innodb_buf_flush_list_now = 1;
# Make the first page dirty for system tablespace
set global innodb_saved_page_number_debug = 0;
set global innodb_fil_make_page_dirty_debug = 0;
# Ensure that the dirty page of system tablespace is also flushed.
set global innodb_buf_flush_list_now = 1;
# Kill the server
# Corrupt the first page (page_no=0) of the system tablespace.
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select f1, f2 from t1;
f1 f2
1 ############
2 ++++++++++++
3 ////////////
4 ------------
5 ............
# Test End
# ---------------------------------------------------------------
# Test Begin: Test if recovery works if 2nd page of
# system tablespace is full of zeroes.
begin;
insert into t1 values (6, repeat('%', 400));
# Ensure that all dirty pages in the system are flushed.
set global innodb_buf_flush_list_now = 1;
# Make the second page dirty for system tablespace
set global innodb_saved_page_number_debug = 1;
set global innodb_fil_make_page_dirty_debug = 0;
# Ensure that the dirty page of system tablespace is also flushed.
set global innodb_buf_flush_list_now = 1;
# Kill the server
# Make the 2nd page (page_no=1) of the system tablespace
# all zeroes.
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select f1, f2 from t1;
f1 f2
1 ############
2 ++++++++++++
3 ////////////
4 ------------
5 ............
# Test End
# ---------------------------------------------------------------
# Test Begin: Test if recovery works if 2nd page of
# system tablespace is corrupted.
begin;
insert into t1 values (6, repeat('%', 400));
# Ensure that all dirty pages in the system are flushed.
set global innodb_buf_flush_list_now = 1;
# Make the second page dirty for system tablespace
set global innodb_saved_page_number_debug = 1;
set global innodb_fil_make_page_dirty_debug = 0;
# Ensure that the dirty page of system tablespace is also flushed.
set global innodb_buf_flush_list_now = 1;
# Kill the server
# Make the 2nd page (page_no=1) of the system tablespace
# all zeroes.
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select f1, f2 from t1;
f1 f2
1 ############
2 ++++++++++++
3 ////////////
4 ------------
5 ............
# Test End
# ---------------------------------------------------------------
drop table t1;
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment