2017-08-11 16:42:27 +03:00
|
|
|
--source include/not_embedded.inc
|
2018-01-11 10:56:13 +02:00
|
|
|
--source include/have_file_key_management.inc
|
2017-08-11 16:42:27 +03:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-13416 mariabackup fails with EFAULT "Bad Address"
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
|
|
|
|
let MYSQLD_DATADIR=`select @@datadir`;
|
|
|
|
|
2020-07-14 13:22:59 +05:30
|
|
|
let $targetdir_old=$MYSQLTEST_VARDIR/tmp/backup_1;
|
|
|
|
--disable_result_log
|
|
|
|
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir_old;
|
|
|
|
--enable_result_log
|
2017-08-11 16:42:27 +03:00
|
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
|
|
|
|
perl;
|
2019-02-16 12:06:52 +02:00
|
|
|
do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
|
2017-08-11 16:42:27 +03:00
|
|
|
my $file= "$ENV{MYSQLD_DATADIR}/ibdata1";
|
|
|
|
open(FILE, "+<", $file) or die "Unable to open $file\n";
|
|
|
|
binmode FILE;
|
|
|
|
my $ps= $ENV{INNODB_PAGE_SIZE};
|
|
|
|
my $page;
|
|
|
|
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
|
2018-01-08 09:24:13 +02:00
|
|
|
substr($page,26,8) = pack("NN", 4096, ~1024);
|
2019-02-16 12:06:52 +02:00
|
|
|
my $polynomial = 0x82f63b78; # CRC-32C
|
MDEV-12026: Implement innodb_checksum_algorithm=full_crc32
MariaDB data-at-rest encryption (innodb_encrypt_tables)
had repurposed the same unused data field that was repurposed
in MySQL 5.7 (and MariaDB 10.2) for the Split Sequence Number (SSN)
field of SPATIAL INDEX. Because of this, MariaDB was unable to
support encryption on SPATIAL INDEX pages.
Furthermore, InnoDB page checksums skipped some bytes, and there
are multiple variations and checksum algorithms. By default,
InnoDB accepts all variations of all algorithms that ever existed.
This unnecessarily weakens the page checksums.
We hereby introduce two more innodb_checksum_algorithm variants
(full_crc32, strict_full_crc32) that are special in a way:
When either setting is active, newly created data files will
carry a flag (fil_space_t::full_crc32()) that indicates that
all pages of the file will use a full CRC-32C checksum over the
entire page contents (excluding the bytes where the checksum
is stored, at the very end of the page). Such files will always
use that checksum, no matter what the parameter
innodb_checksum_algorithm is assigned to.
For old files, the old checksum algorithms will continue to be
used. The value strict_full_crc32 will be equivalent to strict_crc32
and the value full_crc32 will be equivalent to crc32.
ROW_FORMAT=COMPRESSED tables will only use the old format.
These tables do not support new features, such as larger
innodb_page_size or instant ADD/DROP COLUMN. They may be
deprecated in the future. We do not want an unnecessary
file format change for them.
The new full_crc32() format also cleans up the MariaDB tablespace
flags. We will reserve flags to store the page_compressed
compression algorithm, and to store the compressed payload length,
so that checksum can be computed over the compressed (and
possibly encrypted) stream and can be validated without
decrypting or decompressing the page.
In the full_crc32 format, there no longer are separate before-encryption
and after-encryption checksums for pages. The single checksum is
computed on the page contents that is written to the file.
We do not make the new algorithm the default for two reasons.
First, MariaDB 10.4.2 was a beta release, and the default values
of parameters should not change after beta. Second, we did not
yet implement the full_crc32 format for page_compressed pages.
This will be fixed in MDEV-18644.
This is joint work with Marko Mäkelä.
2019-02-19 21:00:00 +02:00
|
|
|
my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS
|
|
|
|
if ($full_crc32)
|
|
|
|
{
|
|
|
|
my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial);
|
|
|
|
substr($page, $ps-4, 4) = pack("N", $ck);
|
|
|
|
}
|
2017-08-11 16:42:27 +03:00
|
|
|
sysseek(FILE, 0, 0) || die "Unable to rewind $file\n";
|
|
|
|
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
|
|
|
|
close(FILE) || die "Unable to close $file\n";
|
|
|
|
EOF
|
|
|
|
|
|
|
|
--remove_files_wildcard $MYSQLD_DATADIR ib_logfile*
|
|
|
|
|
|
|
|
--source include/start_mysqld.inc
|
|
|
|
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
|
2020-01-12 02:05:28 +07:00
|
|
|
--let SEARCH_PATTERN= InnoDB: New log file created, LSN=175964\d{8}
|
2017-08-11 16:42:27 +03:00
|
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
|
2022-06-09 10:57:28 +03:00
|
|
|
CREATE TABLE t(i INT) ENGINE=INNODB ENCRYPTED=YES;
|
2017-08-11 16:42:27 +03:00
|
|
|
INSERT INTO t VALUES(1);
|
|
|
|
|
|
|
|
echo # xtrabackup backup;
|
|
|
|
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
|
|
|
|
--disable_result_log
|
|
|
|
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
|
|
|
|
--enable_result_log
|
2018-01-08 17:09:21 +02:00
|
|
|
SET GLOBAL innodb_flush_log_at_trx_commit=1;
|
2017-08-11 16:42:27 +03:00
|
|
|
INSERT INTO t VALUES(2);
|
|
|
|
echo # xtrabackup prepare;
|
|
|
|
--disable_result_log
|
|
|
|
exec $XTRABACKUP --prepare --target-dir=$targetdir;
|
|
|
|
--source include/restart_and_restore.inc
|
|
|
|
--enable_result_log
|
|
|
|
SELECT * FROM t;
|
2022-06-09 10:57:28 +03:00
|
|
|
FLUSH TABLE t FOR EXPORT;
|
|
|
|
copy_file $_datadir/test/t.ibd $_datadir/test/t_copy.ibd;
|
|
|
|
copy_file $_datadir/test/t.cfg $_datadir/test/t_copy.cfg;
|
|
|
|
UNLOCK TABLES;
|
|
|
|
ALTER TABLE t DISCARD TABLESPACE;
|
|
|
|
move_file $_datadir/test/t_copy.ibd $_datadir/test/t.ibd;
|
|
|
|
move_file $_datadir/test/t_copy.cfg $_datadir/test/t.cfg;
|
|
|
|
ALTER TABLE t IMPORT TABLESPACE;
|
|
|
|
FLUSH TABLE t FOR EXPORT;
|
|
|
|
copy_file $_datadir/test/t.ibd $_datadir/test/t_copy.ibd;
|
|
|
|
copy_file $_datadir/test/t.cfg $_datadir/test/t_copy.cfg;
|
|
|
|
UNLOCK TABLES;
|
|
|
|
ALTER TABLE t DISCARD TABLESPACE;
|
|
|
|
move_file $_datadir/test/t_copy.ibd $_datadir/test/t.ibd;
|
|
|
|
move_file $_datadir/test/t_copy.cfg $_datadir/test/t.cfg;
|
|
|
|
ALTER TABLE t IMPORT TABLESPACE;
|
2017-08-11 16:42:27 +03:00
|
|
|
DROP TABLE t;
|
|
|
|
rmdir $targetdir;
|
2020-07-14 13:22:59 +05:30
|
|
|
let $targetdir= $targetdir_old;
|
|
|
|
exec $XTRABACKUP --prepare --target-dir=$targetdir;
|
|
|
|
--source include/restart_and_restore.inc
|
|
|
|
rmdir $targetdir_old;
|