summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-09-10 12:43:48 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-09-10 12:43:48 +0300
commit13f740904a389f03d3c075fee0b91ecfcc0de60b (patch)
tree96539ae71dd9cbf9374316d7d3e899d3c065fcb0
parentfe4a4bb0a4bd11990f2701f2715638e139c1be53 (diff)
downloadmariadb-git-13f740904a389f03d3c075fee0b91ecfcc0de60b.tar.gz
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.
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_corruption,full_crc32.rdiff9
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_corruption.combinations5
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_corruption.opt1
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_corruption.test44
4 files changed, 43 insertions, 16 deletions
diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption,full_crc32.rdiff b/mysql-test/suite/mariabackup/encrypted_page_corruption,full_crc32.rdiff
new file mode 100644
index 00000000000..3326f0ca3d3
--- /dev/null
+++ b/mysql-test/suite/mariabackup/encrypted_page_corruption,full_crc32.rdiff
@@ -0,0 +1,9 @@
+--- encrypted_page_corruption,crc32.result
++++ encrypted_page_corruption,full_crc32.result
+@@ -5,5 +5,5 @@
+ # Corrupt the table
+ # restart
+ # xtrabackup backup
+-FOUND 1 /Database page corruption detected.*/ in backup.log
++NOT FOUND /Database page corruption detected.*/ in backup.log
+ drop table t1;
diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.combinations b/mysql-test/suite/mariabackup/encrypted_page_corruption.combinations
new file mode 100644
index 00000000000..79e5f7836ed
--- /dev/null
+++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.combinations
@@ -0,0 +1,5 @@
+[crc32]
+--innodb-checksum-algorithm=crc32
+
+[full_crc32]
+--innodb-checksum-algorithm=full_crc32
diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.opt b/mysql-test/suite/mariabackup/encrypted_page_corruption.opt
index bc6d53b6dd9..74a6450a1ef 100644
--- a/mysql-test/suite/mariabackup/encrypted_page_corruption.opt
+++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.opt
@@ -4,4 +4,3 @@
--loose-file-key-management-filekey=FILE:$MTR_SUITE_DIR/filekeys-data.key
--loose-file-key-management-filename=$MTR_SUITE_DIR/filekeys-data.enc
--loose-file-key-management-encryption-algorithm=aes_cbc
---innodb-checksum-algorithm=crc32
diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.test b/mysql-test/suite/mariabackup/encrypted_page_corruption.test
index 5ba77597b35..1beb020b463 100644
--- a/mysql-test/suite/mariabackup/encrypted_page_corruption.test
+++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.test
@@ -19,27 +19,36 @@ use warnings;
use Fcntl qw(:DEFAULT :seek);
do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
-my $page_size = $ENV{INNODB_PAGE_SIZE};
+my $ps = $ENV{INNODB_PAGE_SIZE};
sysopen IBD_FILE, "$ENV{MYSQLD_DATADIR}/test/t1.ibd", O_RDWR
|| die "Cannot open t1.ibd\n";
-sysread(IBD_FILE, $_, 38) || die "Cannot read t1.ibd\n";
+sysread(IBD_FILE, $_, 58) || die "Cannot read t1.ibd\n";
my $space = unpack("x[34]N", $_);
-sysseek(IBD_FILE, $page_size * 3, SEEK_SET) || die "Cannot seek t1.ibd\n";
+my $full_crc32 = unpack("N",substr($_,54,4)) & 0x10; # FIL_SPACE_FLAGS
+sysseek(IBD_FILE, $ps * 3, SEEK_SET) || die "Cannot seek t1.ibd\n";
-my $head = pack("Nx[18]", 3); # better to have a valid page number
-my $body = chr(0) x ($page_size - 38 - 8);
+# better to have a valid page number (3)
+my $page = pack("x[4]Nx[18]Nx[4]N", 3, 1, $space) . chr(0) x ($ps - 38);
-# Calculate innodb_checksum_algorithm=crc32 for the unencrypted page.
-# The following bytes are excluded:
-# bytes 0..3 (the checksum is stored there)
-# bytes 26..37 (encryption key version, post-encryption checksum, tablespace id)
-# bytes $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN)
my $polynomial = 0x82f63b78; # CRC-32C
-my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial);
-
-my $page= pack("N",$ck).$head.pack("NNN",1,$ck,$space).$body.pack("Nx[4]",$ck);
-die unless syswrite(IBD_FILE, $page, $page_size) == $page_size;
+if ($full_crc32)
+{
+ # no possibility of bug here
+ my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial);
+ substr($page, $ps - 4, 4) = pack("N", $ck);
+}
+else
+{
+ my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
+ mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
+ substr($page,0,4)=$ck;
+ substr($page,$ps-8,4)=$ck;
+ # trigger the bug by having the same "post-encryption" checksum!
+ substr($page,30,4)=$ck;
+}
+
+die unless syswrite(IBD_FILE, $page, $ps) == $ps;
close IBD_FILE;
EOF
@@ -49,8 +58,13 @@ echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;
+let $expect_error= 1;
+if (`select @@innodb_checksum_algorithm LIKE '%full_crc32'`)
+{
+ let $expect_error= 0;
+}
--disable_result_log
---error 1
+--error $expect_error
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extended-validation --target-dir=$targetdir --core-file > $backuplog;
--enable_result_log