Browse Source
MDEV-31851 After crash recovery, undo tablespace fails to open
MDEV-31851 After crash recovery, undo tablespace fails to open
Problem: ======== - InnoDB fails to open undo tablespace when page0 is corrupted and fails to throw error. Solution: ========= - InnoDB throws DB_CORRUPTION error when InnoDB encounters page0 corruption of undo tablespace. - InnoDB restores the page0 of undo tablespace from doublewrite buffer if it encounters page corruption - Moved Datafile::restore_from_doublewrite() to recv_dblwr_t::restore_first_page(). So that undo tablespace and system tablespace can use this function instead of duplicating the code srv_undo_tablespace_open(): Returns 0 if file doesn't exist or ULINT_UNDEFINED if page0 is corrupted.pull/2799/head
11 changed files with 140 additions and 80 deletions
-
21mysql-test/suite/innodb/r/undo_space_dblwr.result
-
2mysql-test/suite/innodb/t/undo_space_dblwr.opt
-
47mysql-test/suite/innodb/t/undo_space_dblwr.test
-
2storage/innobase/buf/buf0dblwr.cc
-
58storage/innobase/fsp/fsp0file.cc
-
4storage/innobase/fsp/fsp0sysspace.cc
-
1storage/innobase/handler/ha_innodb.cc
-
5storage/innobase/include/fsp0file.h
-
9storage/innobase/include/log0recv.h
-
34storage/innobase/log/log0recv.cc
-
37storage/innobase/srv/srv0start.cc
@ -0,0 +1,21 @@ |
|||
call mtr.add_suppression("Checksum mismatch in the first page of file"); |
|||
show variables like 'innodb_doublewrite'; |
|||
Variable_name Value |
|||
innodb_doublewrite ON |
|||
create table t1(f1 int not null, f2 int not null)engine=innodb; |
|||
insert into t1 values (1, 1); |
|||
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; |
|||
InnoDB 0 transactions not purged |
|||
set GLOBAL innodb_log_checkpoint_now=1; |
|||
# Make the first page dirty for undo tablespace |
|||
set global innodb_saved_page_number_debug = 0; |
|||
set global innodb_fil_make_page_dirty_debug = 1; |
|||
SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0; |
|||
SET GLOBAL innodb_max_dirty_pages_pct=0.0; |
|||
# Kill the server |
|||
# restart |
|||
FOUND 1 /Checksum mismatch in the first page of file/ in mysqld.1.err |
|||
check table t1; |
|||
Table Op Msg_type Msg_text |
|||
test.t1 check status OK |
|||
drop table t1; |
@ -0,0 +1,2 @@ |
|||
--innodb_undo_tablespaces=3 |
|||
--innodb_sys_tablespaces |
@ -0,0 +1,47 @@ |
|||
--source include/have_innodb.inc |
|||
--source include/have_debug.inc |
|||
--source include/not_embedded.inc |
|||
call mtr.add_suppression("Checksum mismatch in the first page of file"); |
|||
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; |
|||
let MYSQLD_DATADIR=`select @@datadir`; |
|||
|
|||
show variables like 'innodb_doublewrite'; |
|||
create table t1(f1 int not null, f2 int not null)engine=innodb; |
|||
insert into t1 values (1, 1); |
|||
|
|||
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; |
|||
--source include/wait_all_purged.inc |
|||
|
|||
set GLOBAL innodb_log_checkpoint_now=1; |
|||
--source ../include/no_checkpoint_start.inc |
|||
|
|||
--echo # Make the first page dirty for undo tablespace |
|||
set global innodb_saved_page_number_debug = 0; |
|||
set global innodb_fil_make_page_dirty_debug = 1; |
|||
|
|||
SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0; |
|||
SET GLOBAL innodb_max_dirty_pages_pct=0.0; |
|||
|
|||
sleep 1; |
|||
--let CLEANUP_IF_CHECKPOINT=drop table t1; |
|||
--source ../include/no_checkpoint_end.inc |
|||
|
|||
perl; |
|||
use IO::Handle; |
|||
my $fname= "$ENV{'MYSQLD_DATADIR'}/undo001"; |
|||
my $page_size = $ENV{INNODB_PAGE_SIZE}; |
|||
die unless open(FILE, "+<", $fname); |
|||
sysread(FILE, $page, $page_size)==$page_size||die "Unable to read $name\n"; |
|||
substr($page, 49, 4) = pack("N", 1000); |
|||
sysseek(FILE, 0, 0)||die "Unable to seek $fname\n"; |
|||
die unless syswrite(FILE, $page, $page_size) == $page_size; |
|||
close FILE; |
|||
EOF |
|||
|
|||
--source include/start_mysqld.inc |
|||
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; |
|||
let SEARCH_PATTERN= Checksum mismatch in the first page of file; |
|||
--source include/search_pattern_in_file.inc |
|||
|
|||
check table t1; |
|||
drop table t1; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue