Skip to content

Commit 13f7409

Browse files
committed
MDEV-12112/MDEV-12026: Enable the test for full_crc32
The test mariabackup.encrypted_page_corruption was hard-wired for innodb_checksum_algorithm=crc32. Enable a combination for full_crc32 for the sake of completeness.
1 parent fe4a4bb commit 13f7409

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--- encrypted_page_corruption,crc32.result
2+
+++ encrypted_page_corruption,full_crc32.result
3+
@@ -5,5 +5,5 @@
4+
# Corrupt the table
5+
# restart
6+
# xtrabackup backup
7+
-FOUND 1 /Database page corruption detected.*/ in backup.log
8+
+NOT FOUND /Database page corruption detected.*/ in backup.log
9+
drop table t1;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[crc32]
2+
--innodb-checksum-algorithm=crc32
3+
4+
[full_crc32]
5+
--innodb-checksum-algorithm=full_crc32

mysql-test/suite/mariabackup/encrypted_page_corruption.opt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
--loose-file-key-management-filekey=FILE:$MTR_SUITE_DIR/filekeys-data.key
55
--loose-file-key-management-filename=$MTR_SUITE_DIR/filekeys-data.enc
66
--loose-file-key-management-encryption-algorithm=aes_cbc
7-
--innodb-checksum-algorithm=crc32

mysql-test/suite/mariabackup/encrypted_page_corruption.test

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,36 @@ use warnings;
1919
use Fcntl qw(:DEFAULT :seek);
2020
do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
2121

22-
my $page_size = $ENV{INNODB_PAGE_SIZE};
22+
my $ps = $ENV{INNODB_PAGE_SIZE};
2323

2424
sysopen IBD_FILE, "$ENV{MYSQLD_DATADIR}/test/t1.ibd", O_RDWR
2525
|| die "Cannot open t1.ibd\n";
26-
sysread(IBD_FILE, $_, 38) || die "Cannot read t1.ibd\n";
26+
sysread(IBD_FILE, $_, 58) || die "Cannot read t1.ibd\n";
2727
my $space = unpack("x[34]N", $_);
28-
sysseek(IBD_FILE, $page_size * 3, SEEK_SET) || die "Cannot seek t1.ibd\n";
28+
my $full_crc32 = unpack("N",substr($_,54,4)) & 0x10; # FIL_SPACE_FLAGS
29+
sysseek(IBD_FILE, $ps * 3, SEEK_SET) || die "Cannot seek t1.ibd\n";
2930

30-
my $head = pack("Nx[18]", 3); # better to have a valid page number
31-
my $body = chr(0) x ($page_size - 38 - 8);
31+
# better to have a valid page number (3)
32+
my $page = pack("x[4]Nx[18]Nx[4]N", 3, 1, $space) . chr(0) x ($ps - 38);
3233

33-
# Calculate innodb_checksum_algorithm=crc32 for the unencrypted page.
34-
# The following bytes are excluded:
35-
# bytes 0..3 (the checksum is stored there)
36-
# bytes 26..37 (encryption key version, post-encryption checksum, tablespace id)
37-
# bytes $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN)
3834
my $polynomial = 0x82f63b78; # CRC-32C
39-
my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial);
40-
41-
my $page= pack("N",$ck).$head.pack("NNN",1,$ck,$space).$body.pack("Nx[4]",$ck);
42-
die unless syswrite(IBD_FILE, $page, $page_size) == $page_size;
35+
if ($full_crc32)
36+
{
37+
# no possibility of bug here
38+
my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial);
39+
substr($page, $ps - 4, 4) = pack("N", $ck);
40+
}
41+
else
42+
{
43+
my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
44+
mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
45+
substr($page,0,4)=$ck;
46+
substr($page,$ps-8,4)=$ck;
47+
# trigger the bug by having the same "post-encryption" checksum!
48+
substr($page,30,4)=$ck;
49+
}
50+
51+
die unless syswrite(IBD_FILE, $page, $ps) == $ps;
4352
close IBD_FILE;
4453
EOF
4554

@@ -49,8 +58,13 @@ echo # xtrabackup backup;
4958
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
5059
let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;
5160

61+
let $expect_error= 1;
62+
if (`select @@innodb_checksum_algorithm LIKE '%full_crc32'`)
63+
{
64+
let $expect_error= 0;
65+
}
5266
--disable_result_log
53-
--error 1
67+
--error $expect_error
5468
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extended-validation --target-dir=$targetdir --core-file > $backuplog;
5569
--enable_result_log
5670

0 commit comments

Comments
 (0)