-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDEV-34898 Doublewrite recovery of innodb_checksum_algorithm=full_crc32 encrypted pages does not work #3691
Open
Thirunarayanan
wants to merge
1
commit into
10.6
Choose a base branch
from
10.6-MDEV-34898
base: 10.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\] in file .*"); | ||
create table t1 (f1 int primary key, f2 blob)page_compressed = 1 engine=innodb stats_persistent=0; | ||
create table t2(f1 int primary key, f2 blob)engine=innodb stats_persistent=0; | ||
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)); | ||
insert into t2 select * from t1; | ||
commit work; | ||
SET GLOBAL innodb_fast_shutdown = 0; | ||
# restart: --debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0 | ||
select space into @t1_space_id from information_schema.innodb_sys_tablespaces where name="test/t1"; | ||
select space into @t2_space_id from information_schema.innodb_sys_tablespaces where name="test/t2"; | ||
begin; | ||
insert into t1 values (6, repeat('%', 400)); | ||
insert into t2 values (6, repeat('%', 400)); | ||
set global innodb_saved_page_number_debug = 3; | ||
set global innodb_fil_make_page_dirty_debug = @t1_space_id; | ||
set global innodb_saved_page_number_debug = 3; | ||
set global innodb_fil_make_page_dirty_debug = @t2_space_id; | ||
set global innodb_buf_flush_list_now = 1; | ||
# Kill the server | ||
# restart | ||
FOUND 2 /InnoDB: Recovered page \[page id: space=[1-9]*, page number=3\]/ in mysqld.1.err | ||
check table t1; | ||
Table Op Msg_type Msg_text | ||
test.t1 check status OK | ||
check table t2; | ||
Table Op Msg_type Msg_text | ||
test.t2 check status OK | ||
select f1, f2 from t1; | ||
f1 f2 | ||
1 ############ | ||
2 ++++++++++++ | ||
3 //////////// | ||
4 ------------ | ||
5 ............ | ||
select f1, f2 from t2; | ||
f1 f2 | ||
1 ############ | ||
2 ++++++++++++ | ||
3 //////////// | ||
4 ------------ | ||
5 ............ | ||
drop table t2, t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--innodb-use-atomic-writes=0 | ||
--innodb-encrypt-tables=FORCE | ||
--innodb_sys_tablespaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--source include/have_innodb.inc | ||
--source include/have_debug.inc | ||
--source include/not_embedded.inc | ||
--source include/have_example_key_management_plugin.inc | ||
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\] in file .*"); | ||
|
||
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; | ||
let MYSQLD_DATADIR=`select @@datadir`; | ||
let ALGO=`select @@innodb_checksum_algorithm`; | ||
|
||
create table t1 (f1 int primary key, f2 blob)page_compressed = 1 engine=innodb stats_persistent=0; | ||
create table t2(f1 int primary key, f2 blob)engine=innodb stats_persistent=0; | ||
|
||
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)); | ||
insert into t2 select * from t1; | ||
commit work; | ||
|
||
# Slow shutdown and restart to make sure ibuf merge is finished | ||
SET GLOBAL innodb_fast_shutdown = 0; | ||
let $shutdown_timeout=; | ||
let $restart_parameters=--debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0; | ||
--source include/restart_mysqld.inc | ||
--source ../../suite/innodb/include/no_checkpoint_start.inc | ||
|
||
select space into @t1_space_id from information_schema.innodb_sys_tablespaces where name="test/t1"; | ||
select space into @t2_space_id from information_schema.innodb_sys_tablespaces where name="test/t2"; | ||
|
||
begin; | ||
insert into t1 values (6, repeat('%', 400)); | ||
insert into t2 values (6, repeat('%', 400)); | ||
|
||
set global innodb_saved_page_number_debug = 3; | ||
set global innodb_fil_make_page_dirty_debug = @t1_space_id; | ||
|
||
set global innodb_saved_page_number_debug = 3; | ||
set global innodb_fil_make_page_dirty_debug = @t2_space_id; | ||
|
||
set global innodb_buf_flush_list_now = 1; | ||
--let CLEANUP_IF_CHECKPOINT=drop table t1, t2, unexpected_checkpoint; | ||
--source ../../suite/innodb/include/no_checkpoint_end.inc | ||
|
||
# Corrupt the page 3 in t1.ibd, t2.ibd file | ||
perl; | ||
use IO::Handle; | ||
do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; | ||
my $polynomial = 0x82f63b78; # CRC-32C | ||
my $algo = $ENV{ALGO}; | ||
die "Unsupported innodb_checksum_algorithm=$algo\n" unless $algo =~ /crc32/; | ||
|
||
my $fname= "$ENV{'MYSQLD_DATADIR'}test/t1.ibd"; | ||
my $page_size = $ENV{INNODB_PAGE_SIZE}; | ||
my $page; | ||
do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; | ||
open(FILE, "+<", $fname) or die; | ||
sysseek(FILE, 3*$page_size, 0); | ||
sysread(FILE, $page, $page_size)==$page_size||die "Unable to read $name\n"; | ||
sysseek(FILE, 3*$page_size, 0)||die "Unable to seek $fname\n"; | ||
my $corrupted = $page; | ||
# Set FIL_PAGE_LSN to the maximum | ||
substr($corrupted, 16, 8) = chr(255) x 8; | ||
substr($corrupted, $page_size - 8, 8) = chr(255) x 8; | ||
if ($algo =~ /full_crc32/) | ||
{ | ||
my $ck = mycrc32(substr($corrupted, 0, $page_size - 4), 0, $polynomial); | ||
substr($corrupted, $page_size - 4, 4) = pack("N", $ck); | ||
} | ||
else | ||
{ | ||
# Replace the innodb_checksum_algorithm=crc32 checksum | ||
my $ck= pack("N", | ||
mycrc32(substr($corrupted, 4, 22), 0, $polynomial) ^ | ||
mycrc32(substr($corrupted_, 38, $page_size - 38 - 8), 0, | ||
$polynomial)); | ||
substr ($corrupted, 0, 4) = $ck; | ||
substr ($corrupted, $page_size - 8, 4) = $ck; | ||
} | ||
syswrite(FILE, $corrupted); | ||
close FILE; | ||
|
||
my $fname= "$ENV{'MYSQLD_DATADIR'}test/t2.ibd"; | ||
open(FILE, "+<", $fname) or die; | ||
FILE->autoflush(1); | ||
binmode FILE; | ||
seek(FILE, 3 * $ENV{'INNODB_PAGE_SIZE'}, SEEK_SET); | ||
print FILE chr(0) x ($ENV{'INNODB_PAGE_SIZE'}); | ||
close FILE; | ||
EOF | ||
|
||
# Successful recover from doublewrite buffer | ||
let $restart_parameters=; | ||
--source include/start_mysqld.inc | ||
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; | ||
let SEARCH_PATTERN=InnoDB: Recovered page \\[page id: space=[1-9]*, page number=3\\]; | ||
--source include/search_pattern_in_file.inc | ||
|
||
check table t1; | ||
check table t2; | ||
select f1, f2 from t1; | ||
select f1, f2 from t2; | ||
drop table t2, t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked that
FIL_PAGE_LSN
is not encrypted on the page. Therefore, we should be able to corrupt just that (for example, writechr(255) x 8
, which will be newer than end of the log) and recompute the checksum. I think that it would be more interesting than this "totally corrupted" page.Can you please also do a test variant that corrupts this page in the doublewrite buffer, with an LSN that is before the checkpoint? That should lead to InnoDB crash recovery failing. Better make it two attempts: also with an LSN that is after the end of the log.