diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/suite/mariabackup | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/suite/mariabackup')
214 files changed, 6312 insertions, 0 deletions
diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt b/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt new file mode 100644 index 00000000..49297a84 --- /dev/null +++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt @@ -0,0 +1,3 @@ +--innodb --innodb-data-home-dir= --innodb-data-file-path=$MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1:6M;ibdata_second:1M:autoextend +--innodb-undo-tablespaces=2 +--innodb-checksum-algorithm=crc32 diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.result b/mysql-test/suite/mariabackup/absolute_ibdata_paths.result new file mode 100644 index 00000000..a29d9af6 --- /dev/null +++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.result @@ -0,0 +1,12 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# restart +# xtrabackup backup +# remove datadir +# xtrabackup copy back +# restart server +# restart +SELECT * from t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.test b/mysql-test/suite/mariabackup/absolute_ibdata_paths.test new file mode 100644 index 00000000..fa304f0b --- /dev/null +++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.test @@ -0,0 +1,51 @@ +# This test just backs up and restores empty database +# Innodb system tablespace is specified with absolute path in the .opt file +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); + +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; +let MYSQLD_DATADIR= `SELECT @@datadir`; +--source include/shutdown_mysqld.inc +perl; +my $file= "$ENV{MYSQLD_DATADIR}/ibdata_second"; +open(FILE, "+<", $file) or die "Unable to open $file\n"; +binmode FILE; +my $ps= $ENV{INNODB_PAGE_SIZE}; +my $page; +my $pos = $ps * 0; +sysseek(FILE, $pos, 0) || die "Unable to seek $file\n"; +die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; +substr($page,26,8) = pack("NN", 1, 1); +sysseek(FILE, $pos, 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 + +--source include/start_mysqld.inc + +echo # xtrabackup backup; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $_innodb_data_file_path=`select @@innodb_data_file_path`; +let $_innodb_data_home_dir=`select @@innodb_data_home_dir`; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; + +--source include/shutdown_mysqld.inc +echo # remove datadir; +rmdir $MYSQLD_DATADIR; +#remove out-of-datadir ibdata1 +remove_file $MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1; +echo # xtrabackup copy back; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$MYSQLD_DATADIR --target-dir=$targetdir "--innodb_data_file_path=$_innodb_data_file_path" --innodb_data_home_dir=$_innodb_data_home_dir; +echo # restart server; +--source include/start_mysqld.inc +--enable_result_log + +SELECT * from t; +DROP TABLE t; +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/alter_copy_excluded.opt b/mysql-test/suite/mariabackup/alter_copy_excluded.opt new file mode 100644 index 00000000..56434e88 --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_excluded.opt @@ -0,0 +1 @@ +--loose-innodb_sys_tablespaces diff --git a/mysql-test/suite/mariabackup/alter_copy_excluded.result b/mysql-test/suite/mariabackup/alter_copy_excluded.result new file mode 100644 index 00000000..45181e35 --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_excluded.result @@ -0,0 +1,24 @@ +# xtrabackup backup +CREATE TABLE t1(i int, t text, fulltext index(t)) ENGINE=InnoDB; +INSERT into t1 values(1,'foo'); +connect con2, localhost, root,,; +connection con2; +SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit' ; +SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 DROP t, algorithm=COPY;| +connection default; +connection con2; +SET debug_sync='RESET'; +disconnect con2; +connection default; +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t1; +i t +1 foo +DROP TABLE t1; +SELECT * FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%' or name like 'test/%'; +SPACE NAME FLAG ROW_FORMAT PAGE_SIZE FILENAME FS_BLOCK_SIZE FILE_SIZE ALLOCATED_SIZE +# restart diff --git a/mysql-test/suite/mariabackup/alter_copy_excluded.test b/mysql-test/suite/mariabackup/alter_copy_excluded.test new file mode 100644 index 00000000..599fb46b --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_excluded.test @@ -0,0 +1,66 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +# The test demonstrates that intermediate tables (ALTER TABLE...ALGORITHM=COPY) +# will not be included in a backup. + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE t1(i int, t text, fulltext index(t)) ENGINE=InnoDB; +INSERT into t1 values(1,'foo'); + +connect con2, localhost, root,,; +connection con2; +SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit' ; +DELIMITER |; +send SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 DROP t, algorithm=COPY;| +DELIMITER ;| +connection default; + +# Setup mariabackup events +# - After BACKUP STAGE START , let concurrent ALTER run, wand wait for it to create temporary tables +# - After BACKUP STAGE COMMIT, check that temporary files are in the database + +let after_backup_stage_start=SET debug_sync='now SIGNAL after_backup_stage_start WAIT_FOR go'; +DELIMITER |; +# The following query only works if there are innodb "intermediate" tables +# in the system tables , which we want to prove there +let after_backup_stage_block_commit= + IF (SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%') THEN + SET debug_sync='now SIGNAL after_backup_stage_block_commit'; + END IF| +DELIMITER ;| + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +# There should be no temp files in the backup. +--list_files $targetdir/test #sql* + +connection con2; +#Wait for ALTER to finish, cleanup +reap; +SET debug_sync='RESET'; +disconnect con2; + +connection default; +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +# Check there are no temp tablespaces in sys_tablespaces, after backup +SELECT * FROM t1; +DROP TABLE t1; +SELECT * FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%' or name like 'test/%'; + +# Restart once again to clear first_start_after_backup flag +# This is to catch potential warnings, since "missing file" for #sql is suppressed +# during the first start after backup +--source include/restart_mysqld.inc + +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/alter_copy_race.result b/mysql-test/suite/mariabackup/alter_copy_race.result new file mode 100644 index 00000000..82202249 --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_race.result @@ -0,0 +1,24 @@ +# xtrabackup backup +CREATE TABLE t1(i int) ENGINE=InnoDB; +INSERT into t1 values(1); +connect con2, localhost, root,,; +connection con2; +set lock_wait_timeout=1; +SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit'; +SET debug_sync='alter_table_after_temp_table_drop SIGNAL temp_table_dropped'; +SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;| +connection default; +connection con2; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET debug_sync='RESET'; +disconnect con2; +connection default; +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t1; +i +1 +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/alter_copy_race.test b/mysql-test/suite/mariabackup/alter_copy_race.test new file mode 100644 index 00000000..553643bf --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_race.test @@ -0,0 +1,51 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +# The test demonstrates that intermediate tables (ALTER TABLE...ALGORITHM=COPY) +# are not always properly locked, e.g., can be dropped after +# BACKUP STAGE BLOCK_COMMIT +# succeeded. +# Thus mariabackup decides not to have them in backup at all, +# since they keep changing even after the backup LSN was determined. + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE t1(i int) ENGINE=InnoDB; +INSERT into t1 values(1); + +connect con2, localhost, root,,; +connection con2; +set lock_wait_timeout=1; +SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit'; +SET debug_sync='alter_table_after_temp_table_drop SIGNAL temp_table_dropped'; +DELIMITER |; +send SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;| +DELIMITER ;| +connection default; + +# setup mariabackup events +let after_backup_stage_start=SET debug_sync='now SIGNAL after_backup_stage_start WAIT_FOR go'; +let after_backup_stage_block_commit=SET debug_sync='now SIGNAL after_backup_stage_block_commit'; +let backup_fix_ddl=SET debug_sync='now WAIT_FOR temp_table_dropped'; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +connection con2; +--error ER_LOCK_WAIT_TIMEOUT +reap; +SET debug_sync='RESET'; +disconnect con2; + +connection default; +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t1; +DROP TABLE t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/apply-log-only-incr.result b/mysql-test/suite/mariabackup/apply-log-only-incr.result new file mode 100644 index 00000000..f84e8ea5 --- /dev/null +++ b/mysql-test/suite/mariabackup/apply-log-only-incr.result @@ -0,0 +1,37 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t(a INT UNSIGNED PRIMARY KEY) ENGINE INNODB; +INSERT INTO t VALUES(0); +COMMIT; +start transaction; +connect flush_log,localhost,root,,; +BEGIN; +DELETE FROM t LIMIT 1; +SET GLOBAL innodb_flush_log_at_trx_commit = 1; +ROLLBACK; +disconnect flush_log; +connection default; +NOT FOUND /Rolled back recovered transaction/ in current_test +# expect NOT FOUND +NOT FOUND /Rolled back recovered transaction/ in current_test +# expect NOT FOUND +commit; +SELECT count(*) FROM t; +count(*) +201 +# Restore and check results +# shutdown server +# remove datadir +# xtrabackup move back +# restart: --innodb-force-recovery=3 +SELECT COUNT(*) FROM t; +COUNT(*) +1 +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT COUNT(*) FROM t; +COUNT(*) +201 +# restart +SELECT * FROM t; +a +0 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/apply-log-only-incr.test b/mysql-test/suite/mariabackup/apply-log-only-incr.test new file mode 100644 index 00000000..01b74af2 --- /dev/null +++ b/mysql-test/suite/mariabackup/apply-log-only-incr.test @@ -0,0 +1,73 @@ +--source include/have_innodb.inc +--source include/innodb_undo_tablespaces.inc + +call mtr.add_suppression("InnoDB: New log files created"); + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +CREATE TABLE t(a INT UNSIGNED PRIMARY KEY) ENGINE INNODB; +INSERT INTO t VALUES(0); +COMMIT; + +start transaction; +--disable_query_log +let $n=100; +while ($n) { +eval INSERT t VALUES(101-$n); +dec $n; +} + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log +let $n=100; +while ($n) { +eval INSERT t VALUES(201-$n); +dec $n; +} +--enable_query_log +connect (flush_log,localhost,root,,); +BEGIN; +DELETE FROM t LIMIT 1; +SET GLOBAL innodb_flush_log_at_trx_commit = 1; +ROLLBACK; +disconnect flush_log; +connection default; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --ftwrl-wait-timeout=5 --ftwrl-wait-threshold=300 --ftwrl-wait-query-type=all --target-dir=$incremental_dir --incremental-basedir=$basedir ; +exec $XTRABACKUP --prepare --verbose --target-dir=$basedir ; +--enable_result_log + +let SEARCH_FILE=$MYSQLTEST_VARDIR/log/current_test; +--let SEARCH_PATTERN= Rolled back recovered transaction +--source include/search_pattern_in_file.inc +--echo # expect NOT FOUND + +exec $XTRABACKUP --prepare --verbose --target-dir=$basedir --incremental-dir=$incremental_dir ; + +--source include/search_pattern_in_file.inc +--echo # expect NOT FOUND + +commit; +SELECT count(*) FROM t; +echo # Restore and check results; +--let $targetdir=$basedir +--let $restart_parameters= --innodb-force-recovery=3 +--source include/restart_and_restore.inc + +rmdir $basedir; +rmdir $incremental_dir; + +SELECT COUNT(*) FROM t; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +--disable_ps2_protocol +SELECT COUNT(*) FROM t; +--enable_ps2_protocol + +--let $restart_parameters= +--source include/restart_mysqld.inc + +SELECT * FROM t; +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/apply-log-only.result b/mysql-test/suite/mariabackup/apply-log-only.result new file mode 100644 index 00000000..d618a7bb --- /dev/null +++ b/mysql-test/suite/mariabackup/apply-log-only.result @@ -0,0 +1,10 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t VALUES(1); +NOT FOUND /Rolled back recovered transaction/ in current_test +# expect NOT FOUND +SELECT count(*) FROM t; +count(*) +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/apply-log-only.test b/mysql-test/suite/mariabackup/apply-log-only.test new file mode 100644 index 00000000..7ffed071 --- /dev/null +++ b/mysql-test/suite/mariabackup/apply-log-only.test @@ -0,0 +1,25 @@ +--source include/have_innodb.inc +call mtr.add_suppression("InnoDB: New log files created"); + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE t(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t VALUES(1); + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +exec $XTRABACKUP --prepare --target-dir=$basedir ; + +let SEARCH_FILE=$MYSQLTEST_VARDIR/log/current_test; +--let SEARCH_PATTERN= Rolled back recovered transaction +--source include/search_pattern_in_file.inc +--echo # expect NOT FOUND + +SELECT count(*) FROM t; +DROP TABLE t; + +# Cleanup +rmdir $basedir; diff --git a/mysql-test/suite/mariabackup/aria_log_dir_path.result b/mysql-test/suite/mariabackup/aria_log_dir_path.result new file mode 100644 index 00000000..1a877321 --- /dev/null +++ b/mysql-test/suite/mariabackup/aria_log_dir_path.result @@ -0,0 +1,41 @@ +# +# MDEV-30968 mariadb-backup does not copy Aria logs if aria_log_dir_path is used +# +# Restart mariadbd with the test specific parameters +# restart: --aria-log-file-size=8388608 --aria-log-purge-type=external --loose-aria-log-dir-path=MYSQLTEST_VARDIR/tmp/backup_aria_log_dir_path +# Create and populate an Aria table (and Aria logs) +CREATE TABLE t1 (id INT, txt LONGTEXT) ENGINE=Aria; +BEGIN NOT ATOMIC +FOR id IN 0..9 DO +INSERT INTO test.t1 (id, txt) VALUES (id, REPEAT(id,1024*1024)); +END FOR; +END; +$$ +# Testing aria log files before --backup +SET @@global.aria_checkpoint_interval=DEFAULT /*Force checkpoint*/; +SHOW ENGINE aria logs; +Type Name Status +Aria aria_log.00000001 free +Aria aria_log.00000002 in use +# mariadb-backup --backup +# mariadb-backup --prepare +# shutdown server +# remove datadir +# remove aria-log-dir-path +# mariadb-backup --copy-back +# with parameters: --defaults-file=MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=MYSQLTEST_VARDIR/mysqld.1/data/ --target-dir=MYSQLTEST_VARDIR/tmp/backup --parallel=2 --throttle=1 --aria-log-dir-path=MYSQLTEST_VARDIR/tmp/backup_aria_log_dir_path +# starting server +# restart: --aria-log-file-size=8388608 --aria-log-purge-type=external --loose-aria-log-dir-path=MYSQLTEST_VARDIR/tmp/backup_aria_log_dir_path +# Check that the table is there after --copy-back +SELECT COUNT(*) from t1; +COUNT(*) +10 +DROP TABLE t1; +# Testing aria log files after --copy-back +SET @@global.aria_checkpoint_interval=DEFAULT /*Force checkpoint*/; +SHOW ENGINE aria logs; +Type Name Status +Aria aria_log.00000001 free +Aria aria_log.00000002 in use +# Restarting mariadbd with default parameters +# restart diff --git a/mysql-test/suite/mariabackup/aria_log_dir_path.test b/mysql-test/suite/mariabackup/aria_log_dir_path.test new file mode 100644 index 00000000..0178cd4e --- /dev/null +++ b/mysql-test/suite/mariabackup/aria_log_dir_path.test @@ -0,0 +1,105 @@ +--source include/have_maria.inc + +--echo # +--echo # MDEV-30968 mariadb-backup does not copy Aria logs if aria_log_dir_path is used +--echo # + +--let $datadir=`SELECT @@datadir` +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup + +if ($ARIA_LOGDIR_MARIADB == '') +{ + --let $ARIA_LOGDIR_MARIADB=$MYSQLTEST_VARDIR/tmp/backup_aria_log_dir_path +} + +if ($ARIA_LOGDIR_FS == '') +{ + --let $ARIA_LOGDIR_FS=$MYSQLTEST_VARDIR/tmp/backup_aria_log_dir_path +} + +--let $server_parameters=--aria-log-file-size=8388608 --aria-log-purge-type=external --loose-aria-log-dir-path=$ARIA_LOGDIR_MARIADB + + +--echo # Restart mariadbd with the test specific parameters +--mkdir $ARIA_LOGDIR_FS +--let $restart_parameters=$server_parameters +--source include/restart_mysqld.inc + + +--echo # Create and populate an Aria table (and Aria logs) +CREATE TABLE t1 (id INT, txt LONGTEXT) ENGINE=Aria; +DELIMITER $$; +BEGIN NOT ATOMIC + FOR id IN 0..9 DO + INSERT INTO test.t1 (id, txt) VALUES (id, REPEAT(id,1024*1024)); + END FOR; +END; +$$ +DELIMITER ;$$ + + +--echo # Testing aria log files before --backup +SET @@global.aria_checkpoint_interval=DEFAULT /*Force checkpoint*/; +--file_exists $ARIA_LOGDIR_FS/aria_log_control +--file_exists $ARIA_LOGDIR_FS/aria_log.00000001 +--file_exists $ARIA_LOGDIR_FS/aria_log.00000002 +--error 1 +--file_exists $ARIA_LOGDIR_FS/aria_log.00000003 +--replace_regex /Size +[0-9]+ ; .+aria_log/aria_log/ +SHOW ENGINE aria logs; + + +--echo # mariadb-backup --backup +--disable_result_log +--mkdir $targetdir +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir +--enable_result_log + + +--echo # mariadb-backup --prepare +--disable_result_log +--exec $XTRABACKUP --prepare --target-dir=$targetdir +--enable_result_log + + +--echo # shutdown server +--disable_result_log +--source include/shutdown_mysqld.inc +--echo # remove datadir +--rmdir $datadir +--echo # remove aria-log-dir-path +--rmdir $ARIA_LOGDIR_FS + +--echo # mariadb-backup --copy-back +--let $mariadb_backup_parameters=--defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$datadir --target-dir=$targetdir --parallel=2 --throttle=1 --aria-log-dir-path=$ARIA_LOGDIR_MARIADB +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec echo "# with parameters: $mariadb_backup_parameters" +--exec $XTRABACKUP $mariadb_backup_parameters + +--echo # starting server +--let $restart_parameters=$server_parameters +--source include/start_mysqld.inc +--enable_result_log +--rmdir $targetdir + + +--echo # Check that the table is there after --copy-back +SELECT COUNT(*) from t1; +DROP TABLE t1; + + +--echo # Testing aria log files after --copy-back +SET @@global.aria_checkpoint_interval=DEFAULT /*Force checkpoint*/; +--file_exists $ARIA_LOGDIR_FS/aria_log_control +--file_exists $ARIA_LOGDIR_FS/aria_log.00000001 +--file_exists $ARIA_LOGDIR_FS/aria_log.00000002 +--error 1 +--file_exists $ARIA_LOGDIR_FS/aria_log.00000003 +--replace_regex /Size +[0-9]+ ; .+aria_log/aria_log/ +SHOW ENGINE aria logs; + + +--echo # Restarting mariadbd with default parameters +--let $restart_parameters= +--source include/restart_mysqld.inc +--rmdir $ARIA_LOGDIR_FS diff --git a/mysql-test/suite/mariabackup/aria_log_dir_path_rel.result b/mysql-test/suite/mariabackup/aria_log_dir_path_rel.result new file mode 100644 index 00000000..7fef2609 --- /dev/null +++ b/mysql-test/suite/mariabackup/aria_log_dir_path_rel.result @@ -0,0 +1,41 @@ +# +# MDEV-30968 mariadb-backup does not copy Aria logs if aria_log_dir_path is used +# +# Restart mariadbd with the test specific parameters +# restart: --aria-log-file-size=8388608 --aria-log-purge-type=external --loose-aria-log-dir-path=../../tmp/backup_aria_log_dir_path_rel +# Create and populate an Aria table (and Aria logs) +CREATE TABLE t1 (id INT, txt LONGTEXT) ENGINE=Aria; +BEGIN NOT ATOMIC +FOR id IN 0..9 DO +INSERT INTO test.t1 (id, txt) VALUES (id, REPEAT(id,1024*1024)); +END FOR; +END; +$$ +# Testing aria log files before --backup +SET @@global.aria_checkpoint_interval=DEFAULT /*Force checkpoint*/; +SHOW ENGINE aria logs; +Type Name Status +Aria aria_log.00000001 free +Aria aria_log.00000002 in use +# mariadb-backup --backup +# mariadb-backup --prepare +# shutdown server +# remove datadir +# remove aria-log-dir-path +# mariadb-backup --copy-back +# with parameters: --defaults-file=MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=MYSQLTEST_VARDIR/mysqld.1/data/ --target-dir=MYSQLTEST_VARDIR/tmp/backup --parallel=2 --throttle=1 --aria-log-dir-path=../../tmp/backup_aria_log_dir_path_rel +# starting server +# restart: --aria-log-file-size=8388608 --aria-log-purge-type=external --loose-aria-log-dir-path=../../tmp/backup_aria_log_dir_path_rel +# Check that the table is there after --copy-back +SELECT COUNT(*) from t1; +COUNT(*) +10 +DROP TABLE t1; +# Testing aria log files after --copy-back +SET @@global.aria_checkpoint_interval=DEFAULT /*Force checkpoint*/; +SHOW ENGINE aria logs; +Type Name Status +Aria aria_log.00000001 free +Aria aria_log.00000002 in use +# Restarting mariadbd with default parameters +# restart diff --git a/mysql-test/suite/mariabackup/aria_log_dir_path_rel.test b/mysql-test/suite/mariabackup/aria_log_dir_path_rel.test new file mode 100644 index 00000000..c8169959 --- /dev/null +++ b/mysql-test/suite/mariabackup/aria_log_dir_path_rel.test @@ -0,0 +1,4 @@ +--let $ARIA_LOGDIR_MARIADB=../../tmp/backup_aria_log_dir_path_rel +--let $ARIA_LOGDIR_FS=$MYSQLTEST_VARDIR/tmp/backup_aria_log_dir_path_rel + +--source aria_log_dir_path.test diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.opt b/mysql-test/suite/mariabackup/auth_plugin_win.opt new file mode 100644 index 00000000..e534ae1e --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.opt @@ -0,0 +1 @@ +--loose-enable-named-pipe diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.result b/mysql-test/suite/mariabackup/auth_plugin_win.result new file mode 100644 index 00000000..caf5d8df --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.result @@ -0,0 +1,5 @@ +INSTALL SONAME 'auth_named_pipe'; +CREATE USER 'USERNAME' IDENTIFIED WITH named_pipe; +GRANT ALL PRIVILEGES ON *.* to 'USERNAME'; +DROP USER 'USERNAME'; +UNINSTALL SONAME 'auth_named_pipe'; diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.test b/mysql-test/suite/mariabackup/auth_plugin_win.test new file mode 100644 index 00000000..70ae74b7 --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.test @@ -0,0 +1,31 @@ +--source include/windows.inc +--source include/not_embedded.inc + +if (!$AUTH_NAMED_PIPE_SO) { + skip No named pipe plugin; +} + +if (!$USERNAME) { + skip USERNAME variable is undefined; +} + +if (`SELECT count(*) <> 0 FROM mysql.user WHERE user = '$USERNAME'`) { + skip \$USER=$USER which exists in mysql.user; +} + +INSTALL SONAME 'auth_named_pipe'; + +--replace_result $USERNAME USERNAME +eval CREATE USER '$USERNAME' IDENTIFIED WITH named_pipe; +--replace_result $USERNAME USERNAME +eval GRANT ALL PRIVILEGES ON *.* to '$USERNAME'; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf -u $USERNAME --backup --protocol=pipe --target-dir=$targetdir; +--enable_result_log +--replace_result $USERNAME USERNAME +eval DROP USER '$USERNAME'; +rmdir $targetdir; +UNINSTALL SONAME 'auth_named_pipe'; + diff --git a/mysql-test/suite/mariabackup/backup_grants.result b/mysql-test/suite/mariabackup/backup_grants.result new file mode 100644 index 00000000..56899f8d --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_grants.result @@ -0,0 +1,14 @@ +CREATE user backup@localhost; +FOUND 1 /missing required privilege RELOAD/ in backup.log +FOUND 1 /missing required privilege PROCESS/ in backup.log +FOUND 1 /GRANT USAGE ON/ in backup.log +GRANT RELOAD, PROCESS on *.* to backup@localhost; +NOT FOUND /missing required privilege REPLICA MONITOR/ in backup.log +GRANT REPLICA MONITOR ON *.* TO backup@localhost; +REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; +GRANT CONNECTION ADMIN ON *.* TO backup@localhost; +FOUND 1 /missing required privilege REPLICATION SLAVE ADMIN/ in backup.log +NOT FOUND /missing required privilege REPLICA MONITOR/ in backup.log +GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost; +GRANT REPLICA MONITOR ON *.* TO backup@localhost; +DROP USER backup@localhost; diff --git a/mysql-test/suite/mariabackup/backup_grants.test b/mysql-test/suite/mariabackup/backup_grants.test new file mode 100644 index 00000000..894ae73a --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_grants.test @@ -0,0 +1,86 @@ +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +CREATE user backup@localhost; + +# backup possible for unprivileges user, with --no-lock +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --no-lock --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +# backup fails without --no-lock, because of FTWRL +--disable_result_log +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; +--enable_result_log + +let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log; +--let SEARCH_PATTERN= missing required privilege RELOAD +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= missing required privilege PROCESS +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= GRANT USAGE ON +--source include/search_pattern_in_file.inc +# backup succeeds with RELOAD privilege +GRANT RELOAD, PROCESS on *.* to backup@localhost; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +# MDEV-23607 Warning: missing required privilege REPLICATION CLIENT +# --slave-info and galera info require REPLICA MONITOR +--disable_result_log +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; +--enable_result_log +rmdir $targetdir; + +--let SEARCH_PATTERN= missing required privilege REPLICA MONITOR +--source include/search_pattern_in_file.inc + +GRANT REPLICA MONITOR ON *.* TO backup@localhost; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --slave-info --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; +REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; + +# TODO need a query that would delay a BACKUP STAGE START/ BACKUP STAGE BLOCK_COMMIT longer than the kill-long-queries-timeout +#--send SELECT SLEEP(9) kill_me +## kill-long-query-type=(not empty) requires CONNECTION ADMIN +#--disable_result_log +#error 1; +#--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --kill-long-query-type=all --kill-long-queries-timeout=4 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; +#--reap +#--enable_result_log +#rmdir $targetdir; +# +#--let SEARCH_PATTERN= missing required privilege CONNECTION ADMIN +#--source include/search_pattern_in_file.inc + +GRANT CONNECTION ADMIN ON *.* TO backup@localhost; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +# --safe-slave-backup requires REPLICATION SLAVE ADMIN, and REPLICA MONITOR +--disable_result_log +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --safe-slave-backup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; +--enable_result_log +rmdir $targetdir; + +--let SEARCH_PATTERN= missing required privilege REPLICATION SLAVE ADMIN +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= missing required privilege REPLICA MONITOR +--source include/search_pattern_in_file.inc + +GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost; +GRANT REPLICA MONITOR ON *.* TO backup@localhost; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --safe-slave-backup --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +DROP USER backup@localhost; diff --git a/mysql-test/suite/mariabackup/backup_lock_wait_timeout.result b/mysql-test/suite/mariabackup/backup_lock_wait_timeout.result new file mode 100644 index 00000000..9806bc29 --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_lock_wait_timeout.result @@ -0,0 +1,11 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +connect con1,localhost,root,,; +BEGIN; +LOCK TABLES t WRITE; +connection default; +# xtrabackup backup +connection con1; +COMMIT; +connection default; +disconnect con1; +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/backup_lock_wait_timeout.test b/mysql-test/suite/mariabackup/backup_lock_wait_timeout.test new file mode 100644 index 00000000..e0f43910 --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_lock_wait_timeout.test @@ -0,0 +1,28 @@ +--source include/have_innodb.inc +--source include/count_sessions.inc + +CREATE TABLE t(i INT) ENGINE INNODB; + +connect (con1,localhost,root,,); +BEGIN; +LOCK TABLES t WRITE; + +--connection default + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--disable_result_log +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --ftwrl-wait-timeout=1 --target-dir=$targetdir; +--enable_result_log + +--connection con1 +COMMIT; + +--connection default +--disconnect con1 + +DROP TABLE t; +rmdir $targetdir; +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/mariabackup/backup_ssl.result b/mysql-test/suite/mariabackup/backup_ssl.result new file mode 100644 index 00000000..099b8d42 --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_ssl.result @@ -0,0 +1,9 @@ +GRANT ALL PRIVILEGES on *.* TO backup_user IDENTIFIED by 'x' REQUIRE SSL; +FLUSH PRIVILEGES; +# xtrabackup backup +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +DROP USER backup_user; diff --git a/mysql-test/suite/mariabackup/backup_ssl.test b/mysql-test/suite/mariabackup/backup_ssl.test new file mode 100644 index 00000000..e858c834 --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_ssl.test @@ -0,0 +1,16 @@ +GRANT ALL PRIVILEGES on *.* TO backup_user IDENTIFIED by 'x' REQUIRE SSL; +FLUSH PRIVILEGES; +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --user=backup_user --password=x --ssl --backup --target-dir=$targetdir; +--enable_result_log + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log +DROP USER backup_user; +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/big_innodb_log.result b/mysql-test/suite/mariabackup/big_innodb_log.result new file mode 100644 index 00000000..b9b6b6af --- /dev/null +++ b/mysql-test/suite/mariabackup/big_innodb_log.result @@ -0,0 +1,33 @@ +# Kill the server +# restart: --debug-dbug=+d,innodb_small_log_block_no_limit +CREATE TABLE t(i INT) ENGINE InnoDB; +INSERT INTO t VALUES +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9); +set global innodb_log_checkpoint_now = 1; +# xtrabackup backup, execute the following query after test.t is copied: +# BEGIN NOT ATOMIC INSERT INTO test.t SELECT * FROM test.t; UPDATE test.t SET i = 10 WHERE i = 0; DELETE FROM test.t WHERE i = 1; END +SELECT count(*) FROM t WHERE i = 0; +count(*) +0 +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart: --debug-dbug=+d,innodb_small_log_block_no_limit +SELECT count(*) FROM t WHERE i = 0; +count(*) +0 +Ok +Ok +DROP TABLE t; +# Kill the server +# restart diff --git a/mysql-test/suite/mariabackup/big_innodb_log.test b/mysql-test/suite/mariabackup/big_innodb_log.test new file mode 100644 index 00000000..85d22a82 --- /dev/null +++ b/mysql-test/suite/mariabackup/big_innodb_log.test @@ -0,0 +1,90 @@ +# The general reason why innodb redo log file is limited by 512G is that +# log_block_convert_lsn_to_no() returns value limited by 1G. But there is no +# need to have unique log block numbers in log group. This test forces innodb +# to generate redo log files with non-unique log block numbers and tests +# recovery process with such numbers. +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/no_valgrind_without_big.inc + +--let MYSQLD_DATADIR= `select @@datadir` +let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --tmpdir=$MYSQL_TMP_DIR --debug-dbug=+d,innodb_small_log_block_no_limit; + +--source include/kill_mysqld.inc +--rmdir $MYSQLD_DATADIR +--mkdir $MYSQLD_DATADIR +--mkdir $MYSQLD_DATADIR/mysql +--mkdir $MYSQLD_DATADIR/test +--exec $MYSQLD_BOOTSTRAP_CMD < $MYSQL_BOOTSTRAP_SQL_FILE >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 +let $old_restart_parameters=$restart_parameters; +let $restart_parameters= $old_restart_parameters --debug-dbug=+d,innodb_small_log_block_no_limit; +--source include/start_mysqld.inc + +CREATE TABLE t(i INT) ENGINE InnoDB; +INSERT INTO t VALUES + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); + +set global innodb_log_checkpoint_now = 1; +--let after_copy_test_t=BEGIN NOT ATOMIC INSERT INTO test.t SELECT * FROM test.t; UPDATE test.t SET i = 10 WHERE i = 0; DELETE FROM test.t WHERE i = 1; END + +--echo # xtrabackup backup, execute the following query after test.t is copied: +--echo # $after_copy_test_t +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=10 --target-dir=$targetdir --dbug=+d,mariabackup_events,innodb_small_log_block_no_limit; +--enable_result_log + +--let $total_before=`SELECT count(*) FROM t` +SELECT count(*) FROM t WHERE i = 0; +--let $updated_before=`SELECT count(*) FROM t WHERE i = 10` + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir --dbug=+d,innodb_small_log_block_no_limit; +--source include/restart_and_restore.inc +--enable_result_log + +--let $total_after=`SELECT count(*) FROM t` +SELECT count(*) FROM t WHERE i = 0; +--let $updated_after=`SELECT count(*) FROM t WHERE i = 10` + +if ($total_before == $total_after) { +--echo Ok +} +if ($total_before != $total_after) { +--echo Failed +} +if ($updated_before == $updated_after) { +--echo Ok +} +if ($updated_before != $updated_after) { +--echo Failed +} + +DROP TABLE t; +rmdir $targetdir; +--source include/kill_mysqld.inc +--rmdir $MYSQLD_DATADIR + +perl; +use lib "lib"; +use My::Handles { suppress_init_messages => 1 }; +use My::File::Path; +my $install_db_dir = ($ENV{MTR_PARALLEL} == 1) ? + "$ENV{'MYSQLTEST_VARDIR'}/install.db" : + "$ENV{'MYSQLTEST_VARDIR'}/../install.db"; +copytree($install_db_dir, $ENV{'MYSQLD_DATADIR'}); +EOF + +--let $restart_parameters= $old_restart_parameters +--source include/start_mysqld.inc diff --git a/mysql-test/suite/mariabackup/binlog.result b/mysql-test/suite/mariabackup/binlog.result new file mode 100644 index 00000000..7851c2ba --- /dev/null +++ b/mysql-test/suite/mariabackup/binlog.result @@ -0,0 +1,8 @@ +CREATE TABLE t(a varchar(60)) ENGINE INNODB; +INSERT INTO t VALUES(1); +SHOW VARIABLES like 'log_bin'; +Variable_name Value +log_bin ON +FOUND 1 /Last binlog file .+, position \d+/ in current_test +# expect FOUND +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/binlog.test b/mysql-test/suite/mariabackup/binlog.test new file mode 100644 index 00000000..9d62e5f8 --- /dev/null +++ b/mysql-test/suite/mariabackup/binlog.test @@ -0,0 +1,25 @@ +--source include/have_innodb.inc +--source include/have_log_bin.inc + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE t(a varchar(60)) ENGINE INNODB; +INSERT INTO t VALUES(1); + +SHOW VARIABLES like 'log_bin'; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +exec $XTRABACKUP --prepare --binlog-info=1 --target-dir=$basedir ; + +let SEARCH_FILE=$MYSQLTEST_VARDIR/log/current_test; +--let SEARCH_PATTERN= Last binlog file .+, position \d+ +--source include/search_pattern_in_file.inc +--echo # expect FOUND + +DROP TABLE t; + +# Cleanup +rmdir $basedir; diff --git a/mysql-test/suite/mariabackup/compress_qpress.result b/mysql-test/suite/mariabackup/compress_qpress.result new file mode 100644 index 00000000..ff940813 --- /dev/null +++ b/mysql-test/suite/mariabackup/compress_qpress.result @@ -0,0 +1,16 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# xtrabackup backup +INSERT INTO t VALUES(2); +# xtrabackup prepare +db.opt.qp +t.frm.qp +t.ibd.qp +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/compress_qpress.test b/mysql-test/suite/mariabackup/compress_qpress.test new file mode 100644 index 00000000..c7762f8e --- /dev/null +++ b/mysql-test/suite/mariabackup/compress_qpress.test @@ -0,0 +1,28 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +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 --compress --target-dir=$targetdir; +--enable_result_log + +INSERT INTO t VALUES(2); + + +echo # xtrabackup prepare; +--disable_result_log +# Because MDEV-24626 in 10.6 optimized file creation, we could end up with +# t.new.qp instead of t.ibd.qp unless a log checkpoint happened to be +# triggered between CREATE TABLE and the backup run. +--replace_result t.new t.ibd +list_files $targetdir/test *.qp; +exec $XTRABACKUP --decompress --remove-original --target-dir=$targetdir; +list_files $targetdir/test *.qp; +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded,lz4.rdiff b/mysql-test/suite/mariabackup/compression_providers_loaded,lz4.rdiff new file mode 100644 index 00000000..2202a511 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded,lz4.rdiff @@ -0,0 +1,13 @@ +--- suite/mariabackup/compression_providers_loaded.result ++++ suite/mariabackup/compression_providers_loaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lz4 compression + # + # Creating table +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lz4; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded,lzma.rdiff b/mysql-test/suite/mariabackup/compression_providers_loaded,lzma.rdiff new file mode 100644 index 00000000..e6b52d3a --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded,lzma.rdiff @@ -0,0 +1,13 @@ +--- suite/mariabackup/compression_providers_loaded.result ++++ suite/mariabackup/compression_providers_loaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lzma compression + # + # Creating table +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lzma; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded,lzo.rdiff b/mysql-test/suite/mariabackup/compression_providers_loaded,lzo.rdiff new file mode 100644 index 00000000..75e9519d --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded,lzo.rdiff @@ -0,0 +1,13 @@ +--- suite/mariabackup/compression_providers_loaded.result ++++ suite/mariabackup/compression_providers_loaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lzo compression + # + # Creating table +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lzo; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded,snappy.rdiff b/mysql-test/suite/mariabackup/compression_providers_loaded,snappy.rdiff new file mode 100644 index 00000000..da281eff --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded,snappy.rdiff @@ -0,0 +1,13 @@ +--- suite/mariabackup/compression_providers_loaded.result ++++ suite/mariabackup/compression_providers_loaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with snappy compression + # + # Creating table +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = snappy; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded.combinations b/mysql-test/suite/mariabackup/compression_providers_loaded.combinations new file mode 100644 index 00000000..3287917f --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded.combinations @@ -0,0 +1,14 @@ +[bzip2] +plugin-load-add=$PROVIDER_BZIP2_SO + +[lz4] +plugin-load-add=$PROVIDER_LZ4_SO + +[lzma] +plugin-load-add=$PROVIDER_LZMA_SO + +[lzo] +plugin-load-add=$PROVIDER_LZO_SO + +[snappy] +plugin-load-add=$PROVIDER_SNAPPY_SO diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded.result b/mysql-test/suite/mariabackup/compression_providers_loaded.result new file mode 100644 index 00000000..6cd928b0 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded.result @@ -0,0 +1,27 @@ +# +# Testing mariabackup with bzip2 compression +# +# Creating table +set global innodb_compression_algorithm = bzip2; +create table t1 (a int, b text ) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +# restart +# xtrabackup backup +# xtrabackup prepare; +# shutdown server +# remove datadir +# xtrabackup move back +# restart +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded.test b/mysql-test/suite/mariabackup/compression_providers_loaded.test new file mode 100644 index 00000000..aad21ff0 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded.test @@ -0,0 +1,38 @@ +let $alg = $MTR_COMBINATIONS; + +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'provider_$alg' and plugin_status='active'`) +{ + skip "Needs provider_$alg plugin"; +} + +--echo # +--echo # Testing mariabackup with $alg compression +--echo # + +--echo # Creating table +eval set global innodb_compression_algorithm = $alg; +eval create table t1 (a int, b text $column_params) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; + +--source include/restart_mysqld.inc + +--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; + +--echo # xtrabackup prepare; +disable_result_log; +exec $XTRABACKUP --prepare --target-dir=$targetdir; +source include/restart_and_restore.inc; +enable_result_log; + +select a, left(b, 9), length(b) from t1; + +drop table t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded,lz4.rdiff b/mysql-test/suite/mariabackup/compression_providers_unloaded,lz4.rdiff new file mode 100644 index 00000000..4b874403 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded,lz4.rdiff @@ -0,0 +1,22 @@ +--- suite/mariabackup/compression_providers_unloaded.result ++++ suite/mariabackup/compression_providers_unloaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lz4 compression + # +-# Create table with bzip2 compression +-set global innodb_compression_algorithm = bzip2; ++# Create table with lz4 compression ++set global innodb_compression_algorithm = lz4; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); +@@ -14,6 +14,6 @@ + 2 ghighighi 30000 + # Restart server without plugin + call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lz4 + # xtrabackup backup + drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded,lzma.rdiff b/mysql-test/suite/mariabackup/compression_providers_unloaded,lzma.rdiff new file mode 100644 index 00000000..ff57834f --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded,lzma.rdiff @@ -0,0 +1,22 @@ +--- suite/mariabackup/compression_providers_unloaded.result ++++ suite/mariabackup/compression_providers_unloaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lzma compression + # +-# Create table with bzip2 compression +-set global innodb_compression_algorithm = bzip2; ++# Create table with lzma compression ++set global innodb_compression_algorithm = lzma; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); +@@ -14,6 +14,6 @@ + 2 ghighighi 30000 + # Restart server without plugin + call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lzma + # xtrabackup backup + drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded,lzo.rdiff b/mysql-test/suite/mariabackup/compression_providers_unloaded,lzo.rdiff new file mode 100644 index 00000000..5308fc43 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded,lzo.rdiff @@ -0,0 +1,22 @@ +--- suite/mariabackup/compression_providers_unloaded.result ++++ suite/mariabackup/compression_providers_unloaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lzo compression + # +-# Create table with bzip2 compression +-set global innodb_compression_algorithm = bzip2; ++# Create table with lzo compression ++set global innodb_compression_algorithm = lzo; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); +@@ -14,6 +14,6 @@ + 2 ghighighi 30000 + # Restart server without plugin + call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lzo + # xtrabackup backup + drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded,snappy.rdiff b/mysql-test/suite/mariabackup/compression_providers_unloaded,snappy.rdiff new file mode 100644 index 00000000..b7b5e2b5 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded,snappy.rdiff @@ -0,0 +1,22 @@ +--- suite/mariabackup/compression_providers_unloaded.result ++++ suite/mariabackup/compression_providers_unloaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with snappy compression + # +-# Create table with bzip2 compression +-set global innodb_compression_algorithm = bzip2; ++# Create table with snappy compression ++set global innodb_compression_algorithm = snappy; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); +@@ -14,6 +14,6 @@ + 2 ghighighi 30000 + # Restart server without plugin + call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-snappy + # xtrabackup backup + drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded.combinations b/mysql-test/suite/mariabackup/compression_providers_unloaded.combinations new file mode 100644 index 00000000..3287917f --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded.combinations @@ -0,0 +1,14 @@ +[bzip2] +plugin-load-add=$PROVIDER_BZIP2_SO + +[lz4] +plugin-load-add=$PROVIDER_LZ4_SO + +[lzma] +plugin-load-add=$PROVIDER_LZMA_SO + +[lzo] +plugin-load-add=$PROVIDER_LZO_SO + +[snappy] +plugin-load-add=$PROVIDER_SNAPPY_SO diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded.result b/mysql-test/suite/mariabackup/compression_providers_unloaded.result new file mode 100644 index 00000000..ccf3e035 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded.result @@ -0,0 +1,22 @@ +call mtr.add_suppression("Background Page read failed to read, uncompress, or decrypt"); +call mtr.add_suppression("Table is compressed or encrypted but uncompress or decrypt failed"); +call mtr.add_suppression("Refusing to load corrupted table"); +# +# Testing mariabackup with bzip2 compression +# +# Create table with bzip2 compression +set global innodb_compression_algorithm = bzip2; +create table t1 (a int, b text ) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +# Restart server without plugin +call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +# restart: --disable-provider-bzip2 +# xtrabackup backup +drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded.test b/mysql-test/suite/mariabackup/compression_providers_unloaded.test new file mode 100644 index 00000000..673c16d0 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded.test @@ -0,0 +1,35 @@ +let $alg = $MTR_COMBINATIONS; +call mtr.add_suppression("Background Page read failed to read, uncompress, or decrypt"); +call mtr.add_suppression("Table is compressed or encrypted but uncompress or decrypt failed"); +call mtr.add_suppression("Refusing to load corrupted table"); + +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'provider_$alg' and plugin_status='active'`) +{ + skip "Needs provider_$alg plugin"; +} + +--echo # +--echo # Testing mariabackup with $alg compression +--echo # + +--echo # Create table with $alg compression +eval set global innodb_compression_algorithm = $alg; +eval create table t1 (a int, b text $column_params) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; + +--echo # Restart server without plugin +call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +let $restart_parameters = --disable-provider-$alg; +source include/restart_mysqld.inc; + +--echo # xtrabackup backup +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; + +drop table t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/create_during_backup.result b/mysql-test/suite/mariabackup/create_during_backup.result new file mode 100644 index 00000000..374c3dfc --- /dev/null +++ b/mysql-test/suite/mariabackup/create_during_backup.result @@ -0,0 +1,10 @@ +# xtrabackup backup +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT COUNT(*) from t1; +COUNT(*) +10000 +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/create_during_backup.test b/mysql-test/suite/mariabackup/create_during_backup.test new file mode 100644 index 00000000..985a5a3e --- /dev/null +++ b/mysql-test/suite/mariabackup/create_during_backup.test @@ -0,0 +1,26 @@ +--source include/have_debug.inc +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +mkdir $targetdir; + +# this will table and populate it, after backup has list of tables to be copied +--let after_load_tablespaces =CREATE TABLE test.t1 ENGINE=INNODB SELECT UUID() from test.seq_1_to_10000 + +echo # xtrabackup backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +--let after_load_tables= + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +# Check that new table is there after restore. +SELECT COUNT(*) from t1; +DROP TABLE t1; +rmdir $targetdir; + + diff --git a/mysql-test/suite/mariabackup/create_with_data_directory_during_backup.result b/mysql-test/suite/mariabackup/create_with_data_directory_during_backup.result new file mode 100644 index 00000000..be97675c --- /dev/null +++ b/mysql-test/suite/mariabackup/create_with_data_directory_during_backup.result @@ -0,0 +1,10 @@ +# xtrabackup backup +# xtrabackup prepare +DROP TABLE t; +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/create_with_data_directory_during_backup.test b/mysql-test/suite/mariabackup/create_with_data_directory_during_backup.test new file mode 100644 index 00000000..f01028b6 --- /dev/null +++ b/mysql-test/suite/mariabackup/create_with_data_directory_during_backup.test @@ -0,0 +1,25 @@ +--source include/have_debug.inc +--source include/have_symlink.inc +let $table_data_dir=$MYSQLTEST_VARDIR/tmp/ddir; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +mkdir $table_data_dir; +--replace_result $table_data_dir table_data_dir +--let after_load_tablespaces=CREATE TABLE test.t(i int) ENGINE=INNODB DATA DIRECTORY='$table_data_dir' +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log +--source include/shutdown_mysqld.inc +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +--source include/start_mysqld.inc +DROP TABLE t; +rmdir $table_data_dir; +-- source include/restart_and_restore.inc +--enable_result_log +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; +rmdir $table_data_dir; diff --git a/mysql-test/suite/mariabackup/data_directory.result b/mysql-test/suite/mariabackup/data_directory.result new file mode 100644 index 00000000..8692c352 --- /dev/null +++ b/mysql-test/suite/mariabackup/data_directory.result @@ -0,0 +1,19 @@ +CREATE TABLE t(a INT) ENGINE=InnoDB DATA DIRECTORY='table_data_dir'; +INSERT INTO t VALUES(1); +# xtrabackup backup +# xtrabackup prepare +DROP TABLE t; +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +a +1 +DROP TABLE t; +# +# MDEV-18200 MariaBackup full backup failed with InnoDB: Failing assertion: success +# +# +# End of 10.4 tests +# diff --git a/mysql-test/suite/mariabackup/data_directory.test b/mysql-test/suite/mariabackup/data_directory.test new file mode 100644 index 00000000..ffb3ab30 --- /dev/null +++ b/mysql-test/suite/mariabackup/data_directory.test @@ -0,0 +1,39 @@ +--source include/have_symlink.inc +let $table_data_dir=$MYSQLTEST_VARDIR/ddir; +mkdir $table_data_dir; +--replace_result $table_data_dir table_data_dir +EVAL CREATE TABLE t(a INT) ENGINE=InnoDB DATA DIRECTORY='$table_data_dir'; +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 +--source include/shutdown_mysqld.inc +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +--source include/start_mysqld.inc +DROP TABLE t; +rmdir $table_data_dir; +-- source include/restart_and_restore.inc +--enable_result_log +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; + +--echo # +--echo # MDEV-18200 MariaBackup full backup failed with InnoDB: Failing assertion: success +--echo # +let $DATADIR= `select @@datadir`; +chmod 0000 $DATADIR/ibdata1; +--disable_result_log +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log +chmod 0755 $DATADIR/ibdata1; +rmdir $table_data_dir; +rmdir $targetdir; +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/suite/mariabackup/defer_space.result b/mysql-test/suite/mariabackup/defer_space.result new file mode 100644 index 00000000..6453aff5 --- /dev/null +++ b/mysql-test/suite/mariabackup/defer_space.result @@ -0,0 +1,27 @@ +call mtr.add_suppression("InnoDB: Expected tablespace id .*"); +# Mariabackup --backup with page0 INIT_PAGE redo record +# and there is no FILE_CREATE for the tablespace t1 +SET @save_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG="+d,checkpoint_after_file_create"; +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +# xtrabackup backup +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t1; +f1 +1 +DROP TABLE t1; +SET @@SESSION.DEBUG_DBUG= @save_debug; +# Mariabackup fails after corrupting the page0 in disk +# and there is no INIT_PAGE for page0 +CREATE TABLE t1(c INT) ENGINE=INNODB; +# Corrupt the table +# restart +# xtrabackup backup +FOUND 10 /Header page consists of zero bytes*/ in backup.log +UNLOCK TABLES; +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/defer_space.test b/mysql-test/suite/mariabackup/defer_space.test new file mode 100644 index 00000000..397a1ff5 --- /dev/null +++ b/mysql-test/suite/mariabackup/defer_space.test @@ -0,0 +1,68 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/not_embedded.inc +--source include/no_valgrind_without_big.inc + +call mtr.add_suppression("InnoDB: Expected tablespace id .*"); +--echo # Mariabackup --backup with page0 INIT_PAGE redo record +--echo # and there is no FILE_CREATE for the tablespace t1 +SET @save_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG="+d,checkpoint_after_file_create"; +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +INSERT INTO t1 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 + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t1; +DROP TABLE t1; +rmdir $targetdir; +SET @@SESSION.DEBUG_DBUG= @save_debug; + +--echo # Mariabackup fails after corrupting the page0 in disk +--echo # and there is no INIT_PAGE for page0 + +CREATE TABLE t1(c INT) ENGINE=INNODB; +let MYSQLD_DATADIR=`select @@datadir`; +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; +--source include/shutdown_mysqld.inc + +--echo # Corrupt the table + +perl; +my $ps = $ENV{INNODB_PAGE_SIZE}; + +my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; +open(FILE, "+<$file") || die "Unable to open $file"; +binmode FILE; +seek (FILE, 0, SEEK_SET) or die "seek"; +print FILE chr(0x00) x $ps; +close FILE or die "close"; +EOF + +--source include/start_mysqld.inc +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; +--disable_result_log +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --core-file > $backuplog; +--enable_result_log + +--let SEARCH_PATTERN=Header page consists of zero bytes* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +UNLOCK TABLES; +DROP TABLE t1; +rmdir $targetdir; +remove_file $backuplog; diff --git a/mysql-test/suite/mariabackup/disabled.def b/mysql-test/suite/mariabackup/disabled.def new file mode 100644 index 00000000..d272540c --- /dev/null +++ b/mysql-test/suite/mariabackup/disabled.def @@ -0,0 +1 @@ +log_page_corruption : MDEV-26210 diff --git a/mysql-test/suite/mariabackup/drop_table_during_backup.result b/mysql-test/suite/mariabackup/drop_table_during_backup.result new file mode 100644 index 00000000..dfcde706 --- /dev/null +++ b/mysql-test/suite/mariabackup/drop_table_during_backup.result @@ -0,0 +1,19 @@ +CREATE TABLE t1 (i int) ENGINE=INNODB; +CREATE TABLE t2 (i int) ENGINE=INNODB; +CREATE TABLE t3 (i int) ENGINE=INNODB; +CREATE TABLE t4 (i int) ENGINE=INNODB; +CREATE TABLE t5 (i int) ENGINE=INNODB; +set global innodb_log_checkpoint_now=1; +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +CREATE TABLE t1(i int); +DROP TABLE t1; +CREATE TABLE t2(i int); +DROP TABLE t2; +DROP TABLE t3; +CREATE TABLE t4(i int); +DROP TABLE t4; +DROP TABLE t5; diff --git a/mysql-test/suite/mariabackup/drop_table_during_backup.test b/mysql-test/suite/mariabackup/drop_table_during_backup.test new file mode 100644 index 00000000..2ac82945 --- /dev/null +++ b/mysql-test/suite/mariabackup/drop_table_during_backup.test @@ -0,0 +1,35 @@ +--source include/have_debug.inc +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +CREATE TABLE t1 (i int) ENGINE=INNODB; +CREATE TABLE t2 (i int) ENGINE=INNODB; +CREATE TABLE t3 (i int) ENGINE=INNODB; +CREATE TABLE t4 (i int) ENGINE=INNODB; +CREATE TABLE t5 (i int) ENGINE=INNODB; + +set global innodb_log_checkpoint_now=1; + +--let before_copy_test_t1=DROP TABLE test.t1 +--let after_copy_test_t2=DROP TABLE test.t2; +# MDEV-18185, drop + rename combination +--let after_copy_test_t5=BEGIN NOT ATOMIC DROP TABLE test.t5; RENAME TABLE test.t4 TO test.t5; END + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +#check that the table t1 does not exist in backup +CREATE TABLE t1(i int); +DROP TABLE t1; +CREATE TABLE t2(i int); +DROP TABLE t2; +DROP TABLE t3; +CREATE TABLE t4(i int); +DROP TABLE t4; +DROP TABLE t5; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.opt b/mysql-test/suite/mariabackup/encrypted_page_compressed.opt new file mode 100644 index 00000000..e5a02a1a --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.opt @@ -0,0 +1,6 @@ +--innodb-encryption-rotate-key-age=2 +--innodb-encryption-threads=4 +--innodb-tablespaces-encryption +--plugin-load-add=$FILE_KEY_MANAGEMENT_SO +--loose-file-key-management +--loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/logkey.txt diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.result b/mysql-test/suite/mariabackup/encrypted_page_compressed.result new file mode 100644 index 00000000..de4c966c --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.result @@ -0,0 +1,9 @@ +call mtr.add_suppression("InnoDB: Table `test`.`t1` has an unreadable root page"); +call mtr.add_suppression("InnoDB: Encrypted page .* in file .*test.t1\\.ibd looks corrupted; key_version=1"); +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes encrypted=yes; +insert into t1(b, c) values("mariadb", "mariabackup"); +# Corrupt the table +# restart +# xtrabackup backup +FOUND 1 /Database page corruption detected.*/ in backup.log +drop table t1; diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.test b/mysql-test/suite/mariabackup/encrypted_page_compressed.test new file mode 100644 index 00000000..54fffb7d --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.test @@ -0,0 +1,49 @@ +source include/have_file_key_management.inc; +call mtr.add_suppression("InnoDB: Table `test`.`t1` has an unreadable root page"); +call mtr.add_suppression("InnoDB: Encrypted page .* in file .*test.t1\\.ibd looks corrupted; key_version=1"); +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes encrypted=yes; +insert into t1(b, c) values("mariadb", "mariabackup"); + +let $MYSQLD_DATADIR=`select @@datadir`; +let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd; +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; + +--source include/shutdown_mysqld.inc + +--echo # Corrupt the table + +perl; +use strict; +use warnings; +use Fcntl qw(:DEFAULT :seek); + +my $ibd_file = $ENV{'t1_IBD'}; + +my $chunk; +my $page_size = $ENV{'INNODB_PAGE_SIZE'}; + +sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file"; +sysseek IBD_FILE, $page_size * 3 + 75, SEEK_CUR; +$chunk = '\xAA\xAA\xAA\xAA'; +syswrite IBD_FILE, $chunk, 4; + +close IBD_FILE; +EOF + +--source include/start_mysqld.inc + +echo # xtrabackup backup; +--disable_result_log +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --core-file > $backuplog; +--enable_result_log + +--let SEARCH_PATTERN=Database page corruption detected.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; + +drop table t1; +rmdir $targetdir; 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 00000000..3326f0ca --- /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 00000000..79e5f783 --- /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 new file mode 100644 index 00000000..74a6450a --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.opt @@ -0,0 +1,6 @@ +--innodb-encrypt-log=ON +--plugin-load-add=$FILE_KEY_MANAGEMENT_SO +--loose-file-key-management +--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 diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.result b/mysql-test/suite/mariabackup/encrypted_page_corruption.result new file mode 100644 index 00000000..b328d361 --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.result @@ -0,0 +1,9 @@ +call mtr.add_suppression("\\[ERROR\\] InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Table `test`\\.`t1` has an unreadable root page"); +CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB, encrypted=yes; +insert into t1 select repeat('a',100); +# Corrupt the table +# restart +# xtrabackup backup +FOUND 1 /Database page corruption detected.*/ in backup.log +drop table t1; diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.test b/mysql-test/suite/mariabackup/encrypted_page_corruption.test new file mode 100644 index 00000000..1beb020b --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.test @@ -0,0 +1,84 @@ +--source include/have_file_key_management.inc +--source include/innodb_page_size.inc + +call mtr.add_suppression("\\[ERROR\\] InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Table `test`\\.`t1` has an unreadable root page"); +CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB, encrypted=yes; +insert into t1 select repeat('a',100); + +let MYSQLD_DATADIR=`select @@datadir`; +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; + +--source include/shutdown_mysqld.inc + +--echo # Corrupt the table + +perl; +use strict; +use warnings; +use Fcntl qw(:DEFAULT :seek); +do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; + +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, $_, 58) || die "Cannot read t1.ibd\n"; +my $space = unpack("x[34]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"; + +# 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); + +my $polynomial = 0x82f63b78; # CRC-32C +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 + +--source include/start_mysqld.inc + +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 $expect_error +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extended-validation --target-dir=$targetdir --core-file > $backuplog; +--enable_result_log + + +--let SEARCH_PATTERN=Database page corruption detected.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; +rmdir $targetdir; + +# Due to very constructed nature of the "corruption" (faking checksums), the "corruption" won't be found without --extended-validation +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log + +drop table t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/error_during_copyback.result b/mysql-test/suite/mariabackup/error_during_copyback.result new file mode 100644 index 00000000..ba27f0f8 --- /dev/null +++ b/mysql-test/suite/mariabackup/error_during_copyback.result @@ -0,0 +1,10 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# xtrabackup backup +# xtrabackup prepare +# restart server +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/error_during_copyback.test b/mysql-test/suite/mariabackup/error_during_copyback.test new file mode 100644 index 00000000..3ec9fbfc --- /dev/null +++ b/mysql-test/suite/mariabackup/error_during_copyback.test @@ -0,0 +1,25 @@ +--source include/have_debug.inc +CREATE TABLE t(i INT) ENGINE INNODB; +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 +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +let $_datadir= `SELECT @@datadir`; +--source include/shutdown_mysqld.inc +rmdir $_datadir; +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir --dbug=+d,copy_file_error; +list_files $_datadir; +rmdir $_datadir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir; +echo # restart server; +--source include/start_mysqld.inc +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/extra_lsndir.result b/mysql-test/suite/mariabackup/extra_lsndir.result new file mode 100644 index 00000000..a25c45a1 --- /dev/null +++ b/mysql-test/suite/mariabackup/extra_lsndir.result @@ -0,0 +1,2 @@ +xtrabackup_checkpoints +xtrabackup_info diff --git a/mysql-test/suite/mariabackup/extra_lsndir.test b/mysql-test/suite/mariabackup/extra_lsndir.test new file mode 100644 index 00000000..092ee34c --- /dev/null +++ b/mysql-test/suite/mariabackup/extra_lsndir.test @@ -0,0 +1,9 @@ +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $extra_lsndir=$MYSQLTEST_VARDIR/tmp/extra_lsndir; +mkdir $extra_lsndir; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --extra-lsndir=$extra_lsndir; +--enable_result_log +list_files $extra_lsndir; +rmdir $extra_lsndir; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/extra_lsndir_stream.result b/mysql-test/suite/mariabackup/extra_lsndir_stream.result new file mode 100644 index 00000000..a25c45a1 --- /dev/null +++ b/mysql-test/suite/mariabackup/extra_lsndir_stream.result @@ -0,0 +1,2 @@ +xtrabackup_checkpoints +xtrabackup_info diff --git a/mysql-test/suite/mariabackup/extra_lsndir_stream.test b/mysql-test/suite/mariabackup/extra_lsndir_stream.test new file mode 100644 index 00000000..97023cb1 --- /dev/null +++ b/mysql-test/suite/mariabackup/extra_lsndir_stream.test @@ -0,0 +1,7 @@ +let $extra_lsndir=$MYSQLTEST_VARDIR/tmp/extra_lsndir; +mkdir $extra_lsndir; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --stream=xbstream --extra-lsndir=$extra_lsndir > /dev/null; +--enable_result_log +list_files $extra_lsndir; +rmdir $extra_lsndir; diff --git a/mysql-test/suite/mariabackup/filekeys-data.enc b/mysql-test/suite/mariabackup/filekeys-data.enc Binary files differnew file mode 100644 index 00000000..a8adb2f9 --- /dev/null +++ b/mysql-test/suite/mariabackup/filekeys-data.enc diff --git a/mysql-test/suite/mariabackup/filekeys-data.key b/mysql-test/suite/mariabackup/filekeys-data.key new file mode 100644 index 00000000..85fcd1fb --- /dev/null +++ b/mysql-test/suite/mariabackup/filekeys-data.key @@ -0,0 +1,2 @@ +secret + diff --git a/mysql-test/suite/mariabackup/full_backup.opt b/mysql-test/suite/mariabackup/full_backup.opt new file mode 100644 index 00000000..7928cd81 --- /dev/null +++ b/mysql-test/suite/mariabackup/full_backup.opt @@ -0,0 +1 @@ +--innodb_undo_tablespaces=2 diff --git a/mysql-test/suite/mariabackup/full_backup.result b/mysql-test/suite/mariabackup/full_backup.result new file mode 100644 index 00000000..1d0dffd5 --- /dev/null +++ b/mysql-test/suite/mariabackup/full_backup.result @@ -0,0 +1,30 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# xtrabackup backup +NOT FOUND /InnoDB: Allocated tablespace ID/ in backup.log +INSERT INTO t VALUES(2); +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; +# +# MDEV-27121 mariabackup incompatible with disabled dedicated +# undo log tablespaces +# +call mtr.add_suppression("InnoDB: innodb_undo_tablespaces=0 disables dedicated undo log tablespaces"); +call mtr.add_suppression("InnoDB: Cannot change innodb_undo_tablespaces=0 because previous shutdown was not with innodb_fast_shutdown=0"); +# restart: --innodb_undo_tablespaces=0 +# xtrabackup backup +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart: --innodb_undo_tablespaces=0 +# Display undo log files from target directory +undo001 +undo002 diff --git a/mysql-test/suite/mariabackup/full_backup.test b/mysql-test/suite/mariabackup/full_backup.test new file mode 100644 index 00000000..fb043f63 --- /dev/null +++ b/mysql-test/suite/mariabackup/full_backup.test @@ -0,0 +1,56 @@ +--source include/innodb_page_size.inc + +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--let $backup_log=$MYSQLTEST_VARDIR/tmp/backup.log + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backup_log 2>&1; +--enable_result_log + +# The following warning must not appear after MDEV-27343 fix +--let SEARCH_PATTERN=InnoDB: Allocated tablespace ID +--let SEARCH_FILE=$backup_log +--source include/search_pattern_in_file.inc +--remove_file $backup_log + +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; +DROP TABLE t; +rmdir $targetdir; + +--echo # +--echo # MDEV-27121 mariabackup incompatible with disabled dedicated +--echo # undo log tablespaces +--echo # +call mtr.add_suppression("InnoDB: innodb_undo_tablespaces=0 disables dedicated undo log tablespaces"); +call mtr.add_suppression("InnoDB: Cannot change innodb_undo_tablespaces=0 because previous shutdown was not with innodb_fast_shutdown=0"); + +let $restart_parameters=--innodb_undo_tablespaces=0; +--source include/restart_mysqld.inc + +echo # xtrabackup backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +--echo # Display undo log files from target directory +list_files $targetdir undo*; + +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/full_backup_win.result b/mysql-test/suite/mariabackup/full_backup_win.result new file mode 100644 index 00000000..940c7056 --- /dev/null +++ b/mysql-test/suite/mariabackup/full_backup_win.result @@ -0,0 +1,12 @@ +# +# MDEV-30492 Crash when use mariabackup.exe with config 'innodb_flush_method=async_unbuffered' +# +# xtrabackup backup +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +# +# End of 10.4 tests +# diff --git a/mysql-test/suite/mariabackup/full_backup_win.test b/mysql-test/suite/mariabackup/full_backup_win.test new file mode 100644 index 00000000..5a1d1c38 --- /dev/null +++ b/mysql-test/suite/mariabackup/full_backup_win.test @@ -0,0 +1,24 @@ +--source include/windows.inc + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--echo # +--echo # MDEV-30492 Crash when use mariabackup.exe with config 'innodb_flush_method=async_unbuffered' +--echo # + +echo # xtrabackup backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --innodb_flush_method=normal --backup --target-dir=$targetdir; +--enable_result_log + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --innodb-flush-method=async_unbuffered --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +rmdir $targetdir; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff b/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff new file mode 100644 index 00000000..29afd468 --- /dev/null +++ b/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff @@ -0,0 +1,11 @@ +@@ -1,8 +1,8 @@ + # + # MDEV-13416 mariabackup fails with EFAULT "Bad Address" + # +-# restart: --innodb-log-file-size=4M --innodb-encrypt-log=0 +-FOUND 1 /InnoDB: log sequence number 17596481011216/ in mysqld.1.err ++# restart ++FOUND 1 /redo log: [0-9.]*[KMGT]iB; LSN=17596481010687\b/ in mysqld.1.err + CREATE TABLE t(i INT) ENGINE=INNODB ENCRYPTED=YES; + INSERT INTO t VALUES(1); + # xtrabackup backup diff --git a/mysql-test/suite/mariabackup/huge_lsn.combinations b/mysql-test/suite/mariabackup/huge_lsn.combinations new file mode 100644 index 00000000..72938059 --- /dev/null +++ b/mysql-test/suite/mariabackup/huge_lsn.combinations @@ -0,0 +1,5 @@ +[strict_crc32] +--innodb-checksum-algorithm=strict_crc32 + +[strict_full_crc32] +--innodb-checksum-algorithm=strict_full_crc32 diff --git a/mysql-test/suite/mariabackup/huge_lsn.opt b/mysql-test/suite/mariabackup/huge_lsn.opt new file mode 100644 index 00000000..c65b76fb --- /dev/null +++ b/mysql-test/suite/mariabackup/huge_lsn.opt @@ -0,0 +1,10 @@ +--innodb-encrypt-log=ON +--innodb-tablespaces-encryption +--innodb-encrypt-tables=ON +--innodb-encryption-rotate-key-age=1 +--innodb-encryption-threads=4 +--plugin-load-add=$FILE_KEY_MANAGEMENT_SO +--loose-file-key-management +--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 diff --git a/mysql-test/suite/mariabackup/huge_lsn.result b/mysql-test/suite/mariabackup/huge_lsn.result new file mode 100644 index 00000000..503d13fc --- /dev/null +++ b/mysql-test/suite/mariabackup/huge_lsn.result @@ -0,0 +1,31 @@ +# +# MDEV-13416 mariabackup fails with EFAULT "Bad Address" +# +# restart: --innodb-log-file-size=4M --innodb-encrypt-log=0 +FOUND 1 /InnoDB: log sequence number 17596481011216/ in mysqld.1.err +CREATE TABLE t(i INT) ENGINE=INNODB ENCRYPTED=YES; +INSERT INTO t VALUES(1); +# xtrabackup backup +SET GLOBAL innodb_flush_log_at_trx_commit=1; +INSERT INTO t VALUES(2); +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +FLUSH TABLE t FOR EXPORT; +UNLOCK TABLES; +ALTER TABLE t DISCARD TABLESPACE; +ALTER TABLE t IMPORT TABLESPACE; +FLUSH TABLE t FOR EXPORT; +UNLOCK TABLES; +ALTER TABLE t DISCARD TABLESPACE; +ALTER TABLE t IMPORT TABLESPACE; +DROP TABLE t; +# shutdown server +# remove datadir +# xtrabackup move back +# restart diff --git a/mysql-test/suite/mariabackup/huge_lsn.test b/mysql-test/suite/mariabackup/huge_lsn.test new file mode 100644 index 00000000..8850e9d8 --- /dev/null +++ b/mysql-test/suite/mariabackup/huge_lsn.test @@ -0,0 +1,114 @@ +--source include/not_embedded.inc +--source include/have_file_key_management.inc + +--echo # +--echo # MDEV-13416 mariabackup fails with EFAULT "Bad Address" +--echo # + +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; +let MYSQLD_DATADIR=`select @@datadir`; + +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 +--source include/shutdown_mysqld.inc + +if ($MTR_COMBINATION_STRICT_CRC32) { +perl; +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; +substr($page,26,8) = pack("NN", 4096, ~1024); +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"; + +$file= "$ENV{MYSQLD_DATADIR}/ib_logfile0"; +open(FILE, ">", $file) || die "Unable to truncate $file\n"; +close(FILE) || "Unable to close $file\n"; +EOF +--let SEARCH_PATTERN= redo log: [0-9.]*[KMGT]iB; LSN=17596481010687\\b +} + +if (!$MTR_COMBINATION_STRICT_CRC32) { +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; +my $file= "$ENV{MYSQLD_DATADIR}/ib_logfile0"; +open(FILE, ">", $file) or die "Unable to open $file\n"; +binmode FILE; +my $extra_repeat = 139820; +# The desired log sequence number is 17596481011216 (0x1000fffffe10). +my $file_size=4<<20; +my $lsn_hi=4096,$lsn_lo=0xfffffe00 - $extra_repeat * 15; +my $polynomial = 0x82f63b78; # CRC-32C +my ($header, $checkpoint, $log); +$header = "Phys" . pack("x[4]NN", $lsn_hi, $lsn_lo - $file_size + 0x300f) . + "some Perl code" . pack("x[478]"); +$header .= pack("Nx[3584]", mycrc32($header, 0, $polynomial)); +$checkpoint = pack("NNNNx[44]", $lsn_hi, $lsn_lo, $lsn_hi, $lsn_lo); +$checkpoint .= pack("Nx[8128]", mycrc32($checkpoint, 0, $polynomial)); +$log = pack("CxxNN", 0xfa, $lsn_hi, $lsn_lo); +$log .= pack("CN", 0, mycrc32($log, 0, $polynomial)); + +# Write more than 2MiB of FILE_MODIFY mini-transactions to exercise the parser. +my $extra = pack("CCxa*", 0xb9, 127, "a/b.ibd"); +$extra .= pack("CN", 0, mycrc32($extra, 0, $polynomial)); + +print FILE $header, $checkpoint, $extra x ($extra_repeat - 1), $log; +seek(FILE, $file_size - 15, 0); +$extra = pack("CCxa*", 0xb9, 127, "c/d.ibd"); +$extra .= pack("CN", 1, mycrc32($extra, 0, $polynomial)); +print FILE $extra; +close(FILE) or die "Unable to close $file\n"; +EOF +--let SEARCH_PATTERN= InnoDB: log sequence number 17596481011216 +--let $restart_parameters=--innodb-log-file-size=4M --innodb-encrypt-log=0 +} + +--source include/start_mysqld.inc +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; +--source include/search_pattern_in_file.inc + +CREATE TABLE t(i INT) ENGINE=INNODB ENCRYPTED=YES; +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 +SET GLOBAL innodb_flush_log_at_trx_commit=1; +INSERT INTO t VALUES(2); +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +--let $restart_parameters= +--source include/restart_and_restore.inc +--enable_result_log +SELECT * FROM t; +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; +DROP TABLE t; +rmdir $targetdir; +let $targetdir= $targetdir_old; +exec $XTRABACKUP --prepare --target-dir=$targetdir; +--source include/restart_and_restore.inc +rmdir $targetdir_old; diff --git a/mysql-test/suite/mariabackup/include/corrupt-page.pl b/mysql-test/suite/mariabackup/include/corrupt-page.pl new file mode 100644 index 00000000..d5c75dbd --- /dev/null +++ b/mysql-test/suite/mariabackup/include/corrupt-page.pl @@ -0,0 +1,146 @@ +use strict; +use warnings; +use Fcntl qw(:DEFAULT :seek); +do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; + +sub corrupt_space_page_id { + my $file_name = shift; + my @pages_to_corrupt = @_; + + my $page_size = $ENV{INNODB_PAGE_SIZE}; + + sysopen my $ibd_file, $file_name, O_RDWR || die "Cannot open $file_name\n"; + sysread($ibd_file, $_, 38) || die "Cannot read $file_name\n"; + my $space = unpack("x[34]N", $_); + foreach my $page_no (@pages_to_corrupt) { + $space += 10; # generate wrong space id + sysseek($ibd_file, $page_size * $page_no, SEEK_SET) + || die "Cannot seek $file_name\n"; + + my $head = pack("Nx[18]", $page_no + 10); # generate wrong page number + my $body = chr(0) x ($page_size - 38 - 8); + + # 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; + } + close $ibd_file; +} + +sub extend_space { + my $file_name = shift; + my $n_pages = shift; + + my $page_size = $ENV{INNODB_PAGE_SIZE}; + my $page; + + sysopen my $ibd_file, $file_name, O_RDWR || die "Cannot open $file_name\n"; + sysread($ibd_file, $page, $page_size) + || die "Cannot read $file_name\n"; + my $size = unpack("N", substr($page, 46, 4)); + my $packed_new_size = pack("N", $size + $n_pages); + substr($page, 46, 4, $packed_new_size); + + my $head = substr($page, 4, 22); + my $body = substr($page, 38, $page_size - 38 - 8); + my $polynomial = 0x82f63b78; # CRC-32C + my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); + my $packed_ck = pack("N", $ck); + substr($page, 0, 4, $packed_ck); + substr($page, $page_size - 8, 4, $packed_ck); + + sysseek($ibd_file, 0, SEEK_SET) + || die "Cannot seek $file_name\n"; + die unless syswrite($ibd_file, $page, $page_size) == $page_size; + + sysseek($ibd_file, 0, SEEK_END) + || die "Cannot seek $file_name\n"; + my $pages_size = $page_size*$n_pages; + my $pages = chr(0) x $pages_size; + die unless syswrite($ibd_file, $pages, $pages_size) == $pages_size; + close $ibd_file; + return $size; +} + +sub die_if_page_is_not_zero { + my $file_name = shift; + my @pages_to_check = @_; + + no locale; + my $page_size = $ENV{INNODB_PAGE_SIZE}; + my $zero_page = chr(0) x $page_size; + sysopen my $ibd_file, $file_name, O_RDWR || die "Cannot open $file_name\n"; + foreach my $page_no_to_check (@pages_to_check) { + sysseek($ibd_file, $page_size*$page_no_to_check, SEEK_SET) || + die "Cannot seek $file_name\n"; + sysread($ibd_file, my $read_page, $page_size) || + die "Cannot read $file_name\n"; + die "The page $page_no_to_check is not zero-filed in $file_name" + if ($read_page cmp $zero_page); + } + close $ibd_file; +} + +sub print_corrupted_pages_file { + my $file_in = shift; + my $file_out = shift; + open my $fh, '<', $file_in || die $!; + my $line_number = 0; + my $space = {}; + my @spaces; + while (my $line = <$fh>) { + ++$line_number; + if ($line_number & 1) { + my ($name, $id) = split(/ /, $line); + $space->{name} = $name; + } + else { + $space->{pages} = $line; + push (@spaces, $space); + $space = {}; + } + } + close $fh; + my @sorted_spaces = sort { $a->{name} cmp $b->{name} } @spaces; + open $fh, '>', $file_out || die $!; + foreach my $space (@sorted_spaces) { + print $fh $space->{name}; + print $fh "\n"; + print $fh $space->{pages}; + } + close $fh; +} + +sub append_corrupted_pages { + my $file_name = shift; + my $space_name = shift; + my $pages = shift; + open my $fh, '<', $file_name || die $!; + my $line_number = 0; + my $space_line; + while (my $line = <$fh>) { + ++$line_number; + if ($line_number & 1) { + my ($name, $id) = split(/ /, $line); + if ($name eq $space_name) { + $space_line = $line; + last; + } + } + } + close $fh; + if (not defined $space_line) { + die "Can't find requested space $space_name in file $file_name"; + } + open $fh, '>>', $file_name || die $!; + print $fh $space_line; + print $fh "$pages\n"; + close $fh; +} diff --git a/mysql-test/suite/mariabackup/include/restart_and_restore.inc b/mysql-test/suite/mariabackup/include/restart_and_restore.inc new file mode 100644 index 00000000..aa26d28e --- /dev/null +++ b/mysql-test/suite/mariabackup/include/restart_and_restore.inc @@ -0,0 +1,8 @@ +let $_datadir= `SELECT @@datadir`; +echo # shutdown server; +--source include/shutdown_mysqld.inc +echo # remove datadir; +rmdir $_datadir; +echo # xtrabackup move back; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir --parallel=2 --throttle=1 $backup_opts; +--source include/start_mysqld.inc diff --git a/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc new file mode 100644 index 00000000..4a83c9c3 --- /dev/null +++ b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc @@ -0,0 +1,14 @@ +--disable_query_log +--file_exists $targetdir/xtrabackup_slave_info +CREATE TEMPORARY TABLE tmp_slave_info(lineno SERIAL, line TEXT); +--replace_result $targetdir TARGETDIR +--eval LOAD DATA LOCAL INFILE '$targetdir/xtrabackup_slave_info' INTO TABLE tmp_slave_info (line); +SELECT + lineno, + regexp_replace( + regexp_replace(line, '(?<=MASTER_LOG_POS=)[0-9]+', '<NUM>'), + '[0-9]+-[0-9]+-[0-9]+', '<NUM-NUM-NUM>') + AS line +FROM tmp_slave_info ORDER BY lineno; +DROP TEMPORARY TABLE tmp_slave_info; +--enable_query_log diff --git a/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc new file mode 100644 index 00000000..90b2d00b --- /dev/null +++ b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc @@ -0,0 +1,20 @@ +--disable_query_log +--file_exists $XTRABACKUP_OUT +CREATE TEMPORARY TABLE tmp_slave_info_out(lineno SERIAL, line TEXT); +--replace_result $targetdir TARGETDIR +--eval LOAD DATA LOCAL INFILE '$XTRABACKUP_OUT' INTO TABLE tmp_slave_info_out (line); +SELECT + replace( + regexp_replace( + regexp_replace(line, + '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]', + 'YYYY-MM-DD hh:mm:ss'), + '[0-9]+-[0-9]+-[0-9]+', '<NUM-NUM-NUM>'), + '\r','' /* Remove CR on Windows */) + AS line +FROM tmp_slave_info_out +WHERE line LIKE '%MySQL slave binlog position%' + OR line LIKE '%Failed to get master binlog coordinates%' +ORDER BY lineno; +DROP TEMPORARY TABLE tmp_slave_info_out; +--enable_query_log diff --git a/mysql-test/suite/mariabackup/incremental_backup.result b/mysql-test/suite/mariabackup/incremental_backup.result new file mode 100644 index 00000000..ed67ceee --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_backup.result @@ -0,0 +1,36 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t_aria(i INT) ENGINE ARIA; +CREATE TABLE t(i INT PRIMARY KEY) ENGINE INNODB; +INSERT INTO t VALUES(100); +BEGIN; +INSERT INTO t VALUES(2); +connect con1,localhost,root,,; +SET GLOBAL innodb_flush_log_at_trx_commit = 1; +INSERT INTO t VALUES(1); +# Create full backup , modify table, then create incremental/differential backup +BEGIN; +INSERT INTO t VALUES(0); +DELETE FROM t WHERE i=0; +connection default; +COMMIT; +# Generate enough aria log records to increase area log file size +SELECT * FROM t; +i +1 +2 +100 +# Prepare full backup, apply incremental one +# Aria log file was updated during applying incremental backup +disconnect con1; +# Restore and check results +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +2 +100 +DROP TABLE t; +DROP TABLE t_aria; diff --git a/mysql-test/suite/mariabackup/incremental_backup.test b/mysql-test/suite/mariabackup/incremental_backup.test new file mode 100644 index 00000000..62e4f9c6 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_backup.test @@ -0,0 +1,123 @@ +--source include/have_aria.inc +--source include/innodb_page_size.inc +--source include/innodb_undo_tablespaces.inc + +# see suite.pm "check for exact values, in case the default changes to be small everywhere" +if (`select @@max_binlog_stmt_cache_size = 4294963200 and @@innodb_page_size = 65536`) { + skip skipped on 32bit; # tries to allocate 1GB of memory + } + +call mtr.add_suppression("InnoDB: New log files created"); + +let $test_comp=`select @@innodb_page_size < 32768`; +let basedir=$MYSQLTEST_VARDIR/tmp/backup; +let incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +CREATE TABLE t_aria(i INT) ENGINE ARIA; +CREATE TABLE t(i INT PRIMARY KEY) ENGINE INNODB; +# MDEV-515 takes X-lock on the table for the first insert. +# So concurrent insert won't happen on the table +INSERT INTO t VALUES(100); +if ($test_comp) { + # If MDEV-28474 is not fixed, backup preparing will crash with SIGSEGV. + --disable_query_log + --disable_result_log + CREATE TABLE t_comp(i INT PRIMARY KEY) ENGINE INNODB ROW_FORMAT=COMPRESSED; + --enable_query_log + --enable_result_log +} +BEGIN; +INSERT INTO t VALUES(2); +connect (con1,localhost,root,,); +SET GLOBAL innodb_flush_log_at_trx_commit = 1; +INSERT INTO t VALUES(1); + +echo # Create full backup , modify table, then create incremental/differential backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=10 --target-dir=$basedir --throttle=1000; +--enable_result_log +BEGIN; +INSERT INTO t VALUES(0); +DELETE FROM t WHERE i=0; +connection default; +COMMIT; + +--echo # Generate enough aria log records to increase area log file size +--disable_query_log +--disable_result_log +INSERT INTO t_aria VALUES + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); +--let $i = 4 +while ($i) { +INSERT INTO t_aria SELECT * FROM seq_1_to_2000; +--dec $i +} +--enable_query_log +--enable_result_log + +SELECT * FROM t; +# wf_incremental_init() allocates (page_size/4)*page_size bytes with mmap() +# in each data file copy thread, what can fail on 32-bit platforms if threads +# are too much, that's why don't set too big --parallel option value. +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=2 --ftwrl-wait-timeout=5 --ftwrl-wait-threshold=300 --ftwrl-wait-query-type=all --target-dir=$incremental_dir --incremental-basedir=$basedir; + +--disable_result_log +echo # Prepare full backup, apply incremental one; +exec $XTRABACKUP --prepare --target-dir=$basedir; +exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir ; + +let perl_result_file=$MYSQLTEST_VARDIR/tmp/check_file_size_result.inc; + +--perl END_OF_FILE + use strict; + use warnings; + + my $dst_file = "$ENV{'basedir'}/aria_log.00000001"; + my $src_file = "$ENV{'incremental_dir'}/aria_log.00000001"; + my $out_file = $ENV{'perl_result_file'}; + + my $dst_size = -s $dst_file; + my $src_size = -s $src_file; + + open (my $output, '>', $out_file) or die $!; + if ($dst_size >= $src_size) { + print $output '--echo # Aria log file was updated during applying incremental backup'."\n"; + } + else { + print $output '--echo # Aria log file was NOT updated during applying incremental backup'."\n"; + } + close $output; +END_OF_FILE + +--source $perl_result_file +--remove_file $perl_result_file + +disconnect con1; +echo # Restore and check results; +let $targetdir=$basedir; +-- source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t; +DROP TABLE t; +if ($test_comp) { + --disable_query_log + --disable_result_log + DROP TABLE t_comp; + --enable_query_log + --enable_result_log +} +DROP TABLE t_aria; + +# Cleanup +rmdir $basedir; +rmdir $incremental_dir; diff --git a/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.result b/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.result new file mode 100644 index 00000000..e3f8bb24 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.result @@ -0,0 +1,18 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t1 (i INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); +CREATE DATABASE test1; +CREATE TABLE test1.t1 (a INT) ENGINE=InnoDB; +INSERT INTO test1.t1 VALUES (1000); +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t1; +i +0 +SELECT * FROM test1.t1; +a +1000 +DROP TABLE t1; +DROP DATABASE test1; diff --git a/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.test b/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.test new file mode 100644 index 00000000..a79d280b --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.test @@ -0,0 +1,35 @@ +--source include/have_innodb.inc + +call mtr.add_suppression("InnoDB: New log files created"); + +--let basedir=$MYSQLTEST_VARDIR/tmp/backup +--let incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1 + +CREATE TABLE t1 (i INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); + +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=10 --target-dir=$basedir +--enable_result_log + +CREATE DATABASE test1; +CREATE TABLE test1.t1 (a INT) ENGINE=InnoDB; +INSERT INTO test1.t1 VALUES (1000); + +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=2 --ftwrl-wait-timeout=5 --ftwrl-wait-threshold=300 --ftwrl-wait-query-type=all --target-dir=$incremental_dir --incremental-basedir=$basedir +--exec $XTRABACKUP --prepare --target-dir=$basedir +--exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir +--enable_result_log + +--let $targetdir=$basedir +--source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t1; +SELECT * FROM test1.t1; + +DROP TABLE t1; +DROP DATABASE test1; +--rmdir $basedir +--rmdir $incremental_dir diff --git a/mysql-test/suite/mariabackup/incremental_compressed.result b/mysql-test/suite/mariabackup/incremental_compressed.result new file mode 100644 index 00000000..f8b01808 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_compressed.result @@ -0,0 +1,18 @@ +# +# MDEV-18589 Assertion ...physical_size(flags) == info.page_size +# failed in xb_delta_open_matching_space +# +CREATE TABLE t (pk INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +ALTER TABLE t PARTITION BY KEY(pk); +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `pk` int(11) NOT NULL, + PRIMARY KEY (`pk`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPRESSED + PARTITION BY KEY (`pk`) +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/incremental_compressed.test b/mysql-test/suite/mariabackup/incremental_compressed.test new file mode 100644 index 00000000..15aff909 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_compressed.test @@ -0,0 +1,27 @@ +--source include/have_innodb.inc +--source include/have_partition.inc +--source include/innodb_undo_tablespaces.inc + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +--echo # +--echo # MDEV-18589 Assertion ...physical_size(flags) == info.page_size +--echo # failed in xb_delta_open_matching_space +--echo # + +CREATE TABLE t (pk INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; + +--exec $XTRABACKUP --backup --target-dir=$basedir --protocol=tcp --port=$MASTER_MYPORT --user=root + +ALTER TABLE t PARTITION BY KEY(pk); + +--exec $XTRABACKUP --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --protocol=tcp --port=$MASTER_MYPORT --user=root > $incremental_dir.log 2>&1 +--exec $XTRABACKUP --prepare --target-dir=$basedir --user=root > $MYSQL_TMP_DIR/backup_prepare_0.log 2>&1 +--exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir --user=root > $MYSQL_TMP_DIR/backup_prepare_1.log +--cat_file $MYSQL_TMP_DIR/backup_prepare_1.log +let $targetdir=$basedir; +-- source include/restart_and_restore.inc + +SHOW CREATE TABLE t; +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/incremental_ddl_before_backup.result b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.result new file mode 100644 index 00000000..71f250bf --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.result @@ -0,0 +1,32 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t1(i INT) ENGINE INNODB; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; +CREATE TABLE t3(i INT) ENGINE INNODB; +# Create full backup , modify table, then create incremental/differential backup +create table t4(f1 int not null, f2 int not null)engine=innodb; +insert into t4 values(1, 2), (2, 2), (3, 3), (5, 5), (6, 6), (4, 4), (9, 9); +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +rename table t4 to t7; +select count(*) from t7; +count(*) +7168 +# XTRABACKUP INCREMENTAL +# XTRABACKUP PREPARE +# XTRABACKUP INCREMENTAL PREPARE +# shutdown server +# remove datadir +# xtrabackup move back +# restart +select count(*) from t7; +count(*) +7168 +drop table t1, t2, t7, t3; diff --git a/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test new file mode 100644 index 00000000..6d34166d --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test @@ -0,0 +1,51 @@ +--source include/have_debug.inc +--source include/innodb_undo_tablespaces.inc + +call mtr.add_suppression("InnoDB: New log files created"); + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +CREATE TABLE t1(i INT) ENGINE INNODB; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; +CREATE TABLE t3(i INT) ENGINE INNODB; + +echo # Create full backup , modify table, then create incremental/differential backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +create table t4(f1 int not null, f2 int not null)engine=innodb; +insert into t4 values(1, 2), (2, 2), (3, 3), (5, 5), (6, 6), (4, 4), (9, 9); +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +rename table t4 to t7; +select count(*) from t7; + +--echo # XTRABACKUP INCREMENTAL +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir; + +--echo # XTRABACKUP PREPARE +exec $XTRABACKUP --prepare --target-dir=$basedir; + +--echo # XTRABACKUP INCREMENTAL PREPARE +exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir; + +let $targetdir=$basedir; +-- source include/restart_and_restore.inc +--enable_result_log + +select count(*) from t7; +drop table t1, t2, t7, t3; + +# Cleanup +rmdir $basedir; +rmdir $incremental_dir; diff --git a/mysql-test/suite/mariabackup/incremental_ddl_during_backup.result b/mysql-test/suite/mariabackup/incremental_ddl_during_backup.result new file mode 100644 index 00000000..ab5f237b --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_ddl_during_backup.result @@ -0,0 +1,24 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; +CREATE TABLE t3(i INT) ENGINE INNODB; +CREATE TABLE t10(i INT PRIMARY KEY) ENGINE INNODB; +set global innodb_log_checkpoint_now = 1; +# Create full backup , modify table, then create incremental/differential backup +INSERT into t1 values(1); +# Prepare full backup, apply incremental one +# Restore and check results +# shutdown server +# remove datadir +# xtrabackup move back +# restart +CREATE TABLE t1(i int); +DROP TABLE t1; +SELECT * from t1_renamed; +i +1 +DROP TABLE t1_renamed; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE t4; diff --git a/mysql-test/suite/mariabackup/incremental_ddl_during_backup.test b/mysql-test/suite/mariabackup/incremental_ddl_during_backup.test new file mode 100644 index 00000000..d9c6a72b --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_ddl_during_backup.test @@ -0,0 +1,59 @@ +--source include/have_debug.inc +--source include/innodb_undo_tablespaces.inc + +call mtr.add_suppression("InnoDB: New log files created"); + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; +CREATE TABLE t3(i INT) ENGINE INNODB; +CREATE TABLE t10(i INT PRIMARY KEY) ENGINE INNODB; + +set global innodb_log_checkpoint_now = 1; + +echo # Create full backup , modify table, then create incremental/differential backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +INSERT into t1 values(1); + +--let after_load_tablespaces=CREATE TABLE test.t4 ENGINE=INNODB SELECT UUID() from test.seq_1_to_10000 +--let after_copy_test_t1=RENAME TABLE test.t1 TO test.t1_renamed +--let after_copy_test_t2=DROP TABLE test.t2 +--let after_copy_test_t3=CREATE INDEX a_i ON test.t3(i); +--let before_copy_test_t10=DROP TABLE test.t10 +--let wait_innodb_redo_before_copy_test_t10 = 1 + +# mariabackup should crash with assertion if MDEV-24026 is not fixed +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events,mariabackup_inject_code; +--let after_load_tablespaces= +--disable_result_log +echo # Prepare full backup, apply incremental one; +exec $XTRABACKUP --prepare --target-dir=$basedir; +exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir ; + +echo # Restore and check results; +let $targetdir=$basedir; +-- source include/restart_and_restore.inc +--enable_result_log + +# Test that t1 does not exist, but t1_renamed does +CREATE TABLE t1(i int); +DROP TABLE t1; + +SELECT * from t1_renamed; +DROP TABLE t1_renamed; + +# Test that t2 does not exist; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; +DROP TABLE t2; + +DROP TABLE t3; +DROP TABLE t4; + +# Cleanup +rmdir $basedir; +rmdir $incremental_dir; diff --git a/mysql-test/suite/mariabackup/incremental_drop_db.result b/mysql-test/suite/mariabackup/incremental_drop_db.result new file mode 100644 index 00000000..3a6c89f8 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_drop_db.result @@ -0,0 +1,30 @@ +call mtr.add_suppression("InnoDB: New log files created"); +# +# Start of 10.3 tests +# +# +# MDEV-23335 MariaBackup Incremental Does Not Reflect Dropped/Created Databases +# +CREATE DATABASE db1; +CREATE DATABASE db2; +CREATE TABLE db1.t1 (a INT) ENGINE=MyISAM; +CREATE TABLE db1.t2 (a INT) ENGINE=InnoDB; +# Create base backup +DROP DATABASE db1; +# Create incremental backup +# Remove incremental_dir/db2/db.opt file to make incremental_dir/db2/ empty +# Prepare base backup, apply incremental one +# shutdown server +# remove datadir +# xtrabackup move back +# restart +# Expect no 'db1' in the output, because it was really dropped. +# Expect 'db2' in the ouput, because it was not dropped! +# (its incremental directory was emptied only) +SHOW DATABASES LIKE 'db%'; +Database (db%) +db2 +DROP DATABASE db2; +# +# End of 10.3 tests +# diff --git a/mysql-test/suite/mariabackup/incremental_drop_db.test b/mysql-test/suite/mariabackup/incremental_drop_db.test new file mode 100644 index 00000000..de270435 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_drop_db.test @@ -0,0 +1,68 @@ +--source include/have_innodb.inc +call mtr.add_suppression("InnoDB: New log files created"); + +--echo # +--echo # Start of 10.3 tests +--echo # + +--echo # +--echo # MDEV-23335 MariaBackup Incremental Does Not Reflect Dropped/Created Databases +--echo # + +--let $datadir=`SELECT @@datadir` +--let $basedir=$MYSQLTEST_VARDIR/tmp/backup +--let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1 + +# Create two databases: +# - db1 is dropped normally below +# - db2 is used to cover a corner case: its db.opt file is removed + +# Incremental backup contains: +# - no directory for db1 +# - an empty directory for db2 (after we remove db2/db.opt) + + +CREATE DATABASE db1; +CREATE DATABASE db2; + +# Add some tables to db1 +CREATE TABLE db1.t1 (a INT) ENGINE=MyISAM; +CREATE TABLE db1.t2 (a INT) ENGINE=InnoDB; + +--echo # Create base backup +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir +--enable_result_log + +DROP DATABASE db1; + +--echo # Create incremental backup +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir + +--echo # Remove incremental_dir/db2/db.opt file to make incremental_dir/db2/ empty +--remove_file $incremental_dir/db2/db.opt + + +--echo # Prepare base backup, apply incremental one +--disable_result_log +--exec $XTRABACKUP --prepare --target-dir=$basedir +--exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir +--enable_result_log + +--let $targetdir=$basedir +--source include/restart_and_restore.inc +--enable_result_log + +--echo # Expect no 'db1' in the output, because it was really dropped. +--echo # Expect 'db2' in the ouput, because it was not dropped! +--echo # (its incremental directory was emptied only) + +SHOW DATABASES LIKE 'db%'; +DROP DATABASE db2; + +--rmdir $basedir +--rmdir $incremental_dir + +--echo # +--echo # End of 10.3 tests +--echo # diff --git a/mysql-test/suite/mariabackup/incremental_encrypted.opt b/mysql-test/suite/mariabackup/incremental_encrypted.opt new file mode 100644 index 00000000..ea644cef --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_encrypted.opt @@ -0,0 +1,3 @@ +--innodb-tablespaces-encryption +--plugin-load-add=$DEBUG_KEY_MANAGEMENT_SO +--loose-debug_key_management_version=2 diff --git a/mysql-test/suite/mariabackup/incremental_encrypted.result b/mysql-test/suite/mariabackup/incremental_encrypted.result new file mode 100644 index 00000000..6a23f399 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_encrypted.result @@ -0,0 +1,21 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t(i INT) ENGINE INNODB ENCRYPTED=YES; +INSERT INTO t VALUES(1); +# Create full backup , modify table, then create incremental/differential backup +SET GLOBAL innodb_flush_log_at_trx_commit = 1; +INSERT INTO t VALUES(2); +SELECT * FROM t; +i +1 +2 +# Prepare full backup, apply incremental one +# Restore and check results +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +2 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/incremental_encrypted.test b/mysql-test/suite/mariabackup/incremental_encrypted.test new file mode 100644 index 00000000..d5570f20 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_encrypted.test @@ -0,0 +1,44 @@ +--source include/innodb_page_size.inc +--source include/innodb_undo_tablespaces.inc + +if (!$EXAMPLE_KEY_MANAGEMENT_SO) +{ + --skip needs example_key_management plugin +} +call mtr.add_suppression("InnoDB: New log files created"); + + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + + +CREATE TABLE t(i INT) ENGINE INNODB ENCRYPTED=YES; +INSERT INTO t VALUES(1); + + +echo # Create full backup , modify table, then create incremental/differential backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +SET GLOBAL innodb_flush_log_at_trx_commit = 1; +INSERT INTO t VALUES(2); +SELECT * FROM t; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir; +echo # Prepare full backup, apply incremental one; +exec $XTRABACKUP --prepare --target-dir=$basedir; +exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir; + +echo # Restore and check results; +let $targetdir=$basedir; +-- source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t; +DROP TABLE t; + +# Cleanup +rmdir $basedir; +rmdir $incremental_dir; diff --git a/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result new file mode 100644 index 00000000..ac74893d --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result @@ -0,0 +1,24 @@ +call mtr.add_suppression("InnoDB: New log files created"); +# +# Start of 10.2 tests +# +# +# MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken +# +CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; +# Prepare full backup, apply incremental one +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT COUNT(*) FROM test.t1; +COUNT(*) +0 +SELECT COUNT(*) FROM test1.t1; +COUNT(*) +10000 +DROP TABLE t1; +DROP DATABASE test1; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test new file mode 100644 index 00000000..6bd69712 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test @@ -0,0 +1,48 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/innodb_undo_tablespaces.inc + +call mtr.add_suppression("InnoDB: New log files created"); + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken +--echo # + +--let $basedir=$MYSQLTEST_VARDIR/tmp/backup +--let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1 + +CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; + +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir +--enable_result_log + +--let after_load_tablespaces=BEGIN NOT ATOMIC CREATE DATABASE test1; CREATE TABLE test1.t1 ENGINE=INNODB SELECT UUID() from test.seq_1_to_10000; END + +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events,mariabackup_inject_code +--let after_load_tablespaces= +--disable_result_log +--echo # Prepare full backup, apply incremental one +--exec $XTRABACKUP --prepare --target-dir=$basedir +--exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir +--enable_result_log + +--let $targetdir=$basedir +--source include/restart_and_restore.inc +--enable_result_log + +SELECT COUNT(*) FROM test.t1; +SELECT COUNT(*) FROM test1.t1; + +DROP TABLE t1; +DROP DATABASE test1; +--rmdir $basedir +--rmdir $incremental_dir + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/mariabackup/incremental_page_compressed.result b/mysql-test/suite/mariabackup/incremental_page_compressed.result new file mode 100644 index 00000000..eb059cdc --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_page_compressed.result @@ -0,0 +1,13 @@ +# +# MDEV-26794 MariaBackup does not recognize added providers upon prepare of incremental backup +# +CREATE TABLE t (a INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1),(2); +INSTALL SONAME 'provider_snappy'; +SET GLOBAL innodb_compression_algorithm= snappy; +CREATE TABLE t_snappy (a INT) ENGINE=InnoDB page_compressed=1; +INSERT INTO t_snappy VALUES (3),(4); +# restart: --innodb_buffer_pool_load_at_startup=0 +# Prepare initial backup +# Prepare incremental backup +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/incremental_page_compressed.test b/mysql-test/suite/mariabackup/incremental_page_compressed.test new file mode 100644 index 00000000..f6ec26cf --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_page_compressed.test @@ -0,0 +1,38 @@ +--echo # +--echo # MDEV-26794 MariaBackup does not recognize added providers upon prepare of incremental backup +--echo # + +if (!$PROVIDER_SNAPPY_SO) { + skip "Needs provider_snappy plugin"; +} + +--source include/have_innodb.inc + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--let $incdir=$MYSQLTEST_VARDIR/tmp/inc + +CREATE TABLE t (a INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1),(2); + +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir + +INSTALL SONAME 'provider_snappy'; + +SET GLOBAL innodb_compression_algorithm= snappy; + +CREATE TABLE t_snappy (a INT) ENGINE=InnoDB page_compressed=1; +INSERT INTO t_snappy VALUES (3),(4); + +# disable buffer pool load to avoid MDEV-26794 warnings +--let $restart_parameters= --innodb_buffer_pool_load_at_startup=0 +--source include/restart_mysqld.inc + +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --incremental-basedir=$targetdir --target-dir=$incdir + +--echo # Prepare initial backup +--exec $XTRABACKUP --prepare --target-dir=$targetdir + +--echo # Prepare incremental backup +--exec $XTRABACKUP --prepare --target-dir=$targetdir --incremental-dir=$incdir > $MYSQLTEST_VARDIR/prepare.log 2>&1 + +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/incremental_rocksdb.opt b/mysql-test/suite/mariabackup/incremental_rocksdb.opt new file mode 100644 index 00000000..e582413e --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_rocksdb.opt @@ -0,0 +1 @@ +--plugin-load=$HA_ROCKSDB_SO
\ No newline at end of file diff --git a/mysql-test/suite/mariabackup/incremental_rocksdb.result b/mysql-test/suite/mariabackup/incremental_rocksdb.result new file mode 100644 index 00000000..f319b466 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_rocksdb.result @@ -0,0 +1,19 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t(i INT PRIMARY KEY) ENGINE ROCKSDB; +INSERT INTO t VALUES(1); +# Create full backup , modify table, then create incremental/differential backup +DROP TABLE t; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE ROCKSDB; +INSERT INTO t2 VALUES(2); +# Prepare full backup, apply incremental one +# Restore and check results +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t2; +i +2 +DROP TABLE t2; +DROP TABLE t; +ERROR 42S02: Unknown table 'test.t' diff --git a/mysql-test/suite/mariabackup/incremental_rocksdb.test b/mysql-test/suite/mariabackup/incremental_rocksdb.test new file mode 100644 index 00000000..32bce885 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_rocksdb.test @@ -0,0 +1,38 @@ +--source include/have_rocksdb.inc +call mtr.add_suppression("InnoDB: New log files created"); + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +CREATE TABLE t(i INT PRIMARY KEY) ENGINE ROCKSDB; +INSERT INTO t VALUES(1); + +echo # Create full backup , modify table, then create incremental/differential backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log +DROP TABLE t; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE ROCKSDB; +INSERT INTO t2 VALUES(2); +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir; + +--disable_result_log +echo # Prepare full backup, apply incremental one; +exec $XTRABACKUP --prepare --target-dir=$basedir; + +exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir ; + +echo # Restore and check results; +let $targetdir=$basedir; +-- source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t2; +DROP TABLE t2; +--error ER_BAD_TABLE_ERROR +DROP TABLE t; + +# Cleanup +rmdir $basedir; +rmdir $incremental_dir; + diff --git a/mysql-test/suite/mariabackup/innodb_force_recovery.result b/mysql-test/suite/mariabackup/innodb_force_recovery.result new file mode 100644 index 00000000..6626bb0b --- /dev/null +++ b/mysql-test/suite/mariabackup/innodb_force_recovery.result @@ -0,0 +1,26 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# "innodb_force_recovery=1" should be allowed with "--prepare" only (mariabackup) +FOUND 1 /should only be used with "--prepare"/ in backup.log +# "innodb_force_recovery=1" should be allowed with "--apply-log" only (innobackupex) +FOUND 1 /should only be used with "--apply-log"/ in backup.log +# "innodb_force_recovery" should be limited to "SRV_FORCE_IGNORE_CORRUPT" (mariabackup) +FOUND 1 /innodb_force_recovery = 1/ in backup.log +# "innodb_force_recovery" should be limited to "SRV_FORCE_IGNORE_CORRUPT" (innobackupex) +FOUND 1 /innodb_force_recovery = 1/ in backup.log +# "innodb_force_recovery" should be read from "backup-my.cnf" (mariabackup) +FOUND 1 /innodb_force_recovery = 1/ in backup.log +# "innodb_force_recovery=1" should be read from "backup-my.cnf" (innobackupex) +FOUND 1 /innodb_force_recovery = 1/ in backup.log +# "innodb_force_recovery" from the command line should override "backup-my.cnf" (mariabackup) +NOT FOUND /innodb_force_recovery = 1/ in backup.log +# "innodb_force_recovery" from the command line should override "backup-my.cnf" (innobackupex) +NOT FOUND /innodb_force_recovery = 1/ in backup.log +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/innodb_force_recovery.test b/mysql-test/suite/mariabackup/innodb_force_recovery.test new file mode 100644 index 00000000..3a7b3c61 --- /dev/null +++ b/mysql-test/suite/mariabackup/innodb_force_recovery.test @@ -0,0 +1,138 @@ +# This test checks if "innodb_force_recovery" is only allowed with "--prepare" +# (for mariabackup) and "--apply-log" (for innobackupex), and is limited to +# "SRV_FORCE_IGNORE_CORRUPT" only. + +# Setup. +--source include/have_innodb.inc + +--let targetdir=$MYSQLTEST_VARDIR/tmp/backup +--let backuplog=$MYSQLTEST_VARDIR/tmp/backup.log + +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); + +# Check for command line arguments. +--echo # "innodb_force_recovery=1" should be allowed with "--prepare" only (mariabackup) +--disable_result_log +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --innodb-force-recovery=1 --target-dir=$targetdir >$backuplog; +--enable_result_log +--let SEARCH_PATTERN=should only be used with "--prepare" +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc + +--echo # "innodb_force_recovery=1" should be allowed with "--apply-log" only (innobackupex) +--disable_result_log +--error 1 +exec $XTRABACKUP --innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp --innodb-force-recovery=1 $targetdir >$backuplog; +--enable_result_log +--let SEARCH_PATTERN=should only be used with "--apply-log" +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log +--echo # "innodb_force_recovery" should be limited to "SRV_FORCE_IGNORE_CORRUPT" (mariabackup) +--disable_result_log +exec $XTRABACKUP --prepare --innodb-force-recovery=2 --target-dir=$targetdir >$backuplog; +--enable_result_log +--let SEARCH_PATTERN=innodb_force_recovery = 1 +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +rmdir $targetdir; + +--disable_result_log +exec $XTRABACKUP --innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp $targetdir; +--enable_result_log +--echo # "innodb_force_recovery" should be limited to "SRV_FORCE_IGNORE_CORRUPT" (innobackupex) +--disable_result_log +exec $XTRABACKUP --innobackupex --apply-log --innodb-force-recovery=2 $targetdir >$backuplog; +--enable_result_log +--let SEARCH_PATTERN=innodb_force_recovery = 1 +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +rmdir $targetdir; + +# Check for default file ("backup-my.cnf"). +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log +perl; +my $cfg_path="$ENV{'targetdir'}/backup-my.cnf"; +open(my $fd, '>>', "$cfg_path"); +print $fd "innodb_force_recovery=1\n"; +close $fd; +EOF +--echo # "innodb_force_recovery" should be read from "backup-my.cnf" (mariabackup) +--disable_result_log +exec $XTRABACKUP --defaults-file=$targetdir/backup-my.cnf --prepare --export --target-dir=$targetdir >$backuplog; +--enable_result_log +--let SEARCH_PATTERN=innodb_force_recovery = 1 +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +rmdir $targetdir; + +--disable_result_log +exec $XTRABACKUP --innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp $targetdir; +--enable_result_log +perl; +my $cfg_path="$ENV{'targetdir'}/backup-my.cnf"; +open(my $fd, '>>', "$cfg_path"); +print $fd "innodb_force_recovery=2\n"; +close $fd; +EOF +--echo # "innodb_force_recovery=1" should be read from "backup-my.cnf" (innobackupex) +--disable_result_log +exec $XTRABACKUP --innobackupex --defaults-file=$targetdir/backup-my.cnf --apply-log --export $targetdir >$backuplog; +--enable_result_log +--let SEARCH_PATTERN=innodb_force_recovery = 1 +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +rmdir $targetdir; + +# Check for command line argument precedence. +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log +perl; +my $cfg_path="$ENV{'targetdir'}/backup-my.cnf"; +open(my $fd, '>>', "$cfg_path"); +print $fd "innodb_force_recovery=1\n"; +close $fd; +EOF +--echo # "innodb_force_recovery" from the command line should override "backup-my.cnf" (mariabackup) +--disable_result_log +exec $XTRABACKUP --defaults-file=$targetdir/backup-my.cnf --prepare --innodb-force-recovery=0 --target-dir=$targetdir >$backuplog; +--enable_result_log +--let SEARCH_PATTERN=innodb_force_recovery = 1 +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +rmdir $targetdir; + +--disable_result_log +exec $XTRABACKUP --innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp $targetdir; +--enable_result_log +perl; +my $cfg_path="$ENV{'targetdir'}/backup-my.cnf"; +open(my $fd, '>>', "$cfg_path"); +print $fd "innodb_force_recovery=2\n"; +close $fd; +EOF +--echo # "innodb_force_recovery" from the command line should override "backup-my.cnf" (innobackupex) +--disable_result_log +exec $XTRABACKUP --innobackupex --defaults-file=$targetdir/backup-my.cnf --apply-log --innodb-force-recovery=0 --export $targetdir >$backuplog; +--enable_result_log +--let SEARCH_PATTERN=innodb_force_recovery = 1 +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc + +--source include/restart_and_restore.inc + +# Check for restore. +SELECT * FROM t; + +# Clean-up. +DROP TABLE t; +--rmdir $targetdir +--remove_file $backuplog diff --git a/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.opt b/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.opt new file mode 100644 index 00000000..a0b4b588 --- /dev/null +++ b/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.opt @@ -0,0 +1 @@ +--loose-innodb-log-file-size=4194304 diff --git a/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.result b/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.result new file mode 100644 index 00000000..29abe038 --- /dev/null +++ b/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.result @@ -0,0 +1,2 @@ +CREATE TABLE t(i INT) ENGINE=INNODB; +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.test b/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.test new file mode 100644 index 00000000..8bbd4e76 --- /dev/null +++ b/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.test @@ -0,0 +1,21 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_sequence.inc +--source include/no_valgrind_without_big.inc + +CREATE TABLE t(i INT) ENGINE=INNODB; + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup + +# Generate enough redo log records to make at least one loop in log group +--let before_innodb_log_copy_thread_started=INSERT INTO test.t SELECT * from test.seq_1_to_102400 + +--disable_result_log +# mariabackup must exit with error instead of hanging +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +DROP TABLE t; +--rmdir $targetdir + diff --git a/mysql-test/suite/mariabackup/innodb_redo_overwrite.opt b/mysql-test/suite/mariabackup/innodb_redo_overwrite.opt new file mode 100644 index 00000000..a0b4b588 --- /dev/null +++ b/mysql-test/suite/mariabackup/innodb_redo_overwrite.opt @@ -0,0 +1 @@ +--loose-innodb-log-file-size=4194304 diff --git a/mysql-test/suite/mariabackup/innodb_redo_overwrite.result b/mysql-test/suite/mariabackup/innodb_redo_overwrite.result new file mode 100644 index 00000000..bab5d433 --- /dev/null +++ b/mysql-test/suite/mariabackup/innodb_redo_overwrite.result @@ -0,0 +1,5 @@ +CREATE TABLE t ENGINE=INNODB SELECT seq%10 i FROM seq_0_to_204796; +# xtrabackup backup +FOUND 1 /Was only able to copy log from \d+ to \d+, not \d+; try increasing innodb_log_file_size\b/ in backup.log +NOT FOUND /failed: redo log block checksum does not match/ in backup.log +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/innodb_redo_overwrite.test b/mysql-test/suite/mariabackup/innodb_redo_overwrite.test new file mode 100644 index 00000000..ab5993d2 --- /dev/null +++ b/mysql-test/suite/mariabackup/innodb_redo_overwrite.test @@ -0,0 +1,41 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/have_debug.inc +--source include/have_sequence.inc +--source include/no_valgrind_without_big.inc + +CREATE TABLE t ENGINE=INNODB SELECT seq%10 i FROM seq_0_to_204796; + +--echo # xtrabackup backup +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log + +--let before_innodb_log_copy_thread_started=INSERT INTO test.t SELECT * FROM test.t + +--disable_result_log +--error 1 +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events > $backuplog +--enable_result_log + +--let SEARCH_PATTERN=Was only able to copy log from \\d+ to \\d+, not \\d+; try increasing innodb_log_file_size\\b +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +--remove_file $backuplog +--rmdir $targetdir + +--let before_innodb_log_copy_thread_started=INSERT INTO test.t SELECT seq FROM seq_0_to_9 + +--disable_result_log +--error 1 +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events,log_checksum_mismatch > $backuplog +--enable_result_log + +--let SEARCH_PATTERN=failed: redo log block checksum does not match +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +--remove_file $backuplog +--rmdir $targetdir + +--let before_innodb_log_copy_thread_started= + +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/lock_ddl_per_table.opt b/mysql-test/suite/mariabackup/lock_ddl_per_table.opt new file mode 100644 index 00000000..bbb6d7f9 --- /dev/null +++ b/mysql-test/suite/mariabackup/lock_ddl_per_table.opt @@ -0,0 +1 @@ +--loose-partition diff --git a/mysql-test/suite/mariabackup/lock_ddl_per_table.result b/mysql-test/suite/mariabackup/lock_ddl_per_table.result new file mode 100644 index 00000000..c1b28e46 --- /dev/null +++ b/mysql-test/suite/mariabackup/lock_ddl_per_table.result @@ -0,0 +1,12 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# xtrabackup backup +CREATE TABLE `bobby``tables` (id INT, name VARCHAR(50), purchased DATE) ENGINE INNODB PARTITION BY RANGE( YEAR(purchased) ) ( +PARTITION p0 VALUES LESS THAN (1990), +PARTITION p1 VALUES LESS THAN (1995), +PARTITION p2 VALUES LESS THAN (2000), +PARTITION p3 VALUES LESS THAN (2005) +) ; +set global innodb_log_checkpoint_now = 1; +DROP TABLE t; +DROP TABLE `bobby``tables`; diff --git a/mysql-test/suite/mariabackup/lock_ddl_per_table.test b/mysql-test/suite/mariabackup/lock_ddl_per_table.test new file mode 100644 index 00000000..18c20771 --- /dev/null +++ b/mysql-test/suite/mariabackup/lock_ddl_per_table.test @@ -0,0 +1,23 @@ +--source include/have_debug.inc +--source include/have_partition.inc + +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE `bobby``tables` (id INT, name VARCHAR(50), purchased DATE) ENGINE INNODB PARTITION BY RANGE( YEAR(purchased) ) ( + PARTITION p0 VALUES LESS THAN (1990), + PARTITION p1 VALUES LESS THAN (1995), + PARTITION p2 VALUES LESS THAN (2000), + PARTITION p3 VALUES LESS THAN (2005) +) ; + +set global innodb_log_checkpoint_now = 1; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --lock-ddl-per-table=1 --dbug=+d,check_mdl_lock_works; +--enable_result_log +DROP TABLE t; +DROP TABLE `bobby``tables`; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/log_checksum_mismatch.result b/mysql-test/suite/mariabackup/log_checksum_mismatch.result new file mode 100644 index 00000000..31bd9dcc --- /dev/null +++ b/mysql-test/suite/mariabackup/log_checksum_mismatch.result @@ -0,0 +1,14 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# xtrabackup backup +FOUND 1 /Invalid log block checksum/ in backup.log +INSERT INTO t VALUES(2); +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/log_checksum_mismatch.test b/mysql-test/suite/mariabackup/log_checksum_mismatch.test new file mode 100644 index 00000000..c8baf66e --- /dev/null +++ b/mysql-test/suite/mariabackup/log_checksum_mismatch.test @@ -0,0 +1,32 @@ +--source include/have_debug.inc + +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,log_intermittent_checksum_mismatch --core-file > $backuplog; +--enable_result_log + +--let SEARCH_RANGE = 10000000 +--let SEARCH_PATTERN=Invalid log block checksum +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; + + +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; +DROP TABLE t; +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/log_copy_interval.result b/mysql-test/suite/mariabackup/log_copy_interval.result new file mode 100644 index 00000000..678fc6cc --- /dev/null +++ b/mysql-test/suite/mariabackup/log_copy_interval.result @@ -0,0 +1,2 @@ +# xtrabackup backup +NOT FOUND /sleep_after_waiting_for_lsn\n(\[\d+\] \d+-\d+-\d+ \d+:\d+:\d+ >> log scanned up to \(\d+\)\n){2}/ in backup.log diff --git a/mysql-test/suite/mariabackup/log_copy_interval.test b/mysql-test/suite/mariabackup/log_copy_interval.test new file mode 100644 index 00000000..5ea09c53 --- /dev/null +++ b/mysql-test/suite/mariabackup/log_copy_interval.test @@ -0,0 +1,18 @@ +--source include/have_debug.inc + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--let $backup_log=$MYSQLTEST_VARDIR/tmp/backup.log + +--let sleep_after_waiting_for_lsn=250 +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --log-copy-interval=500 --dbug=+d,mariabackup_inject_code > $backup_log 2>&1; +--enable_result_log + +--let SEARCH_PATTERN=sleep_after_waiting_for_lsn\n(\[\d+\] \d+-\d+-\d+ \d+:\d+:\d+ >> log scanned up to \(\d+\)\n){2} +--let SEARCH_FILE=$backup_log +--source include/search_pattern_in_file.inc +--remove_file $backup_log + +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/log_page_corruption.opt b/mysql-test/suite/mariabackup/log_page_corruption.opt new file mode 100644 index 00000000..c44c611e --- /dev/null +++ b/mysql-test/suite/mariabackup/log_page_corruption.opt @@ -0,0 +1 @@ +--innodb-checksum-algorithm=crc32 diff --git a/mysql-test/suite/mariabackup/log_page_corruption.result b/mysql-test/suite/mariabackup/log_page_corruption.result new file mode 100644 index 00000000..3772a6c0 --- /dev/null +++ b/mysql-test/suite/mariabackup/log_page_corruption.result @@ -0,0 +1,174 @@ +######## +# Test for generating "innodb_corrupted_pages" file during full and +# incremental backup, including DDL processing +### + +CREATE TABLE t1_corrupted(c INT) ENGINE INNODB; +CREATE TABLE t2_corrupted(c INT) ENGINE INNODB; +CREATE TABLE t3(c INT) ENGINE INNODB; +CREATE TABLE t5_corrupted_to_rename(c INT) ENGINE INNODB; +CREATE TABLE t6_corrupted_to_drop(c INT) ENGINE INNODB; +CREATE TABLE t7_corrupted_to_alter(c INT) ENGINE INNODB; +CREATE TABLE t1_inc_corrupted(c INT) ENGINE INNODB; +CREATE TABLE t2_inc_corrupted(c INT) ENGINE INNODB; +CREATE TABLE t3_inc(c INT) ENGINE INNODB; +CREATE TABLE t5_inc_corrupted_to_rename(c INT) ENGINE INNODB; +CREATE TABLE t6_inc_corrupted_to_drop(c INT) ENGINE INNODB; +CREATE TABLE t7_inc_corrupted_to_alter(c INT) ENGINE INNODB; +INSERT INTO t1_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t2_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t3 VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t5_corrupted_to_rename VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t6_corrupted_to_drop VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t7_corrupted_to_alter VALUES (3), (4), (5), (6), (7), (8), (9); +# Corrupt tables +# restart +# Backup must fail due to page corruption +FOUND 1 /Database page corruption detected.*/ in backup.log +# "innodb_corrupted_pages" file must not exist +# Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option, and the file must contain all corrupted pages info, including those, which are supposed to be absent in the next test due to "DROP TABLE" execution during backup +--- "innodb_corrupted_pages" file content: --- +test/t1_corrupted +4 6 7 +test/t2_corrupted +5 6 8 +test/t5_corrupted_to_rename +4 +test/t6_corrupted_to_drop +4 +------ +# Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option +FOUND 1 /Database page corruption detected.*/ in backup.log +FOUND 1 /completed OK!/ in backup.log +--- "innodb_corrupted_pages" file content: --- +test/t1_corrupted +4 6 7 +test/t2_corrupted +5 6 8 +test/t4_corrupted_new +1 +test/t5_corrupted_to_rename_renamed +4 +test/t7_corrupted_to_alter +3 +------ +INSERT INTO t1_inc_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t2_inc_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t3_inc VALUES (3), (4), (5), (6), (7), (8), (9); +# restart +# Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option, and the file must contain all corrupted pages info, including those, which are supposed to be absent in the next test due to "DROP TABLE" execution during backup +--- "innodb_corrupted_pages" file content: --- +test/t1_corrupted +4 6 7 +test/t1_inc_corrupted +4 6 7 +test/t2_corrupted +5 6 8 +test/t2_inc_corrupted +5 6 8 +test/t5_corrupted_to_rename_renamed +4 +test/t5_inc_corrupted_to_rename +4 +test/t6_inc_corrupted_to_drop +4 +------ +# Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option +--- "innodb_corrupted_pages" file content: --- +test/t1_corrupted +4 6 7 +test/t1_inc_corrupted +4 6 7 +test/t2_corrupted +5 6 8 +test/t2_inc_corrupted +5 6 8 +test/t4_inc_corrupted_new +1 +test/t5_corrupted_to_rename_renamed +4 +test/t5_inc_corrupted_to_rename_renamed +4 +test/t7_inc_corrupted_to_alter +3 +------ +# Check if corrupted pages were copied to delta files, and non-corrupted pages are not copied. +DROP TABLE t1_corrupted; +DROP TABLE t2_corrupted; +DROP TABLE t4_corrupted_new; +DROP TABLE t5_corrupted_to_rename_renamed; +DROP TABLE t7_corrupted_to_alter; +DROP TABLE t1_inc_corrupted; +DROP TABLE t2_inc_corrupted; +DROP TABLE t4_inc_corrupted_new; +DROP TABLE t5_inc_corrupted_to_rename_renamed; +DROP TABLE t7_inc_corrupted_to_alter; + +######## +# Test for --prepare with "innodb_corrupted_pages" file +### + +# Extend some tablespace and corrupt extended pages for full backup +# restart +# Full backup with --log-innodb-page-corruption +--- "innodb_corrupted_pages" file content: --- +test/t3 +4 6 +------ +# Extend some tablespace and corrupt extended pages for incremental backup +# restart +# Incremental backup --log-innodb-page-corruption +--- "innodb_corrupted_pages" file content: --- +test/t3 +4 6 +test/t3_inc +4 6 +------ +# Full backup prepare +# "innodb_corrupted_pages" file must not exist after successful prepare +FOUND 1 /was successfully fixed.*/ in backup.log +# Check that fixed pages are zero-filled +# Incremental backup prepare +# "innodb_corrupted_pages" file must not exist after successful prepare +# do not remove "innodb_corrupted_pages" in incremental dir +FOUND 1 /was successfully fixed.*/ in backup.log +# Check that fixed pages are zero-filled +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t3; +c +3 +4 +5 +6 +7 +8 +9 +SELECT * FROM t3_inc; +c +3 +4 +5 +6 +7 +8 +9 +# Test the case when not all corrupted pages are fixed + +# Add some fake corrupted pages +# Full backup prepare +FOUND 1 /Error: corrupted page.*/ in backup.log +--- "innodb_corrupted_pages" file content: --- +test/t3 +3 +------ +# Incremental backup prepare +FOUND 1 /Error: corrupted page.*/ in backup.log +--- "innodb_corrupted_pages" file content: --- +test/t3 +3 +------ +DROP TABLE t3; +DROP TABLE t3_inc; diff --git a/mysql-test/suite/mariabackup/log_page_corruption.test b/mysql-test/suite/mariabackup/log_page_corruption.test new file mode 100644 index 00000000..18d773bd --- /dev/null +++ b/mysql-test/suite/mariabackup/log_page_corruption.test @@ -0,0 +1,464 @@ +--source include/have_debug.inc +--source include/no_valgrind_without_big.inc +--source include/innodb_undo_tablespaces.inc + +--echo ######## +--echo # Test for generating "innodb_corrupted_pages" file during full and +--echo # incremental backup, including DDL processing +--echo ### +--echo + +CREATE TABLE t1_corrupted(c INT) ENGINE INNODB; +CREATE TABLE t2_corrupted(c INT) ENGINE INNODB; +CREATE TABLE t3(c INT) ENGINE INNODB; +CREATE TABLE t5_corrupted_to_rename(c INT) ENGINE INNODB; +CREATE TABLE t6_corrupted_to_drop(c INT) ENGINE INNODB; +CREATE TABLE t7_corrupted_to_alter(c INT) ENGINE INNODB; + +CREATE TABLE t1_inc_corrupted(c INT) ENGINE INNODB; +CREATE TABLE t2_inc_corrupted(c INT) ENGINE INNODB; +CREATE TABLE t3_inc(c INT) ENGINE INNODB; +CREATE TABLE t5_inc_corrupted_to_rename(c INT) ENGINE INNODB; +CREATE TABLE t6_inc_corrupted_to_drop(c INT) ENGINE INNODB; +CREATE TABLE t7_inc_corrupted_to_alter(c INT) ENGINE INNODB; + +# Fill tables with several pages +INSERT INTO t1_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t2_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t3 VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t5_corrupted_to_rename VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t6_corrupted_to_drop VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t7_corrupted_to_alter VALUES (3), (4), (5), (6), (7), (8), (9); + +--let MYSQLD_DATADIR=`select @@datadir` +--let INNODB_PAGE_SIZE=`select @@innodb_page_size` + +--source include/shutdown_mysqld.inc +--echo # Corrupt tables +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +my $schema = "$ENV{MYSQLD_DATADIR}/test"; + +my $last_page_no = extend_space("$schema/t1_corrupted.ibd", 4); +corrupt_space_page_id("$schema/t1_corrupted.ibd", + $last_page_no, $last_page_no + 2, $last_page_no + 3); + +$last_page_no = extend_space("$schema/t2_corrupted.ibd", 5); +corrupt_space_page_id("$schema/t2_corrupted.ibd", + $last_page_no + 1, $last_page_no + 2, $last_page_no + 4); + +$last_page_no = extend_space("$schema/t5_corrupted_to_rename.ibd", 1); +corrupt_space_page_id("$schema/t5_corrupted_to_rename.ibd", $last_page_no); + +$last_page_no = extend_space("$schema/t6_corrupted_to_drop.ibd", 1); +corrupt_space_page_id("$schema/t6_corrupted_to_drop.ibd", $last_page_no); +EOF +--source include/start_mysqld.inc + +--let targetdir=$MYSQLTEST_VARDIR/tmp/backup +--let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log +--let corrupted_pages_file = $targetdir/innodb_corrupted_pages +--let corrupted_pages_file_filt = $MYSQLTEST_VARDIR/tmp/innodb_corrupted_pages_filt +--let perl_result_file=$MYSQLTEST_VARDIR/tmp/perl_result + +--echo # Backup must fail due to page corruption +--disable_result_log +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog; +--enable_result_log + +--let SEARCH_PATTERN=Database page corruption detected.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +--echo # "innodb_corrupted_pages" file must not exist +--error 1 +--file_exists $corrupted_pages_file +--rmdir $targetdir + +--echo # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option, and the file must contain all corrupted pages info, including those, which are supposed to be absent in the next test due to "DROP TABLE" execution during backup +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$targetdir +--enable_result_log + +--echo --- "innodb_corrupted_pages" file content: --- +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +print_corrupted_pages_file($ENV{corrupted_pages_file}, + $ENV{corrupted_pages_file_filt}); +EOF +--cat_file $corrupted_pages_file_filt +--echo ------ +--rmdir $targetdir + +--let after_load_tablespaces=CREATE TABLE test.t4_corrupted_new ENGINE=INNODB SELECT UUID() from test.seq_1_to_10 +--let add_corrupted_page_for_test_t4_corrupted_new=1 +--let after_copy_test_t5_corrupted_to_rename=RENAME TABLE test.t5_corrupted_to_rename TO test.t5_corrupted_to_rename_renamed +--let after_copy_test_t6_corrupted_to_drop=DROP TABLE test.t6_corrupted_to_drop +--let after_copy_test_t7_corrupted_to_alter=ALTER TABLE test.t7_corrupted_to_alter ADD COLUMN (d INT) +--let add_corrupted_page_for_test_t7_corrupted_to_alter=3 + +--echo # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog +--enable_result_log + +--let SEARCH_PATTERN=Database page corruption detected.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc + +--let SEARCH_PATTERN=completed OK! +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc + +--echo --- "innodb_corrupted_pages" file content: --- +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +print_corrupted_pages_file($ENV{corrupted_pages_file}, + $ENV{corrupted_pages_file_filt}); +EOF +--cat_file $corrupted_pages_file_filt +--echo ------ +--let after_load_tablespaces= +--let add_corrupted_page_for_test_t4_corrupted_new= +--let after_copy_test_t5_corrupted_to_rename= +--let after_copy_test_t6_corrupted_to_drop= +--let after_copy_test_t7_corrupted_to_alter= +--let add_corrupted_page_for_test_t7_corrupted_to_alter= +# Fill tables for incremental backup with several pages +INSERT INTO t1_inc_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t2_inc_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); +INSERT INTO t3_inc VALUES (3), (4), (5), (6), (7), (8), (9); + +--source include/shutdown_mysqld.inc +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +my $schema="$ENV{MYSQLD_DATADIR}/test"; + +open(my $fh, '>', $ENV{perl_result_file}) or die $!; + +my $last_page_no = extend_space("$schema/t1_inc_corrupted.ibd", 4); +corrupt_space_page_id("$schema/t1_inc_corrupted.ibd", + $last_page_no, $last_page_no + 2, $last_page_no + 3); +print $fh "$last_page_no\n"; + +$last_page_no = extend_space("$schema/t2_inc_corrupted.ibd", 5); +corrupt_space_page_id("$schema/t2_inc_corrupted.ibd", + $last_page_no + 1, $last_page_no + 2, $last_page_no + 4); +print $fh "$last_page_no\n"; + +$last_page_no = extend_space("$schema/t5_inc_corrupted_to_rename.ibd", 1); +corrupt_space_page_id("$schema/t5_inc_corrupted_to_rename.ibd", $last_page_no); +print $fh "$last_page_no\n"; + +$last_page_no = extend_space("$schema/t6_inc_corrupted_to_drop.ibd", 1); +corrupt_space_page_id("$schema/t6_inc_corrupted_to_drop.ibd", $last_page_no); + +close $fh; +EOF +--source include/start_mysqld.inc + +--let incdir=$MYSQLTEST_VARDIR/tmp/backup_inc + +--echo # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option, and the file must contain all corrupted pages info, including those, which are supposed to be absent in the next test due to "DROP TABLE" execution during backup +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$incdir --incremental-basedir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code +--disable_result_log + +--let corrupted_pages_file = $incdir/innodb_corrupted_pages +--echo --- "innodb_corrupted_pages" file content: --- +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +print_corrupted_pages_file($ENV{corrupted_pages_file}, + $ENV{corrupted_pages_file_filt}); +EOF +--cat_file $corrupted_pages_file_filt +--echo ------ +--remove_file $corrupted_pages_file_filt +--rmdir $incdir + +--let after_load_tablespaces=CREATE TABLE test.t4_inc_corrupted_new ENGINE=INNODB SELECT UUID() from test.seq_1_to_10 +--let add_corrupted_page_for_test_t4_inc_corrupted_new=1 +--let after_copy_test_t5_inc_corrupted_to_rename=RENAME TABLE test.t5_inc_corrupted_to_rename TO test.t5_inc_corrupted_to_rename_renamed +--let after_copy_test_t6_inc_corrupted_to_drop=DROP TABLE test.t6_inc_corrupted_to_drop +--let after_copy_test_t7_inc_corrupted_to_alter=ALTER TABLE test.t7_inc_corrupted_to_alter ADD COLUMN (d INT) +--let add_corrupted_page_for_test_t7_inc_corrupted_to_alter=3 + +--echo # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$incdir --incremental-basedir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog +--disable_result_log + +--let after_load_tablespaces= +--let add_corrupted_page_for_test_t4_inc_corrupted_new= +--let after_copy_test_t5_inc_corrupted_to_rename= +--let after_copy_test_t6_inc_corrupted_to_drop= +--let after_copy_test_t7_inc_corrupted_to_alter= +--let add_corrupted_page_for_test_t7_inc_corrupted_to_alter= + +--let SEARCH_PATTERN=Database page corruption detected.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=completed OK! +--source include/search_pattern_in_file.inc + +--let corrupted_pages_file = $incdir/innodb_corrupted_pages +--echo --- "innodb_corrupted_pages" file content: --- +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +print_corrupted_pages_file($ENV{corrupted_pages_file}, + $ENV{corrupted_pages_file_filt}); +EOF +--cat_file $corrupted_pages_file_filt +--echo ------ + +--echo # Check if corrupted pages were copied to delta files, and non-corrupted pages are not copied. +perl; +use strict; +use warnings; +my $schema = "$ENV{incdir}/test"; + +open(my $fh, '<', $ENV{perl_result_file}) or die $!; + +my $last_page_no = <$fh>; +die_if_no_pages("$schema/t1_corrupted.ibd.delta", + $last_page_no, $last_page_no + 2, $last_page_no + 3); + +$last_page_no = <$fh>; +die_if_no_pages("$schema/t2_corrupted.ibd.delta", + $last_page_no + 1, $last_page_no + 2, $last_page_no + 4); + +$last_page_no = <$fh>; +die_if_no_pages("$schema/t5_corrupted_to_rename_renamed.ibd.delta", + $last_page_no); + +close $fh; + +die_if_not_empty("$schema/t3.ibd.delta"); + +sub read_first_page_from_delta { + my $file_name = shift; + my $pages_count = shift; + + open my $file, '<:raw', $file_name || die "Cannot open $file_name\n"; + read $file, my $buffer, $pages_count*4 || die "Cannot read $file_name\n"; + close $file; + + return unpack("N[$pages_count]", $buffer); +} + +sub die_if_no_pages { + my $file_name = shift; + my @check_pages = @_; + my @read_pages = + read_first_page_from_delta($file_name, scalar(@check_pages) + 1); + for (my $i = 1; $i < @check_pages + 1; ++$i) { + my $check_page_no = $check_pages[$i - 1]; + die "Corrupted page $check_page_no was not copied to $file_name." + if ($i >= @read_pages || $read_pages[$i] != $check_page_no); + } +} + +sub die_if_not_empty { + my $file_name = shift; + my ($magic, $full) = read_first_page_from_delta($file_name, 2); + die "Delta $file_name must be empty." + if ($full != 0xFFFFFFFF); +} +EOF +--rmdir $incdir +--rmdir $targetdir + +DROP TABLE t1_corrupted; +DROP TABLE t2_corrupted; +DROP TABLE t4_corrupted_new; +DROP TABLE t5_corrupted_to_rename_renamed; +DROP TABLE t7_corrupted_to_alter; +DROP TABLE t1_inc_corrupted; +DROP TABLE t2_inc_corrupted; +DROP TABLE t4_inc_corrupted_new; +DROP TABLE t5_inc_corrupted_to_rename_renamed; +DROP TABLE t7_inc_corrupted_to_alter; + +--echo +--echo ######## +--echo # Test for --prepare with "innodb_corrupted_pages" file +--echo ### +--echo + +--echo # Extend some tablespace and corrupt extended pages for full backup +--source include/shutdown_mysqld.inc +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +my $schema="$ENV{MYSQLD_DATADIR}/test"; +my $last_page_no = extend_space("$schema/t3.ibd", 3); +corrupt_space_page_id("$schema/t3.ibd", $last_page_no, $last_page_no + 2); +open(my $fh, '>', $ENV{perl_result_file}) or die $!; +print $fh "$last_page_no\n"; +close $fh; +EOF +--source include/start_mysqld.inc + +--echo # Full backup with --log-innodb-page-corruption +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$targetdir +--enable_result_log +--let corrupted_pages_file = $targetdir/innodb_corrupted_pages +--echo --- "innodb_corrupted_pages" file content: --- +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +print_corrupted_pages_file($ENV{corrupted_pages_file}, + $ENV{corrupted_pages_file_filt}); +EOF +--cat_file $corrupted_pages_file_filt +--echo ------ + +--echo # Extend some tablespace and corrupt extended pages for incremental backup +--source include/shutdown_mysqld.inc +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +my $schema="$ENV{MYSQLD_DATADIR}/test"; +my $last_page_no = extend_space("$schema/t3_inc.ibd", 3); +corrupt_space_page_id("$schema/t3_inc.ibd", $last_page_no, $last_page_no + 2); +open(my $fh, '>>', $ENV{perl_result_file}) or die $!; +print $fh "$last_page_no"; +close $fh; +EOF +--source include/start_mysqld.inc + +--echo # Incremental backup --log-innodb-page-corruption +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$incdir --incremental-basedir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog +--disable_result_log +--let corrupted_pages_file = $incdir/innodb_corrupted_pages +--echo --- "innodb_corrupted_pages" file content: --- +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +print_corrupted_pages_file($ENV{corrupted_pages_file}, + $ENV{corrupted_pages_file_filt}); +EOF +--cat_file $corrupted_pages_file_filt +--echo ------ + +--let targetdir2=$targetdir-2 +--let incdir2=$incdir-2 +perl; +use lib "lib"; +use My::Handles { suppress_init_messages => 1 }; +use My::File::Path; +copytree($ENV{'targetdir'}, $ENV{'targetdir2'}); +copytree($ENV{'incdir'}, $ENV{'incdir2'}); +EOF + +--echo # Full backup prepare +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir > $backuplog; +--enable_result_log + +--echo # "innodb_corrupted_pages" file must not exist after successful prepare +--error 1 +--file_exists $targetdir/innodb_corrupted_pages +--let SEARCH_PATTERN=was successfully fixed.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc + +--echo # Check that fixed pages are zero-filled +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +open(my $fh, '<', $ENV{perl_result_file}) or die $!; +my $last_page_no = <$fh>; +close $fh; +my $schema = "$ENV{targetdir}/test"; +die_if_page_is_not_zero("$schema/t3.ibd", $last_page_no, $last_page_no + 2); +EOF + +--echo # Incremental backup prepare +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir --incremental-dir=$incdir > $backuplog; +--enable_result_log + +--echo # "innodb_corrupted_pages" file must not exist after successful prepare +--error 1 +--file_exists $targetdir/innodb_corrupted_pages +--echo # do not remove "innodb_corrupted_pages" in incremental dir +--file_exists $incdir/innodb_corrupted_pages +--let SEARCH_PATTERN=was successfully fixed.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc + +--echo # Check that fixed pages are zero-filled +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +open(my $fh, '<', $ENV{perl_result_file}) or die $!; +my $last_page_no_full = <$fh>; +my $last_page_no_inc = <$fh>; +close $fh; +my $schema = "$ENV{targetdir}/test"; +die_if_page_is_not_zero("$schema/t3.ibd", + $last_page_no_full, $last_page_no_full + 2); +die_if_page_is_not_zero("$schema/t3_inc.ibd", + $last_page_no_inc, $last_page_no_inc + 2); +EOF + +--source include/restart_and_restore.inc + +SELECT * FROM t3; +SELECT * FROM t3_inc; + +--echo # Test the case when not all corrupted pages are fixed +--echo +--echo # Add some fake corrupted pages +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +append_corrupted_pages( + "$ENV{targetdir2}/innodb_corrupted_pages", 'test/t3', '3 4'); +append_corrupted_pages( + "$ENV{incdir2}/innodb_corrupted_pages", 'test/t3_inc', '4 5'); +EOF + +--echo # Full backup prepare +--disable_result_log +--error 1 +exec $XTRABACKUP --prepare --target-dir=$targetdir2 > $backuplog; +--enable_result_log + +--let SEARCH_PATTERN=Error: corrupted page.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +--let corrupted_pages_file = $targetdir2/innodb_corrupted_pages +--echo --- "innodb_corrupted_pages" file content: --- +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +print_corrupted_pages_file($ENV{corrupted_pages_file}, + $ENV{corrupted_pages_file_filt}); +EOF +--cat_file $corrupted_pages_file_filt +--echo ------ + +--echo # Incremental backup prepare +--disable_result_log +--error 1 +exec $XTRABACKUP --prepare --target-dir=$targetdir2 --incremental-dir=$incdir2 > $backuplog; +--enable_result_log + +--let SEARCH_PATTERN=Error: corrupted page.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +--let corrupted_pages_file = $targetdir2/innodb_corrupted_pages +--echo --- "innodb_corrupted_pages" file content: --- +perl; +do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; +print_corrupted_pages_file($ENV{corrupted_pages_file}, + $ENV{corrupted_pages_file_filt}); +EOF +--cat_file $corrupted_pages_file_filt +--echo ------ + +DROP TABLE t3; +DROP TABLE t3_inc; +--remove_file $backuplog +--remove_file $perl_result_file +--remove_file $corrupted_pages_file_filt +--rmdir $targetdir +--rmdir $targetdir2 +--rmdir $incdir +--rmdir $incdir2 diff --git a/mysql-test/suite/mariabackup/mdev-14447.combinations b/mysql-test/suite/mariabackup/mdev-14447.combinations new file mode 100644 index 00000000..79e5f783 --- /dev/null +++ b/mysql-test/suite/mariabackup/mdev-14447.combinations @@ -0,0 +1,5 @@ +[crc32] +--innodb-checksum-algorithm=crc32 + +[full_crc32] +--innodb-checksum-algorithm=full_crc32 diff --git a/mysql-test/suite/mariabackup/mdev-14447.opt b/mysql-test/suite/mariabackup/mdev-14447.opt new file mode 100644 index 00000000..5ac67e95 --- /dev/null +++ b/mysql-test/suite/mariabackup/mdev-14447.opt @@ -0,0 +1 @@ +--sequence --innodb-data-file-path=ibdata_first:3M;ibdata_second:1M:autoextend
\ No newline at end of file diff --git a/mysql-test/suite/mariabackup/mdev-14447.result b/mysql-test/suite/mariabackup/mdev-14447.result new file mode 100644 index 00000000..16d3ab56 --- /dev/null +++ b/mysql-test/suite/mariabackup/mdev-14447.result @@ -0,0 +1,22 @@ +call mtr.add_suppression("InnoDB: New log files created"); +SET GLOBAL innodb_file_per_table=0; +CREATE TABLE t(a varchar(40) PRIMARY KEY, b varchar(40), c varchar(40), d varchar(40), index(b,c,d)) ENGINE INNODB; +# Create full backup , modify table, then create incremental/differential backup +SET debug_dbug='+d,skip_page_checksum',foreign_key_checks=0,unique_checks=0; +BEGIN; +INSERT INTO t select uuid(), uuid(), uuid(), uuid() from seq_1_to_100000; +COMMIT; +SELECT count(*) FROM t; +count(*) +100000 +# Prepare full backup, apply incremental one +# Restore and check results +# shutdown server +# remove datadir +# xtrabackup move back +# restart server +# restart +SELECT count(*) FROM t; +count(*) +100000 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/mdev-14447.test b/mysql-test/suite/mariabackup/mdev-14447.test new file mode 100644 index 00000000..79a0d075 --- /dev/null +++ b/mysql-test/suite/mariabackup/mdev-14447.test @@ -0,0 +1,51 @@ +--source include/have_debug.inc +# This test is slow on buildbot. +--source include/big_test.inc +call mtr.add_suppression("InnoDB: New log files created"); + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +SET GLOBAL innodb_file_per_table=0; +CREATE TABLE t(a varchar(40) PRIMARY KEY, b varchar(40), c varchar(40), d varchar(40), index(b,c,d)) ENGINE INNODB; + +echo # Create full backup , modify table, then create incremental/differential backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +SET debug_dbug='+d,skip_page_checksum',foreign_key_checks=0,unique_checks=0; +BEGIN; +INSERT INTO t select uuid(), uuid(), uuid(), uuid() from seq_1_to_100000; +COMMIT; +SELECT count(*) FROM t; + +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,page_intermittent_checksum_mismatch; + +--disable_result_log +echo # Prepare full backup, apply incremental one; +exec $XTRABACKUP --prepare --verbose --target-dir=$basedir; + +exec $XTRABACKUP --prepare --verbose --target-dir=$basedir --incremental-dir=$incremental_dir ; + +echo # Restore and check results; +let $targetdir=$basedir; + +let $_datadir= `SELECT @@datadir`; +let $innodb_data_file_path=`SELECT @@innodb_data_file_path`; +echo # shutdown server; +--source include/shutdown_mysqld.inc +echo # remove datadir; +rmdir $_datadir; +echo # xtrabackup move back; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir "--innodb_data_file_path=$innodb_data_file_path" --target-dir=$targetdir; +echo # restart server; +--source include/start_mysqld.inc + +--enable_result_log +SELECT count(*) FROM t; +DROP TABLE t; + +# Cleanup +rmdir $basedir; +rmdir $incremental_dir; diff --git a/mysql-test/suite/mariabackup/mdev-18438.result b/mysql-test/suite/mariabackup/mdev-18438.result new file mode 100644 index 00000000..ab3b81bd --- /dev/null +++ b/mysql-test/suite/mariabackup/mdev-18438.result @@ -0,0 +1 @@ +stream.xb diff --git a/mysql-test/suite/mariabackup/mdev-18438.test b/mysql-test/suite/mariabackup/mdev-18438.test new file mode 100644 index 00000000..a6ec4547 --- /dev/null +++ b/mysql-test/suite/mariabackup/mdev-18438.test @@ -0,0 +1,11 @@ +let $basedir=$MYSQLTEST_VARDIR/tmp/mdev-18438; +mkdir $basedir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extra-lsndir=$basedir/extra_lsndir --stream=xbstream > $basedir/stream.xb; +mkdir $basedir/backup; +rmdir $basedir/extra_lsndir; +--disable_result_log +exec $XBSTREAM -x -C $basedir/backup < $basedir/stream.xb; +--enable_result_log +rmdir $basedir/backup; +list_files $basedir; +rmdir $basedir; diff --git a/mysql-test/suite/mariabackup/missing_ibd.result b/mysql-test/suite/mariabackup/missing_ibd.result new file mode 100644 index 00000000..1ad18e8b --- /dev/null +++ b/mysql-test/suite/mariabackup/missing_ibd.result @@ -0,0 +1,7 @@ +create table t1(c1 int) engine=InnoDB; +INSERT INTO t1 VALUES(1); +# restart +# xtrabackup backup +select * from t1; +ERROR HY000: Got error 194 "Tablespace is missing for a table" from storage engine InnoDB +drop table t1; diff --git a/mysql-test/suite/mariabackup/missing_ibd.test b/mysql-test/suite/mariabackup/missing_ibd.test new file mode 100644 index 00000000..f406a555 --- /dev/null +++ b/mysql-test/suite/mariabackup/missing_ibd.test @@ -0,0 +1,34 @@ +--source include/have_innodb.inc + +# +# MDEV-13499: Backing up table that "doesn't exist in engine" cause crash in mariabackup when using encryption +# +create table t1(c1 int) engine=InnoDB; +INSERT INTO t1 VALUES(1); +let MYSQLD_DATADIR=`select @@datadir`; + +--disable_query_log +call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: '.*test.t1\.ibd'"); +call mtr.add_suppression('InnoDB: (Operating system error number|Error number \\d+ means)'); +call mtr.add_suppression('InnoDB: The error means the system cannot find the path specified\.'); +call mtr.add_suppression('InnoDB: Table test/t1 in the InnoDB data dictionary has tablespace id .*, but tablespace with that id or name does not exist'); +call mtr.add_suppression('InnoDB: Ignoring tablespace for test/t1 because it could not be opened\.'); +--enable_query_log + +--source include/shutdown_mysqld.inc + +--remove_file $MYSQLD_DATADIR/test/t1.ibd + +--source include/start_mysqld.inc + +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 + +rmdir $targetdir; + +--error ER_GET_ERRNO +select * from t1; +drop table t1; diff --git a/mysql-test/suite/mariabackup/nolock_ddl_during_backup_end.result b/mysql-test/suite/mariabackup/nolock_ddl_during_backup_end.result new file mode 100644 index 00000000..1bd3052b --- /dev/null +++ b/mysql-test/suite/mariabackup/nolock_ddl_during_backup_end.result @@ -0,0 +1,2 @@ +CREATE TABLE t1(i int) ENGINE=INNODB; +# xtrabackup backup diff --git a/mysql-test/suite/mariabackup/nolock_ddl_during_backup_end.test b/mysql-test/suite/mariabackup/nolock_ddl_during_backup_end.test new file mode 100644 index 00000000..f6bc51bd --- /dev/null +++ b/mysql-test/suite/mariabackup/nolock_ddl_during_backup_end.test @@ -0,0 +1,14 @@ +--source include/have_debug.inc +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +mkdir $targetdir; + +CREATE TABLE t1(i int) ENGINE=INNODB; + +# this will table and populate it, after backup has list of tables to be copied +--let backup_fix_ddl=BEGIN NOT ATOMIC DROP TABLE test.t1;DO SLEEP(10000); END +echo # xtrabackup backup; +--disable_result_log +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --no-lock --dbug=+d,mariabackup_events; +--enable_result_log +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/options_check.result b/mysql-test/suite/mariabackup/options_check.result new file mode 100644 index 00000000..59666754 --- /dev/null +++ b/mysql-test/suite/mariabackup/options_check.result @@ -0,0 +1,8 @@ +# Check for unknown options in command-line +# Check for unknown options in "mariabackup" group +# Check for unknown options in "xtrabackup" group +# Check for unknown options in "mariadb-backup" group +# Check for options overwriting +# Check if uknown options that follow --mysqld-args are ingored +# Check if [mariadb-client] group is not loaded (MDEV-22894) +# Check if --help presents diff --git a/mysql-test/suite/mariabackup/options_check.test b/mysql-test/suite/mariabackup/options_check.test new file mode 100644 index 00000000..022bcbd5 --- /dev/null +++ b/mysql-test/suite/mariabackup/options_check.test @@ -0,0 +1,69 @@ +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--let $custom_cnf=$MYSQLTEST_VARDIR/tmp/custom_my.cnf + +--echo # Check for unknown options in command-line +--disable_result_log +--error 7 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --unknown-option=xxx --target-dir=$targetdir; +--error 2 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --unknown-option --target-dir=$targetdir; + +--echo # Check for unknown options in "mariabackup" group +--write_file $custom_cnf +[mariabackup] +unknown-option=XXX +EOF +--error 7 +exec $XTRABACKUP --defaults-file=$custom_cnf --backup --target-dir=$targetdir; +--remove_file $custom_cnf + +--echo # Check for unknown options in "xtrabackup" group +--write_file $custom_cnf +[xtrabackup] +unknown-option=XXX +EOF +--error 7 +exec $XTRABACKUP --defaults-file=$custom_cnf --backup --target-dir=$targetdir; +--remove_file $custom_cnf + +--echo # Check for unknown options in "mariadb-backup" group +--write_file $custom_cnf +[mariadb-backup] +unknown-option=XXX +EOF +--error 7 +exec $XTRABACKUP --defaults-file=$custom_cnf --backup --target-dir=$targetdir; +--remove_file $custom_cnf + +--echo # Check for options overwriting +--write_file $custom_cnf +[mariadbd] +innodb-flush-method=O_DIRECT + +[mariabackup] +innodb-flush-method=blablabla +EOF +--error 13 +exec $XTRABACKUP --defaults-file=$custom_cnf --backup --target-dir=$targetdir; +--remove_file $custom_cnf + +--echo # Check if uknown options that follow --mysqld-args are ingored +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --mysqld-args --unknown-option; +--rmdir $targetdir + +--echo # Check if [mariadb-client] group is not loaded (MDEV-22894) +--copy_file $MYSQLTEST_VARDIR/my.cnf $custom_cnf +--append_file $custom_cnf +[mariadb-client] +user=bla +password=bla +EOF +exec $XTRABACKUP --defaults-file=$custom_cnf --backup --target-dir=$targetdir; +--remove_file $custom_cnf +--rmdir $targetdir + +--echo # Check if --help presents +exec $XTRABACKUP --help; +exec $XTRABACKUP -?; +--enable_result_log + diff --git a/mysql-test/suite/mariabackup/page_compression_level.result b/mysql-test/suite/mariabackup/page_compression_level.result new file mode 100644 index 00000000..811fd821 --- /dev/null +++ b/mysql-test/suite/mariabackup/page_compression_level.result @@ -0,0 +1,14 @@ +set global innodb_compression_level = 3; +CREATE TABLE t1(c1 INT, b CHAR(20)) ENGINE=INNODB PAGE_COMPRESSED=1; +INSERT INTO t1 VALUES(1, 'mariadb'); +# xtrabackup backup +# xtrabackup prepare +FOUND 1 /innodb_compression_level=3/ in backup-my.cnf +DELETE FROM t1; +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t1 IMPORT TABLESPACE; +SELECT * FROM t1; +c1 b +1 mariadb +DROP TABLE t1; +set global innodb_compression_level = default; diff --git a/mysql-test/suite/mariabackup/page_compression_level.test b/mysql-test/suite/mariabackup/page_compression_level.test new file mode 100644 index 00000000..e80c956e --- /dev/null +++ b/mysql-test/suite/mariabackup/page_compression_level.test @@ -0,0 +1,31 @@ +#--source include/innodb_page_size.inc + +set global innodb_compression_level = 3; +CREATE TABLE t1(c1 INT, b CHAR(20)) ENGINE=INNODB PAGE_COMPRESSED=1; +INSERT INTO t1 VALUES(1, 'mariadb'); + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +echo # xtrabackup prepare; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir; +--enable_result_log + +--let SEARCH_PATTERN=innodb_compression_level=3 +--let SEARCH_FILE=$targetdir/backup-my.cnf +--source include/search_pattern_in_file.inc + +DELETE FROM t1; +ALTER TABLE t1 DISCARD TABLESPACE; +let $MYSQLD_DATADIR= `select @@datadir`; +copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd; +copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg; +ALTER TABLE t1 IMPORT TABLESPACE; + +SELECT * FROM t1; + +DROP TABLE t1; +set global innodb_compression_level = default; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/partial.result b/mysql-test/suite/mariabackup/partial.result new file mode 100644 index 00000000..981bef4e --- /dev/null +++ b/mysql-test/suite/mariabackup/partial.result @@ -0,0 +1,19 @@ +CREATE TABLE t1(i INT) ENGINE INNODB; +INSERT INTO t1 VALUES(1); +CREATE TABLE t21(i INT) ENGINE INNODB; +INSERT INTO t21 VALUES(1); +CREATE TABLE t2(i int) ENGINE INNODB; +# xtrabackup backup +t1.new +t21.new +# xtrabackup prepare +t1.cfg +t21.cfg +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t1 IMPORT TABLESPACE; +SELECT * FROM t1; +i +1 +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t21; diff --git a/mysql-test/suite/mariabackup/partial.test b/mysql-test/suite/mariabackup/partial.test new file mode 100644 index 00000000..d0d07daf --- /dev/null +++ b/mysql-test/suite/mariabackup/partial.test @@ -0,0 +1,61 @@ +#--source include/innodb_page_size.inc + +# Export single table from backup +# (xtrabackup with --prepare --export) + +CREATE TABLE t1(i INT) ENGINE INNODB; +INSERT INTO t1 VALUES(1); +CREATE TABLE t21(i INT) ENGINE INNODB; +INSERT INTO t21 VALUES(1); + +CREATE TABLE t2(i int) ENGINE INNODB; + +echo # xtrabackup backup; + +let targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.*1" --target-dir=$targetdir; +--enable_result_log +list_files $targetdir/test *.ibd; +list_files $targetdir/test *.new; + +# Inject a junk .ibd file into backup dir to +# see if prepare does not choke on it. +write_file $targetdir/test/junk.ibd; +EOF +write_file $targetdir/test/junk.frm; +EOF + +let server_cnf=$targetdir/server.cnf; +copy_file $MYSQLTEST_VARDIR/my.cnf $server_cnf; + +# Emulate server config file turnes on binary logs +perl; +my $binlog_path="$ENV{'targetdir'}/mysqld-bin"; +my $config_path=$ENV{'server_cnf'}; +open(my $fd, '>>', "$config_path"); +print $fd "\n[mysqld]\n"; +print $fd "log-bin=$binlog_path\n"; +close $fd; +EOF + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --defaults-file=$server_cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir; +--enable_result_log + +list_files $targetdir/test *.cfg; +# There must not be binary logs created on --prepare step +list_files $targetdir/ mysqld-bin.*; + +let $MYSQLD_DATADIR= `select @@datadir`; +ALTER TABLE t1 DISCARD TABLESPACE; +copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd; +copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg; +ALTER TABLE t1 IMPORT TABLESPACE; + +SELECT * FROM t1; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t21; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/partial_exclude.opt b/mysql-test/suite/mariabackup/partial_exclude.opt new file mode 100644 index 00000000..872335ed --- /dev/null +++ b/mysql-test/suite/mariabackup/partial_exclude.opt @@ -0,0 +1,2 @@ +--ignore-db-dirs=db3 +--ignore-db-dirs=db4 diff --git a/mysql-test/suite/mariabackup/partial_exclude.result b/mysql-test/suite/mariabackup/partial_exclude.result new file mode 100644 index 00000000..f57a5f63 --- /dev/null +++ b/mysql-test/suite/mariabackup/partial_exclude.result @@ -0,0 +1,22 @@ +select @@ignore_db_dirs; +@@ignore_db_dirs +db3,db4 +CREATE TABLE t1(i INT) ENGINE INNODB; +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(i int) ENGINE INNODB; +CREATE DATABASE db2; +USE db2; +CREATE TABLE t1(i INT) ENGINE INNODB; +USE test; +BEGIN; +INSERT INTO db2.t1 VALUES(20); +INSERT INTO test.t1 VALUES(20); +INSERT INTO test.t2 VALUES(20); +# xtrabackup backup +COMMIT; +t1.new +DROP TABLE t1; +DROP TABLE t2; +DROP DATABASE db2; +NOT FOUND /Operating system error number/ in backup.log +NOT FOUND /Could not find a valid tablespace file for/ in backup.log diff --git a/mysql-test/suite/mariabackup/partial_exclude.test b/mysql-test/suite/mariabackup/partial_exclude.test new file mode 100644 index 00000000..6a1ae13b --- /dev/null +++ b/mysql-test/suite/mariabackup/partial_exclude.test @@ -0,0 +1,70 @@ +#--source include/innodb_page_size.inc + +# Test --databases-exclude and --tables-exclude feature of xtrabackup 2.3.8 +select @@ignore_db_dirs; + +let $MYSQLD_DATADIR= `select @@datadir`; + +mkdir $MYSQLD_DATADIR/db3; +mkdir $MYSQLD_DATADIR/db4; +mkdir $MYSQLD_DATADIR/db5; + +CREATE TABLE t1(i INT) ENGINE INNODB; +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(i int) ENGINE INNODB; + +CREATE DATABASE db2; +USE db2; +CREATE TABLE t1(i INT) ENGINE INNODB; + +USE test; + +BEGIN; +INSERT INTO db2.t1 VALUES(20); +INSERT INTO test.t1 VALUES(20); +INSERT INTO test.t2 VALUES(20); + +echo # xtrabackup backup; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables-exclude=test.*2" "--databases-exclude=db2" --target-dir=$targetdir; +--enable_result_log + +COMMIT; + +# check that only t1 table is in backup (t2 is excluded) +list_files $targetdir/test *.new; +list_files $targetdir/test *.ibd; +# check that db2 database is not in the backup (excluded) +--error 1 +list_files $targetdir/db2 *.ibd; +# check that db3 database is not in the backup (excluded) +--error 1 +list_files $targetdir/db3 *.ibd; +# check that db4 database is not in the backup (excluded) +--error 1 +list_files $targetdir/db4 *.ibd; +# check that db5 database is in the backup +list_files $targetdir/db5 *.ibd; + +DROP TABLE t1; +DROP TABLE t2; +DROP DATABASE db2; +rmdir $MYSQLD_DATADIR/db3; +rmdir $MYSQLD_DATADIR/db4; +rmdir $MYSQLD_DATADIR/db5; + +--let $backup_log=$MYSQLTEST_VARDIR/tmp/backup.log +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --export --prepare --target-dir="$targetdir" > $backup_log; +--enable_result_log + +--let SEARCH_FILE=$backup_log +--let SEARCH_PATTERN=Operating system error number +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=Could not find a valid tablespace file for +--source include/search_pattern_in_file.inc +--remove_file $backup_log + +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/partition_datadir.result b/mysql-test/suite/mariabackup/partition_datadir.result new file mode 100644 index 00000000..f00db641 --- /dev/null +++ b/mysql-test/suite/mariabackup/partition_datadir.result @@ -0,0 +1,22 @@ +CREATE TABLE t(i int) +ENGINE=InnoDB +PARTITION BY RANGE (i) +(PARTITION p0 VALUES LESS THAN (100), +PARTITION P1 VALUES LESS THAN (200), +PARTITION p2 VALUES LESS THAN (300) DATA DIRECTORY = 'MYSQLTEST_VARDIR/partitdata', +PARTITION p3 VALUES LESS THAN (400) DATA DIRECTORY = 'MYSQLTEST_VARDIR/partitdata', +PARTITION p4 VALUES LESS THAN MAXVALUE); +INSERT INTO t VALUES (1), (101), (201), (301), (401); +DROP TABLE t; +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +101 +201 +301 +401 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/partition_datadir.test b/mysql-test/suite/mariabackup/partition_datadir.test new file mode 100644 index 00000000..36520d33 --- /dev/null +++ b/mysql-test/suite/mariabackup/partition_datadir.test @@ -0,0 +1,26 @@ +--source include/have_partition.inc +--source include/have_symlink.inc +let $targetdir=$MYSQLTEST_VARDIR/backup; +mkdir $targetdir; +mkdir $MYSQLTEST_VARDIR/partitdata; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t(i int) +ENGINE=InnoDB +PARTITION BY RANGE (i) +(PARTITION p0 VALUES LESS THAN (100), + PARTITION P1 VALUES LESS THAN (200), + PARTITION p2 VALUES LESS THAN (300) DATA DIRECTORY = '$MYSQLTEST_VARDIR/partitdata', + PARTITION p3 VALUES LESS THAN (400) DATA DIRECTORY = '$MYSQLTEST_VARDIR/partitdata', + PARTITION p4 VALUES LESS THAN MAXVALUE); +INSERT INTO t VALUES (1), (101), (201), (301), (401); +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +exec $XTRABACKUP --prepare --target-dir=$targetdir; +DROP TABLE t; +rmdir $MYSQLTEST_VARDIR/partitdata; +--source include/restart_and_restore.inc +--enable_result_log +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; +rmdir $MYSQLTEST_VARDIR/partitdata; diff --git a/mysql-test/suite/mariabackup/partition_partial.opt b/mysql-test/suite/mariabackup/partition_partial.opt new file mode 100644 index 00000000..508cf185 --- /dev/null +++ b/mysql-test/suite/mariabackup/partition_partial.opt @@ -0,0 +1 @@ +--innodb --loose-partition diff --git a/mysql-test/suite/mariabackup/partition_partial.result b/mysql-test/suite/mariabackup/partition_partial.result new file mode 100644 index 00000000..62b7adf7 --- /dev/null +++ b/mysql-test/suite/mariabackup/partition_partial.result @@ -0,0 +1,31 @@ +CREATE TABLE t1(i INT) ENGINE INNODB +PARTITION BY RANGE (i) +(PARTITION p1 VALUES LESS THAN (100), +PARTITION p2 VALUES LESS THAN (200), +PARTITION p3 VALUES LESS THAN (300), +PARTITION p4 VALUES LESS THAN (400)); +INSERT INTO t1 VALUES (1), (101), (201), (301); +# xtrabackup backup +INSERT INTO t1 VALUES (1), (101), (201), (301); +# xtrabackup prepare +CREATE TABLE t1_placeholder (i INT) ENGINE INNODB; +ALTER TABLE t1_placeholder DISCARD TABLESPACE; +ALTER TABLE t1_placeholder IMPORT TABLESPACE; +ALTER TABLE t1 EXCHANGE PARTITION p4 WITH TABLE t1_placeholder; +ALTER TABLE t1_placeholder DISCARD TABLESPACE; +ALTER TABLE t1_placeholder IMPORT TABLESPACE; +ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE t1_placeholder; +ALTER TABLE t1_placeholder DISCARD TABLESPACE; +ALTER TABLE t1_placeholder IMPORT TABLESPACE; +ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t1_placeholder; +ALTER TABLE t1_placeholder DISCARD TABLESPACE; +ALTER TABLE t1_placeholder IMPORT TABLESPACE; +ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t1_placeholder; +SELECT * FROM t1; +i +1 +101 +201 +301 +DROP TABLE t1; +DROP TABLE t1_placeholder; diff --git a/mysql-test/suite/mariabackup/partition_partial.test b/mysql-test/suite/mariabackup/partition_partial.test new file mode 100644 index 00000000..7ccc42c0 --- /dev/null +++ b/mysql-test/suite/mariabackup/partition_partial.test @@ -0,0 +1,45 @@ +#--source include/innodb_page_size.inc +--source include/have_partition.inc + +# import partitioned table from table from partial backup + +CREATE TABLE t1(i INT) ENGINE INNODB +PARTITION BY RANGE (i) +(PARTITION p1 VALUES LESS THAN (100), + PARTITION p2 VALUES LESS THAN (200), + PARTITION p3 VALUES LESS THAN (300), + PARTITION p4 VALUES LESS THAN (400)); + +INSERT INTO t1 VALUES (1), (101), (201), (301); + +echo # xtrabackup backup; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.t1" --target-dir=$targetdir; +--enable_result_log +INSERT INTO t1 VALUES (1), (101), (201), (301); + + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir; +--enable_result_log + + +let $MYSQLD_DATADIR= `select @@datadir`; +CREATE TABLE t1_placeholder (i INT) ENGINE INNODB; +let $i=4; +while($i) +{ + eval ALTER TABLE t1_placeholder DISCARD TABLESPACE; + copy_file $targetdir/test/t1#P#p$i.cfg $MYSQLD_DATADIR/test/t1_placeholder.cfg; + copy_file $targetdir/test/t1#P#p$i.ibd $MYSQLD_DATADIR/test/t1_placeholder.ibd; + eval ALTER TABLE t1_placeholder IMPORT TABLESPACE; + eval ALTER TABLE t1 EXCHANGE PARTITION p$i WITH TABLE t1_placeholder; + dec $i; +} +SELECT * FROM t1; +DROP TABLE t1; +DROP TABLE t1_placeholder; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/recreate_table_during_backup.result b/mysql-test/suite/mariabackup/recreate_table_during_backup.result new file mode 100644 index 00000000..3e01312c --- /dev/null +++ b/mysql-test/suite/mariabackup/recreate_table_during_backup.result @@ -0,0 +1,24 @@ +CREATE TABLE t1(i int) ENGINE=INNODB; +CREATE TABLE t2(i int) ENGINE=INNODB; +CREATE TABLE t3(a CHAR(36)) ENGINE INNODB; +INSERT INTO t3 SELECT UUID() FROM seq_1_to_1000; +set global innodb_log_checkpoint_now=1; +# xtrabackup backup +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT COUNT(*) from t1; +COUNT(*) +100 +SELECT COUNT(*) from t2; +COUNT(*) +1000 +SELECT COUNT(*) from t3; +COUNT(*) +1000 +DROP INDEX index_a ON t3; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/suite/mariabackup/recreate_table_during_backup.test b/mysql-test/suite/mariabackup/recreate_table_during_backup.test new file mode 100644 index 00000000..1feb2c5c --- /dev/null +++ b/mysql-test/suite/mariabackup/recreate_table_during_backup.test @@ -0,0 +1,38 @@ +--source include/have_debug.inc +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +mkdir $targetdir; + +CREATE TABLE t1(i int) ENGINE=INNODB; +CREATE TABLE t2(i int) ENGINE=INNODB; +CREATE TABLE t3(a CHAR(36)) ENGINE INNODB; +INSERT INTO t3 SELECT UUID() FROM seq_1_to_1000; + +set global innodb_log_checkpoint_now=1; +# this will table and populate it, after backup has list of tables to be copied +--let before_copy_test_t1=BEGIN NOT ATOMIC DROP TABLE test.t1;CREATE TABLE test.t1 ENGINE=INNODB SELECT UUID() from test.seq_1_to_100; END +--let after_copy_test_t2=BEGIN NOT ATOMIC DROP TABLE test.t2;CREATE TABLE test.t2 ENGINE=INNODB SELECT UUID() from test.seq_1_to_1000; END +--let after_copy_test_t3=ALTER TABLE test.t3 ADD INDEX index_a(a),ALGORITHM=COPY +echo # xtrabackup backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --close-files --dbug=+d,mariabackup_events; +--enable_result_log +--let after_load_tables= + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +# Check that new table is there after restore. +SELECT COUNT(*) from t1; +SELECT COUNT(*) from t2; +SELECT COUNT(*) from t3; +DROP INDEX index_a ON t3; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +rmdir $targetdir; + + + diff --git a/mysql-test/suite/mariabackup/relative_path.opt b/mysql-test/suite/mariabackup/relative_path.opt new file mode 100644 index 00000000..3e3c33e4 --- /dev/null +++ b/mysql-test/suite/mariabackup/relative_path.opt @@ -0,0 +1 @@ +--innodb-undo-tablespaces=2 diff --git a/mysql-test/suite/mariabackup/relative_path.result b/mysql-test/suite/mariabackup/relative_path.result new file mode 100644 index 00000000..7aa0c696 --- /dev/null +++ b/mysql-test/suite/mariabackup/relative_path.result @@ -0,0 +1,20 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# xtrabackup backup +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +# shutdown server +# remove datadir +# xtrabackup move back +# restart +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/relative_path.test b/mysql-test/suite/mariabackup/relative_path.test new file mode 100644 index 00000000..bd25a217 --- /dev/null +++ b/mysql-test/suite/mariabackup/relative_path.test @@ -0,0 +1,35 @@ +--source include/have_innodb.inc + +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--let $backup_log=$MYSQLTEST_VARDIR/tmp/backup.log + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backup_log 2>&1; +--enable_result_log + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; + +# If MDEV-28187 is not fixed, the following tries to copy backup to data +# directory will fail, because their destination path will be the same as +# their source path + +--let $backup_opts=--innodb_undo_directory=./ +--source include/restart_and_restore.inc + +--let $backup_opts=--innodb_log_group_home_dir=./ +--source include/restart_and_restore.inc + +--let $backup_opts=--innodb_data_home_dir=./ +--source include/restart_and_restore.inc + +--enable_result_log + +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/rename_during_backup.result b/mysql-test/suite/mariabackup/rename_during_backup.result new file mode 100644 index 00000000..e071b6b2 --- /dev/null +++ b/mysql-test/suite/mariabackup/rename_during_backup.result @@ -0,0 +1,63 @@ +CREATE TABLE t1(i int) ENGINE INNODB; +INSERT into t1 values(1); +CREATE TABLE t2(i int) ENGINE INNODB; +INSERT INTO t2 values(2); +CREATE TABLE t3(i int) ENGINE INNODB; +CREATE TABLE t4(i int) ENGINE INNODB; +CREATE TABLE t5(i int) ENGINE INNODB; +INSERT INTO t5 VALUES(5); +CREATE TABLE a(a int) ENGINE INNODB; +INSERT INTO a values(1); +CREATE TABLE b(b CHAR(1)) ENGINE INNODB; +INSERT INTO b VALUES('b'); +CREATE TABLE a1(a1 int) ENGINE INNODB; +INSERT INTO a1 VALUES(1); +CREATE TABLE b1(b1 CHAR(2)) ENGINE INNODB; +INSERT INTO b1 VALUES('b1'); +set global innodb_log_checkpoint_now = 1; +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +CREATE TABLE t1(i int); +DROP TABLE t1; +SELECT * from t1_renamed; +i +1 +DROP TABLE t1_renamed; +CREATE TABLE t2(i int); +DROP TABLE t2; +SELECT * from t2_renamed; +i +2 +DROP TABLE t2_renamed; +SELECT * from t3; +i +3 +DROP TABLE t3; +SELECT * from t4; +i +DROP TABLE t4; +CREATE TABLE tmp(i int); +DROP TABLE tmp; +SELECT * FROM a; +b +b +SELECT * FROM b; +a +1 +SELECT * FROM a1; +b1 +b1 +SELECT * FROM b1; +a1 +1 +DROP TABLE a,b,a1,b1; +SELECT * from t5; +i +DROP TABLE t5; +SELECT * from t6; +i +5 +DROP TABLE t6; diff --git a/mysql-test/suite/mariabackup/rename_during_backup.test b/mysql-test/suite/mariabackup/rename_during_backup.test new file mode 100644 index 00000000..d8e40b28 --- /dev/null +++ b/mysql-test/suite/mariabackup/rename_during_backup.test @@ -0,0 +1,95 @@ +--source include/have_debug.inc +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +mkdir $targetdir; + +CREATE TABLE t1(i int) ENGINE INNODB; +INSERT into t1 values(1); + +CREATE TABLE t2(i int) ENGINE INNODB; +INSERT INTO t2 values(2); + +CREATE TABLE t3(i int) ENGINE INNODB; +CREATE TABLE t4(i int) ENGINE INNODB; +CREATE TABLE t5(i int) ENGINE INNODB; +INSERT INTO t5 VALUES(5); + +CREATE TABLE a(a int) ENGINE INNODB; +INSERT INTO a values(1); +CREATE TABLE b(b CHAR(1)) ENGINE INNODB; +INSERT INTO b VALUES('b'); + +CREATE TABLE a1(a1 int) ENGINE INNODB; +INSERT INTO a1 VALUES(1); + +CREATE TABLE b1(b1 CHAR(2)) ENGINE INNODB; +INSERT INTO b1 VALUES('b1'); + +set global innodb_log_checkpoint_now = 1; + +# Test renames before of after copying tablespaces +--let before_copy_test_t1=RENAME TABLE test.t1 TO test.t1_renamed +--let after_copy_test_t2=RENAME TABLE test.t2 TO test.t2_renamed +--let after_copy_test_t3=BEGIN NOT ATOMIC RENAME TABLE test.t3 TO test.t3_tmp; INSERT INTO test.t3_tmp VALUES(3); RENAME TABLE test.t3_tmp TO test.t3; END +--let before_copy_test_t4=RENAME TABLE test.t4 TO test.t4_tmp +--let after_copy_test_t4=RENAME TABLE test.t4_tmp TO test.t4 +--let after_copy_test_t5=BEGIN NOT ATOMIC RENAME TABLE test.t5 TO test.t6; CREATE TABLE test.t5(i int) ENGINE INNODB; END + +# Test circular renames +--let before_copy_test_b=RENAME TABLE test.a to test.tmp, test.b to test.a, test.tmp to test.b +--let after_copy_test_b1=RENAME TABLE test.a1 to test.tmp, test.b1 to test.a1, test.tmp to test.b1 + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +--let before_copy_test_t1='' +--let after_copy_test_t2='' +--let before_copy_test_a='' +--let after_copy_test_a1='' + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +# the table was renamed from t1 to t1_renamed +# make sure t1 does not exist, and t1_renamed does. + +CREATE TABLE t1(i int); +DROP TABLE t1; + +SELECT * from t1_renamed; +DROP TABLE t1_renamed; + + +CREATE TABLE t2(i int); +DROP TABLE t2; + +SELECT * from t2_renamed; +DROP TABLE t2_renamed; + +#rename to itself +SELECT * from t3; +DROP TABLE t3; + +SELECT * from t4; +DROP TABLE t4; + +# For circular renames , make sure intermediate tables do not exist +CREATE TABLE tmp(i int); +DROP TABLE tmp; + +SELECT * FROM a; +SELECT * FROM b; +SELECT * FROM a1; +SELECT * FROM b1; + +DROP TABLE a,b,a1,b1; +SELECT * from t5; +DROP TABLE t5; +SELECT * from t6; +DROP TABLE t6; +rmdir $targetdir; + + diff --git a/mysql-test/suite/mariabackup/rename_during_mdl_lock.result b/mysql-test/suite/mariabackup/rename_during_mdl_lock.result new file mode 100644 index 00000000..074de33b --- /dev/null +++ b/mysql-test/suite/mariabackup/rename_during_mdl_lock.result @@ -0,0 +1,12 @@ +CREATE TABLE t1(i int) ENGINE INNODB; +set global innodb_log_checkpoint_now = 1; +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +CREATE TABLE t1(i int); +DROP TABLE t1; +SELECT * from t2; +i +DROP TABLE t2; diff --git a/mysql-test/suite/mariabackup/rename_during_mdl_lock.test b/mysql-test/suite/mariabackup/rename_during_mdl_lock.test new file mode 100644 index 00000000..212b7aab --- /dev/null +++ b/mysql-test/suite/mariabackup/rename_during_mdl_lock.test @@ -0,0 +1,22 @@ +--source include/have_debug.inc +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +mkdir $targetdir; +CREATE TABLE t1(i int) ENGINE INNODB; +set global innodb_log_checkpoint_now = 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --lock-ddl-per-table --dbug=+d,rename_during_mdl_lock_table; + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log +# the table was renamed from t1 to t2 +# make sure t1 does not exist, and t2 does + +CREATE TABLE t1(i int); +DROP TABLE t1; +SELECT * from t2; +DROP TABLE t2; + +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/row_format_redundant.result b/mysql-test/suite/mariabackup/row_format_redundant.result new file mode 100644 index 00000000..7ff5e865 --- /dev/null +++ b/mysql-test/suite/mariabackup/row_format_redundant.result @@ -0,0 +1,14 @@ +CREATE TABLE t1 (pk INT PRIMARY KEY, a YEAR UNSIGNED) ENGINE=InnoDB +ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES (1,2021),(2,21),(3,0); +UPDATE t1 SET a = NULL; +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t1; +pk a +1 NULL +2 NULL +3 NULL +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/row_format_redundant.test b/mysql-test/suite/mariabackup/row_format_redundant.test new file mode 100644 index 00000000..5bae9218 --- /dev/null +++ b/mysql-test/suite/mariabackup/row_format_redundant.test @@ -0,0 +1,17 @@ +--source include/have_innodb.inc + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup + +CREATE TABLE t1 (pk INT PRIMARY KEY, a YEAR UNSIGNED) ENGINE=InnoDB +ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES (1,2021),(2,21),(3,0); +UPDATE t1 SET a = NULL; + +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +exec $XTRABACKUP --prepare --verbose --target-dir=$targetdir; +--source include/restart_and_restore.inc + +rmdir $targetdir; + +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/rpl_slave_info.result b/mysql-test/suite/mariabackup/rpl_slave_info.result new file mode 100644 index 00000000..ec27166e --- /dev/null +++ b/mysql-test/suite/mariabackup/rpl_slave_info.result @@ -0,0 +1,44 @@ +include/master-slave.inc +[connection master] +connection slave; +############### +# If Using_Gtid != 'No', backup gtid_slave_pos +######################## +include/stop_slave.inc +change master to master_use_gtid=slave_pos; +include/start_slave.inc +connection master; +CREATE TABLE t(i INT); +connection slave; +"using_gtid: Slave_Pos" +FOUND 1 /gtid_slave_pos/ in xtrabackup_slave_info +NOT FOUND /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>'; +2 CHANGE MASTER TO master_use_gtid = slave_pos; +############### +# If Using_Gtid != 'No' and !gtid_slave_pos, backup master position +######################## +include/stop_slave.inc +SET GLOBAL gtid_slave_pos=""; +NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info +FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=<NUM>; +############### +# If Using_Gtid == 'No', backup Exec_Master_Log_Pos +######################## +change master to master_use_gtid=no; +include/start_slave.inc +connection master; +INSERT INTO t VALUES(1); +connection slave; +"using_gtid: No" +NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info +FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=<NUM>; +connection master; +DROP TABLE t; +connection slave; +include/rpl_end.inc diff --git a/mysql-test/suite/mariabackup/rpl_slave_info.test b/mysql-test/suite/mariabackup/rpl_slave_info.test new file mode 100644 index 00000000..1c5dd89a --- /dev/null +++ b/mysql-test/suite/mariabackup/rpl_slave_info.test @@ -0,0 +1,89 @@ +--source include/master-slave.inc + +--connection slave + +--echo ############### +--echo # If Using_Gtid != 'No', backup gtid_slave_pos +--echo ######################## + +--source include/stop_slave.inc +change master to master_use_gtid=slave_pos; +--source include/start_slave.inc + +--connection master +CREATE TABLE t(i INT); +--sync_slave_with_master + +--let $using_gtid=query_get_value(SHOW SLAVE STATUS,Using_Gtid,1) +--echo "using_gtid: $using_gtid" + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.2 --slave-info --backup --target-dir=$targetdir; +--enable_result_log + +--let SEARCH_FILE=$targetdir/xtrabackup_slave_info +--let SEARCH_PATTERN=gtid_slave_pos +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=MASTER_LOG_FILE +--source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc + +rmdir $targetdir; + +--echo ############### +--echo # If Using_Gtid != 'No' and !gtid_slave_pos, backup master position +--echo ######################## + +--source include/stop_slave.inc +--disable_warnings +SET GLOBAL gtid_slave_pos=""; +--enable_warnings + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.2 --slave-info --backup --target-dir=$targetdir; +--enable_result_log + +--let SEARCH_FILE=$targetdir/xtrabackup_slave_info +--let SEARCH_PATTERN=gtid_slave_pos +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=MASTER_LOG_FILE +--source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc + +rmdir $targetdir; + +--echo ############### +--echo # If Using_Gtid == 'No', backup Exec_Master_Log_Pos +--echo ######################## + +change master to master_use_gtid=no; +--source include/start_slave.inc + +--connection master +INSERT INTO t VALUES(1); +--sync_slave_with_master + +--let $using_gtid=query_get_value(SHOW SLAVE STATUS,Using_Gtid,1) +--echo "using_gtid: $using_gtid" + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.2 --slave-info --backup --target-dir=$targetdir; +--enable_result_log + +--let SEARCH_FILE=$targetdir/xtrabackup_slave_info +--let SEARCH_PATTERN=gtid_slave_pos +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=MASTER_LOG_FILE +--source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc + +rmdir $targetdir; + +# Cleanup +--connection master +DROP TABLE t; +--sync_slave_with_master +--source include/rpl_end.inc diff --git a/mysql-test/suite/mariabackup/skip_innodb.opt b/mysql-test/suite/mariabackup/skip_innodb.opt new file mode 100644 index 00000000..213331f5 --- /dev/null +++ b/mysql-test/suite/mariabackup/skip_innodb.opt @@ -0,0 +1 @@ +--loose-skip-innodb
\ No newline at end of file diff --git a/mysql-test/suite/mariabackup/skip_innodb.result b/mysql-test/suite/mariabackup/skip_innodb.result new file mode 100644 index 00000000..859b3c56 --- /dev/null +++ b/mysql-test/suite/mariabackup/skip_innodb.result @@ -0,0 +1,10 @@ +CREATE TABLE t(i int); +INSERT INTO t VALUES(1); +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * from t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/skip_innodb.test b/mysql-test/suite/mariabackup/skip_innodb.test new file mode 100644 index 00000000..25495b30 --- /dev/null +++ b/mysql-test/suite/mariabackup/skip_innodb.test @@ -0,0 +1,13 @@ +--source include/innodb_undo_tablespaces.inc +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +CREATE TABLE t(i int); +INSERT INTO t VALUES(1); +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log +SELECT * from t; +DROP TABLE t; + +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/slave_info_norpl.result b/mysql-test/suite/mariabackup/slave_info_norpl.result new file mode 100644 index 00000000..04ca2fb2 --- /dev/null +++ b/mysql-test/suite/mariabackup/slave_info_norpl.result @@ -0,0 +1,61 @@ +# +# Start of 10.2 tests +# +# +# MDEV-21037 mariabackup does not detect multi-source replication slave +# +SELECT @@global.gtid_slave_pos; +@@global.gtid_slave_pos + + +# Without any masters the file xtrabackup_slave_info is not created +line +[00] YYYY-MM-DD hh:mm:ss Failed to get master binlog coordinates from SHOW SLAVE STATUS.This means that the server is not a replication slave. Ignoring the --slave-info option + +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000; +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: master '' filename '' position '0' + +CHANGE MASTER 'master2' TO MASTER_HOST='localhost', MASTER_PORT=10002; +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +2 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: master '' filename '' position '0'; master 'master2' filename '' position '0' + +SET GLOBAL gtid_slave_pos='1-1-1,2-2-2'; +CHANGE MASTER 'master3' TO MASTER_HOST='localhost', MASTER_PORT=10003, MASTER_USE_GTID=slave_pos; +CHANGE MASTER 'master4' TO MASTER_HOST='localhost', MASTER_PORT=10004, MASTER_USE_GTID=no; +CHANGE MASTER 'master5' TO MASTER_HOST='localhost', MASTER_PORT=10005, MASTER_USE_GTID=slave_pos; +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; +2 CHANGE MASTER TO master_use_gtid = slave_pos; +3 CHANGE MASTER 'master2' TO master_use_gtid = slave_pos; +4 CHANGE MASTER 'master3' TO master_use_gtid = slave_pos; +5 CHANGE MASTER 'master4' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +6 CHANGE MASTER 'master5' TO master_use_gtid = slave_pos; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: gtid_slave_pos '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; master '' master_use_gtid = slave_pos; master 'master2' master_use_gtid = slave_pos; master 'master3' master_use_gtid = slave_pos; master 'master4' filename '' position '0'; master 'master5' master_use_gtid = slave_pos + +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000, MASTER_USE_GTID=slave_pos; +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; +2 CHANGE MASTER TO master_use_gtid = slave_pos; +3 CHANGE MASTER 'master2' TO master_use_gtid = slave_pos; +4 CHANGE MASTER 'master3' TO master_use_gtid = slave_pos; +5 CHANGE MASTER 'master4' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +6 CHANGE MASTER 'master5' TO master_use_gtid = slave_pos; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: gtid_slave_pos '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; master '' master_use_gtid = slave_pos; master 'master2' master_use_gtid = slave_pos; master 'master3' master_use_gtid = slave_pos; master 'master4' filename '' position '0'; master 'master5' master_use_gtid = slave_pos +RESET SLAVE ALL; +RESET SLAVE 'master2' ALL; +RESET SLAVE 'master3' ALL; +RESET SLAVE 'master4' ALL; +Warnings: +Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos' +RESET SLAVE 'master5' ALL; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/mariabackup/slave_info_norpl.test b/mysql-test/suite/mariabackup/slave_info_norpl.test new file mode 100644 index 00000000..0d2d2ed4 --- /dev/null +++ b/mysql-test/suite/mariabackup/slave_info_norpl.test @@ -0,0 +1,86 @@ +# +# "mariabackup --slave-info" tests that can be run without +# actually starting the replication. +# + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-21037 mariabackup does not detect multi-source replication slave +--echo # + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--let $XTRABACKUP_ARGS=--defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.2 --slave-info --backup --databases=test --target-dir=$targetdir +--let $XTRABACKUP_OUT=$MYSQLTEST_VARDIR/tmp/xtrabackup_out + +# Should be empty by default +SELECT @@global.gtid_slave_pos; + +--echo +--echo # Without any masters the file xtrabackup_slave_info is not created + +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--error 1 +--file_exists $targetdir/xtrabackup_slave_info +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER 'master2' TO MASTER_HOST='localhost', MASTER_PORT=10002; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +SET GLOBAL gtid_slave_pos='1-1-1,2-2-2'; +CHANGE MASTER 'master3' TO MASTER_HOST='localhost', MASTER_PORT=10003, MASTER_USE_GTID=slave_pos; +CHANGE MASTER 'master4' TO MASTER_HOST='localhost', MASTER_PORT=10004, MASTER_USE_GTID=no; +CHANGE MASTER 'master5' TO MASTER_HOST='localhost', MASTER_PORT=10005, MASTER_USE_GTID=slave_pos; + +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000, MASTER_USE_GTID=slave_pos; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +RESET SLAVE ALL; +RESET SLAVE 'master2' ALL; +RESET SLAVE 'master3' ALL; +RESET SLAVE 'master4' ALL; +RESET SLAVE 'master5' ALL; + + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/mariabackup/small_ibd.result b/mysql-test/suite/mariabackup/small_ibd.result new file mode 100644 index 00000000..1c840a7a --- /dev/null +++ b/mysql-test/suite/mariabackup/small_ibd.result @@ -0,0 +1 @@ +#backup diff --git a/mysql-test/suite/mariabackup/small_ibd.test b/mysql-test/suite/mariabackup/small_ibd.test new file mode 100644 index 00000000..e8175fce --- /dev/null +++ b/mysql-test/suite/mariabackup/small_ibd.test @@ -0,0 +1,19 @@ +--source include/innodb_page_size.inc + +# Check if ibd smaller than page size are skipped +# It is possible, due to race conditions that new file +# is created by server while xtrabackup is running +# The first page in this file does not yet exist. +# xtrabackup should skip such file. + +let $_datadir= `SELECT @@datadir`; +write_file $_datadir/test/small.ibd; +EOF +echo #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 +remove_file $_datadir/test/small.ibd; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/suite.opt b/mysql-test/suite/mariabackup/suite.opt new file mode 100644 index 00000000..1df46435 --- /dev/null +++ b/mysql-test/suite/mariabackup/suite.opt @@ -0,0 +1 @@ +--innodb --loose-changed_page_bitmaps --innodb-sys-tables --innodb-flush-log-at-trx-commit=2 --sequence diff --git a/mysql-test/suite/mariabackup/suite.pm b/mysql-test/suite/mariabackup/suite.pm new file mode 100644 index 00000000..f0db4482 --- /dev/null +++ b/mysql-test/suite/mariabackup/suite.pm @@ -0,0 +1,21 @@ +package My::Suite::MariaBackup; + +@ISA = qw(My::Suite); +use My::Find; +use File::Basename; +use strict; + +return "Not run for embedded server" if $::opt_embedded_server; + +return "No mariabackup" unless $ENV{XTRABACKUP}; + +my $have_qpress = index(`qpress 2>&1`,"Compression") > 0; + +sub skip_combinations { + my %skip; + $skip{'include/have_file_key_management.inc'} = 'needs file_key_management plugin' unless $ENV{FILE_KEY_MANAGEMENT_SO}; + $skip{'compress_qpress.test'}= 'needs qpress executable in PATH' unless $have_qpress; + %skip; +} + +bless { }; diff --git a/mysql-test/suite/mariabackup/system_versioning.result b/mysql-test/suite/mariabackup/system_versioning.result new file mode 100644 index 00000000..f8feb08b --- /dev/null +++ b/mysql-test/suite/mariabackup/system_versioning.result @@ -0,0 +1,49 @@ +create table t (a int) with system versioning; +insert into t values (1); +update t set a=2; +insert into t values (3); +# shutdown server +# remove datadir +# xtrabackup move back +# restart +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +select * from t; +a +2 +select a from t for system_time all; +a +2 +1 +create or replace table t ( +a int, +s bigint unsigned as row start invisible, +e bigint unsigned as row end invisible, +period for system_time(s, e) +) with system versioning engine=innodb; +insert into t values (1); +update t set a=2; +insert into t values (3); +# shutdown server +# remove datadir +# xtrabackup move back +# restart +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `s` bigint(20) unsigned GENERATED ALWAYS AS ROW START INVISIBLE, + `e` bigint(20) unsigned GENERATED ALWAYS AS ROW END INVISIBLE, + PERIOD FOR SYSTEM_TIME (`s`, `e`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +select * from t; +a +2 +select a from t for system_time all; +a +2 +1 +drop table t; diff --git a/mysql-test/suite/mariabackup/system_versioning.test b/mysql-test/suite/mariabackup/system_versioning.test new file mode 100644 index 00000000..1ced00b4 --- /dev/null +++ b/mysql-test/suite/mariabackup/system_versioning.test @@ -0,0 +1,50 @@ +create table t (a int) with system versioning; +insert into t values (1); +update t set a=2; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log + +insert into t values (3); + +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM +show create table t; +select * from t; +select a from t for system_time all; + +rmdir $targetdir; + +create or replace table t ( + a int, + s bigint unsigned as row start invisible, + e bigint unsigned as row end invisible, + period for system_time(s, e) +) with system versioning engine=innodb; +insert into t values (1); +update t set a=2; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log + +insert into t values (3); + +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +show create table t; +select * from t; +select a from t for system_time all; + +drop table t; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/truncate_during_backup.result b/mysql-test/suite/mariabackup/truncate_during_backup.result new file mode 100644 index 00000000..f9d5c785 --- /dev/null +++ b/mysql-test/suite/mariabackup/truncate_during_backup.result @@ -0,0 +1,4 @@ +CREATE TABLE t1 ENGINE=InnoDB SELECT 1; +DROP TABLE t1; +SET GLOBAL innodb_log_checkpoint_now=1; +SET GLOBAL innodb_log_checkpoint_now=DEFAULT; diff --git a/mysql-test/suite/mariabackup/truncate_during_backup.test b/mysql-test/suite/mariabackup/truncate_during_backup.test new file mode 100644 index 00000000..46ee244d --- /dev/null +++ b/mysql-test/suite/mariabackup/truncate_during_backup.test @@ -0,0 +1,18 @@ +--source include/have_debug.inc +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +mkdir $targetdir; + +CREATE TABLE t1 ENGINE=InnoDB SELECT 1; + +--let after_load_tablespaces=TRUNCATE test.t1 + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +--let after_load_tablespaces= + +DROP TABLE t1; +SET GLOBAL innodb_log_checkpoint_now=1; +SET GLOBAL innodb_log_checkpoint_now=DEFAULT; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/undo_space_id.opt b/mysql-test/suite/mariabackup/undo_space_id.opt new file mode 100644 index 00000000..006e17a2 --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_space_id.opt @@ -0,0 +1,3 @@ +--debug=d,innodb_undo_upgrade,force_rebootstrap +--innodb_data_file_path=ib_mysql:10M +--innodb_undo_tablespaces=2 diff --git a/mysql-test/suite/mariabackup/undo_space_id.result b/mysql-test/suite/mariabackup/undo_space_id.result new file mode 100644 index 00000000..b03b9705 --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_space_id.result @@ -0,0 +1,13 @@ +# Create 2 UNDO TABLESPACE(UNDO001(space_id =3), UNDO002(space_id =4)) +CREATE TABLE t1(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t1 VALUES(1); +# xtrabackup backup +# Display undo log files from target directory +undo001 +undo002 +# xtrabackup prepare +# Display undo log files from targer directory +undo001 +undo002 +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/undo_space_id.test b/mysql-test/suite/mariabackup/undo_space_id.test new file mode 100644 index 00000000..2c56492f --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_space_id.test @@ -0,0 +1,25 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +--echo # Create 2 UNDO TABLESPACE(UNDO001(space_id =3), UNDO002(space_id =4)) + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE t1(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t1 VALUES(1); + +--echo # xtrabackup backup +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log +--echo # Display undo log files from target directory +list_files $basedir undo*; + +--echo # xtrabackup prepare +exec $XTRABACKUP --prepare --target-dir=$basedir; +--echo # Display undo log files from targer directory +list_files $basedir undo*; + +DROP TABLE t1; +rmdir $basedir; diff --git a/mysql-test/suite/mariabackup/undo_upgrade.result b/mysql-test/suite/mariabackup/undo_upgrade.result new file mode 100644 index 00000000..7b77e9ff --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_upgrade.result @@ -0,0 +1,19 @@ +set global innodb_fast_shutdown=0; +# restart: --innodb_undo_tablespaces=2 +CREATE TABLE t1(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t1 VALUES(1); +# xtrabackup backup +# Restart the server with 4 undo tablespaces +set global innodb_fast_shutdown=0; +# restart: --innodb_undo_tablespaces=4 +# incremental backup should fail +FOUND 1 /--incremental backup is impossible if the server had been restarted with different innodb_undo_tablespaces/ in backup.log +# Take full backup again +# Prepare full backup +# Display 4 undo log files from target directory +undo001 +undo002 +undo003 +undo004 +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/undo_upgrade.test b/mysql-test/suite/mariabackup/undo_upgrade.test new file mode 100644 index 00000000..3d599269 --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_upgrade.test @@ -0,0 +1,50 @@ +--source include/have_innodb.inc +--source include/innodb_page_size.inc + +let basedir=$MYSQLTEST_VARDIR/tmp/backup; +let incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +set global innodb_fast_shutdown=0; +let $restart_parameters=--innodb_undo_tablespaces=2; +--source include/restart_mysqld.inc + +CREATE TABLE t1(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t1 VALUES(1); + +--echo # xtrabackup backup +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +--echo # Restart the server with 4 undo tablespaces +let $restart_parameters=--innodb_undo_tablespaces=4; +set global innodb_fast_shutdown=0; +--source include/restart_mysqld.inc + +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; +--echo # incremental backup should fail +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir 2> $backuplog; + +--let SEARCH_PATTERN=--incremental backup is impossible if the server had been restarted with different innodb_undo_tablespaces +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; +rmdir $incremental_dir; +rmdir $basedir; + +--echo # Take full backup again +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log +--disable_result_log + +echo # Prepare full backup; +exec $XTRABACKUP --prepare --target-dir=$basedir; + +--echo # Display 4 undo log files from target directory +list_files $basedir undo*; + +DROP TABLE t1; +rmdir $basedir; diff --git a/mysql-test/suite/mariabackup/unencrypted_page_compressed.result b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result new file mode 100644 index 00000000..d995d1be --- /dev/null +++ b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result @@ -0,0 +1,9 @@ +call mtr.add_suppression("InnoDB: Table `test`.`t1` has an unreadable root page"); +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes; +insert into t1(b, c) values("mariadb", "mariabackup"); +InnoDB 0 transactions not purged +# Corrupt the table +# restart: --skip-innodb-buffer-pool-load-at-startup +# xtrabackup backup +FOUND 1 /Database page corruption detected.*/ in backup.log +drop table t1; diff --git a/mysql-test/suite/mariabackup/unencrypted_page_compressed.test b/mysql-test/suite/mariabackup/unencrypted_page_compressed.test new file mode 100644 index 00000000..247a210a --- /dev/null +++ b/mysql-test/suite/mariabackup/unencrypted_page_compressed.test @@ -0,0 +1,49 @@ +call mtr.add_suppression("InnoDB: Table `test`.`t1` has an unreadable root page"); +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes; +insert into t1(b, c) values("mariadb", "mariabackup"); +--source ../innodb/include/wait_all_purged.inc + +let $MYSQLD_DATADIR=`select @@datadir`; +let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd; +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; + +--source include/shutdown_mysqld.inc + +--echo # Corrupt the table + +perl; +use strict; +use warnings; +use Fcntl qw(:DEFAULT :seek); + +my $ibd_file = $ENV{'t1_IBD'}; + +my $chunk; +my $page_size = $ENV{'INNODB_PAGE_SIZE'}; + +sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file"; +sysseek IBD_FILE, 16384 * 3 + 75, SEEK_CUR; +$chunk = '\xAA\xAA\xAA\xAA'; +syswrite IBD_FILE, $chunk, 4; + +close IBD_FILE; +EOF + +--let $restart_parameters= --skip-innodb-buffer-pool-load-at-startup +--source include/start_mysqld.inc + +echo # xtrabackup backup; +--disable_result_log +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --core-file > $backuplog; +--enable_result_log + +--let SEARCH_PATTERN=Database page corruption detected.* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; + +drop table t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/unsupported_redo.result b/mysql-test/suite/mariabackup/unsupported_redo.result new file mode 100644 index 00000000..4ba40f5a --- /dev/null +++ b/mysql-test/suite/mariabackup/unsupported_redo.result @@ -0,0 +1,32 @@ +call mtr.add_suppression("InnoDB: New log files created"); +call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation"); +call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified"); +call mtr.add_suppression("InnoDB: Ignoring tablespace for `test`\\.`t21` because it could not be opened"); +call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: "); +call mtr.add_suppression("Table .* in the InnoDB data dictionary has tablespace id .*, but tablespace with that id or name does not exist"); +CREATE TABLE t1(i INT PRIMARY KEY auto_increment, a int) ENGINE INNODB; +ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; +# No longer fails during full backup +DROP TABLE t1; +CREATE TABLE t1(i INT PRIMARY KEY auto_increment, a int) ENGINE INNODB; +INSERT INTO t1(a) select 1 union select 2 union select 3; +# Create full backup , modify table, then fails during creation of +# incremental/differential backup +ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; +DROP TABLE t1; +CREATE TABLE t1(i INT) ENGINE INNODB; +INSERT INTO t1 VALUES(1); +CREATE TABLE t21(i INT) ENGINE INNODB; +INSERT INTO t21 VALUES(1); +CREATE TABLE t2(i int) ENGINE INNODB; +ALTER TABLE t21 FORCE, ALGORITHM=INPLACE; +# Create partial backup (excluding table t21), Ignore the +# unsupported redo log for the table t21. +t1.new +t2.new +# Prepare the full backup +t1.ibd +t2.ibd +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t21; diff --git a/mysql-test/suite/mariabackup/unsupported_redo.test b/mysql-test/suite/mariabackup/unsupported_redo.test new file mode 100644 index 00000000..97e1cad2 --- /dev/null +++ b/mysql-test/suite/mariabackup/unsupported_redo.test @@ -0,0 +1,75 @@ +--source include/have_innodb.inc +--source include/innodb_undo_tablespaces.inc +call mtr.add_suppression("InnoDB: New log files created"); +call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation"); +call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified"); +call mtr.add_suppression("InnoDB: Ignoring tablespace for `test`\\.`t21` because it could not be opened"); +call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: "); +call mtr.add_suppression("Table .* in the InnoDB data dictionary has tablespace id .*, but tablespace with that id or name does not exist"); + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +CREATE TABLE t1(i INT PRIMARY KEY auto_increment, a int) ENGINE INNODB; +ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; + +echo # No longer fails during full backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +DROP TABLE t1; + +rmdir $basedir; + +CREATE TABLE t1(i INT PRIMARY KEY auto_increment, a int) ENGINE INNODB; + +INSERT INTO t1(a) select 1 union select 2 union select 3; + +--echo # Create full backup , modify table, then fails during creation of +--echo # incremental/differential backup +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir; +--enable_result_log + +DROP TABLE t1; + +rmdir $basedir;rmdir $incremental_dir; + +CREATE TABLE t1(i INT) ENGINE INNODB; +INSERT INTO t1 VALUES(1); +CREATE TABLE t21(i INT) ENGINE INNODB; +INSERT INTO t21 VALUES(1); + +let $MYSQLD_DATADIR= `select @@datadir`; +let $targetdir=$MYSQLTEST_VARDIR/tmp/bk; + +CREATE TABLE t2(i int) ENGINE INNODB; + +ALTER TABLE t21 FORCE, ALGORITHM=INPLACE; + +--echo # Create partial backup (excluding table t21), Ignore the +--echo # unsupported redo log for the table t21. + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables-exclude=test.t21" --target-dir=$targetdir; +--enable_result_log +--list_files $targetdir/test *.ibd +--list_files $targetdir/test *.new + +--echo # Prepare the full backup +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +--enable_result_log +--list_files $targetdir/test *.ibd + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t21; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.opt b/mysql-test/suite/mariabackup/xb_aws_key_management.opt new file mode 100644 index 00000000..fceff3be --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.opt @@ -0,0 +1,3 @@ +--plugin-load-add=$AWS_KEY_MANAGEMENT_SO +--loose-aws-key-management +--loose-aws-key-management-mock=ON diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.result b/mysql-test/suite/mariabackup/xb_aws_key_management.result new file mode 100644 index 00000000..0ca72291 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.result @@ -0,0 +1,11 @@ +CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes; +INSERT INTO t VALUES('foobar1'); +# xtrabackup backup +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * from t; +c +foobar1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.test b/mysql-test/suite/mariabackup/xb_aws_key_management.test new file mode 100644 index 00000000..c8a12f6e --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.test @@ -0,0 +1,19 @@ +--source include/have_debug.inc + +if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'aws_key_management' AND PLUGIN_STATUS='ACTIVE'`) +{ + --skip needs aws_key_management plugin +} + +CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes; +INSERT INTO t VALUES('foobar1'); +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log +SELECT * from t; +DROP TABLE t; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/xb_compressed_encrypted.opt b/mysql-test/suite/mariabackup/xb_compressed_encrypted.opt new file mode 100644 index 00000000..4105fecf --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_compressed_encrypted.opt @@ -0,0 +1,8 @@ +--innodb-encryption-rotate-key-age=0 +--innodb-encryption-threads=4 +--innodb-tablespaces-encryption +--plugin-load-add=$FILE_KEY_MANAGEMENT_SO +--loose-file-key-management +--loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/logkey.txt +--innodb_strict_mode +--innodb_file_per_table diff --git a/mysql-test/suite/mariabackup/xb_compressed_encrypted.result b/mysql-test/suite/mariabackup/xb_compressed_encrypted.result new file mode 100644 index 00000000..22a4c151 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_compressed_encrypted.result @@ -0,0 +1,14 @@ +CREATE TABLE t1(c1 INT, b VARCHAR(2400), index(b(100),c1)) +ENGINE=INNODB ROW_FORMAT=compressed ENCRYPTED=YES; +BEGIN; +COMMIT; +# xtrabackup backup +drop table t1; +# shutdown server +# remove datadir +# xtrabackup move back +# restart +select sum(c1) from t1; +sum(c1) +12497500 +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/xb_compressed_encrypted.test b/mysql-test/suite/mariabackup/xb_compressed_encrypted.test new file mode 100644 index 00000000..2cca740d --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_compressed_encrypted.test @@ -0,0 +1,31 @@ +--source include/innodb_page_size_small.inc +--source include/have_file_key_management.inc + +CREATE TABLE t1(c1 INT, b VARCHAR(2400), index(b(100),c1)) +ENGINE=INNODB ROW_FORMAT=compressed ENCRYPTED=YES; + +BEGIN; +let $n= 5000; +let $i= $n; +let $u= `SELECT uuid()`; +--disable_query_log +while ($i) { + eval INSERT INTO t1 + VALUES($n-$i, concat('$u', $n-$i, repeat('ab', floor(rand()*100)), '$u')); + dec $i; +} +--enable_query_log +COMMIT; + +echo # xtrabackup backup; +--disable_result_log +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp $targetdir; +drop table t1; +exec $INNOBACKUPEX --apply-log $targetdir; + +-- source include/restart_and_restore.inc +--enable_result_log +select sum(c1) from t1; +DROP TABLE t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/xb_file_key_management.opt b/mysql-test/suite/mariabackup/xb_file_key_management.opt new file mode 100644 index 00000000..74a6450a --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_file_key_management.opt @@ -0,0 +1,6 @@ +--innodb-encrypt-log=ON +--plugin-load-add=$FILE_KEY_MANAGEMENT_SO +--loose-file-key-management +--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 diff --git a/mysql-test/suite/mariabackup/xb_file_key_management.result b/mysql-test/suite/mariabackup/xb_file_key_management.result new file mode 100644 index 00000000..cf8edb31 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_file_key_management.result @@ -0,0 +1,18 @@ +CREATE TABLE t(c TEXT) ENGINE INNODB encrypted=yes; +INSERT INTO t VALUES(REPEAT('fubar',100)); +INSERT INTO t VALUES('foobar1'); +DELETE FROM t LIMIT 1; +# xtrabackup backup +NOT FOUND /foobar1/ in ib_logfile0 +# expect NOT FOUND +INSERT INTO t VALUES('foobar2'); +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +ib_logfile0 +SELECT * FROM t; +c +foobar1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/xb_file_key_management.test b/mysql-test/suite/mariabackup/xb_file_key_management.test new file mode 100644 index 00000000..4d27b2df --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_file_key_management.test @@ -0,0 +1,33 @@ +#--source include/innodb_page_size.inc +--source include/have_file_key_management.inc + +CREATE TABLE t(c TEXT) ENGINE INNODB encrypted=yes; +INSERT INTO t VALUES(REPEAT('fubar',100)); +INSERT INTO t VALUES('foobar1'); +DELETE FROM t LIMIT 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 + +--let SEARCH_RANGE = 10000000 +--let SEARCH_PATTERN=foobar1 +--let SEARCH_FILE=$targetdir/ib_logfile0 +--source include/search_pattern_in_file.inc +--echo # expect NOT FOUND + +INSERT INTO t VALUES('foobar2'); +echo # xtrabackup prepare; + +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +--list_files $targetdir ib_logfile* +--remove_file $targetdir/ib_logfile0 + +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/xb_fulltext_encrypted.opt b/mysql-test/suite/mariabackup/xb_fulltext_encrypted.opt new file mode 100644 index 00000000..b3ef3663 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_fulltext_encrypted.opt @@ -0,0 +1,8 @@ +--plugin-load-add=$FILE_KEY_MANAGEMENT_SO +--innodb_strict_mode +--innodb_file_per_table +--innodb-encryption-rotate-key-age=2 +--innodb-encryption-threads=4 +--innodb-tablespaces-encryption +--loose-file-key-management +--loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/logkey.txt
\ No newline at end of file diff --git a/mysql-test/suite/mariabackup/xb_fulltext_encrypted.result b/mysql-test/suite/mariabackup/xb_fulltext_encrypted.result new file mode 100644 index 00000000..7c0a6451 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_fulltext_encrypted.result @@ -0,0 +1,14 @@ +CREATE TABLE film_text ( +film_id SMALLINT NOT NULL, +title VARCHAR(255) NOT NULL, +description TEXT, +PRIMARY KEY (film_id), +FULLTEXT KEY idx_title_description (title,description), +FULLTEXT KEY (description), +FULLTEXT KEY (title) +)ENGINE=InnoDB DEFAULT CHARSET=utf8 ENCRYPTED=YES; +# shutdown server +# remove datadir +# xtrabackup move back +# restart +drop table film_text; diff --git a/mysql-test/suite/mariabackup/xb_fulltext_encrypted.test b/mysql-test/suite/mariabackup/xb_fulltext_encrypted.test new file mode 100644 index 00000000..f7b72b5c --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_fulltext_encrypted.test @@ -0,0 +1,24 @@ +#--source include/innodb_page_size.inc +--source include/have_file_key_management.inc + +CREATE TABLE film_text ( +film_id SMALLINT NOT NULL, +title VARCHAR(255) NOT NULL, +description TEXT, +PRIMARY KEY (film_id), +FULLTEXT KEY idx_title_description (title,description), +FULLTEXT KEY (description), +FULLTEXT KEY (title) +)ENGINE=InnoDB DEFAULT CHARSET=utf8 ENCRYPTED=YES; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--disable_result_log + +exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp $targetdir; +exec $INNOBACKUPEX --apply-log $targetdir; +--source include/restart_and_restore.inc + +--enable_result_log + +drop table film_text; diff --git a/mysql-test/suite/mariabackup/xb_history.result b/mysql-test/suite/mariabackup/xb_history.result new file mode 100644 index 00000000..9feb5f41 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_history.result @@ -0,0 +1,37 @@ +DROP TABLE IF EXISTS mysql.mariadb_backup_history; +SHOW CREATE TABLE mysql.mariadb_backup_history; +Table Create Table +mariadb_backup_history CREATE TABLE `mariadb_backup_history` ( + `uuid` varchar(40) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `tool_name` varchar(255) DEFAULT NULL, + `tool_command` text DEFAULT NULL, + `tool_version` varchar(255) DEFAULT NULL, + `ibbackup_version` varchar(255) DEFAULT NULL, + `server_version` varchar(255) DEFAULT NULL, + `start_time` timestamp NULL DEFAULT NULL, + `end_time` timestamp NULL DEFAULT NULL, + `lock_time` bigint(20) unsigned DEFAULT NULL, + `binlog_pos` varchar(128) DEFAULT NULL, + `innodb_from_lsn` bigint(20) unsigned DEFAULT NULL, + `innodb_to_lsn` bigint(20) unsigned DEFAULT NULL, + `partial` enum('Y','N') DEFAULT NULL, + `incremental` enum('Y','N') DEFAULT NULL, + `format` enum('file','tar','xbstream') DEFAULT NULL, + `compressed` enum('Y','N') DEFAULT NULL, + PRIMARY KEY (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci +SELECT COUNT(*) FROM mysql.mariadb_backup_history; +COUNT(*) +1 +SELECT name FROM mysql.mariadb_backup_history; +name +foo +SELECT COUNT(*) FROM mysql.mariadb_backup_history; +COUNT(*) +2 +SELECT name FROM mysql.mariadb_backup_history; +name + +foo +DROP TABLE mysql.mariadb_backup_history; diff --git a/mysql-test/suite/mariabackup/xb_history.test b/mysql-test/suite/mariabackup/xb_history.test new file mode 100644 index 00000000..f9374a1a --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_history.test @@ -0,0 +1,27 @@ +#--source include/innodb_page_size.inc + +--disable_warnings +DROP TABLE IF EXISTS mysql.mariadb_backup_history; +--enable_warnings + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --history=foo --backup --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +SHOW CREATE TABLE mysql.mariadb_backup_history; +SELECT COUNT(*) FROM mysql.mariadb_backup_history; +SELECT name FROM mysql.mariadb_backup_history; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --history --backup --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +SELECT COUNT(*) FROM mysql.mariadb_backup_history; +--sorted_result +SELECT name FROM mysql.mariadb_backup_history; + +DROP TABLE mysql.mariadb_backup_history; diff --git a/mysql-test/suite/mariabackup/xb_page_compress.result b/mysql-test/suite/mariabackup/xb_page_compress.result new file mode 100644 index 00000000..7380856f --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_page_compress.result @@ -0,0 +1,28 @@ +CREATE TABLE t1(c1 INT, b CHAR(20)) ENGINE=INNODB PAGE_COMPRESSED=1; +CREATE PROCEDURE innodb_insert_proc (REPEAT_COUNT INT) +BEGIN +DECLARE CURRENT_NUM INT; +SET CURRENT_NUM = 0; +WHILE CURRENT_NUM < REPEAT_COUNT DO +INSERT INTO t1 VALUES(CURRENT_NUM,'TESTING..'); +SET CURRENT_NUM = CURRENT_NUM + 1; +END WHILE; +END// +COMMIT; +SET AUTOCOMMIT=0; +CALL innodb_insert_proc(5000); +COMMIT; +SELECT (VARIABLE_VALUE >= 0) AS HAVE_COMPRESSED_PAGES +FROM INFORMATION_SCHEMA.GLOBAL_STATUS +WHERE VARIABLE_NAME = 'INNODB_NUM_PAGES_PAGE_COMPRESSED'; +HAVE_COMPRESSED_PAGES +1 +# xtrabackup backup +# xtrabackup prepare +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t1 IMPORT TABLESPACE; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +DROP PROCEDURE innodb_insert_proc; +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/xb_page_compress.test b/mysql-test/suite/mariabackup/xb_page_compress.test new file mode 100644 index 00000000..7e806e6d --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_page_compress.test @@ -0,0 +1,45 @@ +#--source include/innodb_page_size.inc + +CREATE TABLE t1(c1 INT, b CHAR(20)) ENGINE=INNODB PAGE_COMPRESSED=1; + +DELIMITER //; +CREATE PROCEDURE innodb_insert_proc (REPEAT_COUNT INT) +BEGIN + DECLARE CURRENT_NUM INT; + SET CURRENT_NUM = 0; + WHILE CURRENT_NUM < REPEAT_COUNT DO + INSERT INTO t1 VALUES(CURRENT_NUM,'TESTING..'); + SET CURRENT_NUM = CURRENT_NUM + 1; + END WHILE; +END// +DELIMITER ;// +COMMIT; + +SET AUTOCOMMIT=0; +CALL innodb_insert_proc(5000); +COMMIT; + +SELECT (VARIABLE_VALUE >= 0) AS HAVE_COMPRESSED_PAGES + FROM INFORMATION_SCHEMA.GLOBAL_STATUS + WHERE VARIABLE_NAME = 'INNODB_NUM_PAGES_PAGE_COMPRESSED'; + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.*1" --target-dir=$targetdir; +echo # xtrabackup prepare; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir; +--enable_result_log + +ALTER TABLE t1 DISCARD TABLESPACE; +let $MYSQLD_DATADIR= `select @@datadir`; +copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd; +copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg; +ALTER TABLE t1 IMPORT TABLESPACE; + +SELECT COUNT(*) FROM t1; + +DROP PROCEDURE innodb_insert_proc; +DROP TABLE t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/xb_partition.result b/mysql-test/suite/mariabackup/xb_partition.result new file mode 100644 index 00000000..69896371 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_partition.result @@ -0,0 +1,64 @@ +CREATE TABLE t1(a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2(a INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (4), (5), (6); +CREATE TABLE p ( +a int +) ENGINE=InnoDB +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (100), +PARTITION p1 VALUES LESS THAN (200), +PARTITION p2 VALUES LESS THAN (300), +PARTITION p3 VALUES LESS THAN (400)); +INSERT INTO p VALUES (1), (101), (201), (301); +CREATE TABLE isam_t1(a INT) ENGINE=MyISAM; +INSERT INTO isam_t1 VALUES (1), (2), (3); +CREATE TABLE isam_t2(a INT) ENGINE=MyISAM; +INSERT INTO isam_t2 VALUES (4), (5), (6); +CREATE TABLE isam_p ( +a int +) ENGINE=MyISAM +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (100), +PARTITION p1 VALUES LESS THAN (200), +PARTITION p2 VALUES LESS THAN (300), +PARTITION p3 VALUES LESS THAN (400)); +INSERT INTO isam_p VALUES (1), (101), (201), (301); +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t2(a INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (40), (50), (60); +ALTER TABLE p DROP PARTITION p0; +ALTER TABLE p DROP PARTITION p1; +ALTER TABLE p ADD PARTITION (PARTITION p4 VALUES LESS THAN (500)); +ALTER TABLE p ADD PARTITION (PARTITION p5 VALUES LESS THAN (600)); +INSERT INTO p VALUES (401), (501); +DROP TABLE isam_t1; +DROP TABLE isam_t2; +CREATE TABLE isam_t2(a INT) ENGINE=MyISAM; +INSERT INTO isam_t2 VALUES (40), (50), (60); +ALTER TABLE isam_p DROP PARTITION p0; +ALTER TABLE isam_p DROP PARTITION p1; +ALTER TABLE isam_p ADD PARTITION (PARTITION p4 VALUES LESS THAN (500)); +ALTER TABLE isam_p ADD PARTITION (PARTITION p5 VALUES LESS THAN (600)); +INSERT INTO isam_p VALUES (401), (501); +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * from p; +a +201 +301 +401 +501 +SELECT * from isam_p; +a +201 +301 +401 +501 +DROP TABLE isam_p; +DROP TABLE isam_t2; +DROP TABLE p; +DROP TABLE t2; diff --git a/mysql-test/suite/mariabackup/xb_partition.test b/mysql-test/suite/mariabackup/xb_partition.test new file mode 100644 index 00000000..1c8eeaa1 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_partition.test @@ -0,0 +1,88 @@ +#--source include/innodb_page_size.inc +--source include/have_partition.inc +--source include/innodb_undo_tablespaces.inc + +CREATE TABLE t1(a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE TABLE t2(a INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (4), (5), (6); + +CREATE TABLE p ( + a int +) ENGINE=InnoDB +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (100), + PARTITION p1 VALUES LESS THAN (200), + PARTITION p2 VALUES LESS THAN (300), + PARTITION p3 VALUES LESS THAN (400)); + +INSERT INTO p VALUES (1), (101), (201), (301); + +CREATE TABLE isam_t1(a INT) ENGINE=MyISAM; +INSERT INTO isam_t1 VALUES (1), (2), (3); + +CREATE TABLE isam_t2(a INT) ENGINE=MyISAM; +INSERT INTO isam_t2 VALUES (4), (5), (6); + +CREATE TABLE isam_p ( + a int +) ENGINE=MyISAM +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (100), + PARTITION p1 VALUES LESS THAN (200), + PARTITION p2 VALUES LESS THAN (300), + PARTITION p3 VALUES LESS THAN (400)); + +INSERT INTO isam_p VALUES (1), (101), (201), (301); + +let $targetdir=$MYSQLTEST_VARDIR/tmp; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir/full; +--enable_result_log + +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t2(a INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (40), (50), (60); + +ALTER TABLE p DROP PARTITION p0; +ALTER TABLE p DROP PARTITION p1; +ALTER TABLE p ADD PARTITION (PARTITION p4 VALUES LESS THAN (500)); +ALTER TABLE p ADD PARTITION (PARTITION p5 VALUES LESS THAN (600)); + +INSERT INTO p VALUES (401), (501); + + +DROP TABLE isam_t1; +DROP TABLE isam_t2; +CREATE TABLE isam_t2(a INT) ENGINE=MyISAM; + +INSERT INTO isam_t2 VALUES (40), (50), (60); + +ALTER TABLE isam_p DROP PARTITION p0; +ALTER TABLE isam_p DROP PARTITION p1; +ALTER TABLE isam_p ADD PARTITION (PARTITION p4 VALUES LESS THAN (500)); +ALTER TABLE isam_p ADD PARTITION (PARTITION p5 VALUES LESS THAN (600)); + +INSERT INTO isam_p VALUES (401), (501); + +--disable_result_log +exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --incremental --no-timestamp --incremental-basedir=$targetdir/full $targetdir/inc; +exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --apply-log $targetdir/full; +exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --apply-log --incremental-dir=$targetdir/inc $targetdir/full; + +let $targetdir=$targetdir/full; +-- source include/restart_and_restore.inc +--enable_result_log + +SELECT * from p; +SELECT * from isam_p; + +DROP TABLE isam_p; +DROP TABLE isam_t2; +DROP TABLE p; +DROP TABLE t2; +rmdir $MYSQLTEST_VARDIR/tmp/full; +rmdir $MYSQLTEST_VARDIR/tmp/inc; diff --git a/mysql-test/suite/mariabackup/xb_rocksdb.opt b/mysql-test/suite/mariabackup/xb_rocksdb.opt new file mode 100644 index 00000000..e582413e --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb.opt @@ -0,0 +1 @@ +--plugin-load=$HA_ROCKSDB_SO
\ No newline at end of file diff --git a/mysql-test/suite/mariabackup/xb_rocksdb.result b/mysql-test/suite/mariabackup/xb_rocksdb.result new file mode 100644 index 00000000..fafa4925 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb.result @@ -0,0 +1,23 @@ +CREATE TABLE t(i INT) ENGINE ROCKSDB; +INSERT INTO t VALUES(1); +# xtrabackup backup +INSERT INTO t VALUES(2); +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +# xbstream extract +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart server +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/xb_rocksdb.test b/mysql-test/suite/mariabackup/xb_rocksdb.test new file mode 100644 index 00000000..e41f3b2b --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb.test @@ -0,0 +1,52 @@ +--source include/have_rocksdb.inc + +CREATE TABLE t(i INT) ENGINE ROCKSDB; +INSERT INTO t VALUES(1); +echo # xtrabackup backup; +# we'll backup to both directory and to stream to restore that later + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $stream=$MYSQLTEST_VARDIR/tmp/backup.xb; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir $backup_extra_param; +--enable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --stream=xbstream > $stream 2>$MYSQLTEST_VARDIR/tmp/backup_stream.log; + +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; + +rmdir $targetdir; +mkdir $targetdir; + + +echo # xbstream extract; + +exec $XBSTREAM -x -C $targetdir < $stream; + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; + +let $_datadir= `SELECT @@datadir`; +echo # shutdown server; +--source include/shutdown_mysqld.inc +echo # remove datadir; +rmdir $_datadir; +echo # xtrabackup move back; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --move-back --datadir=$_datadir --target-dir=$targetdir $copy_back_extra_param; +echo # restart server; +--source include/start_mysqld.inc + +--enable_result_log +SELECT * FROM t; + +DROP TABLE t; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/xb_rocksdb_datadir.opt b/mysql-test/suite/mariabackup/xb_rocksdb_datadir.opt new file mode 100644 index 00000000..0f069018 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb_datadir.opt @@ -0,0 +1 @@ +--plugin-load=$HA_ROCKSDB_SO --loose-rocksdb-datadir=$MYSQLTEST_VARDIR/tmp/rocksdb_datadir
\ No newline at end of file diff --git a/mysql-test/suite/mariabackup/xb_rocksdb_datadir.result b/mysql-test/suite/mariabackup/xb_rocksdb_datadir.result new file mode 100644 index 00000000..76130c2f --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb_datadir.result @@ -0,0 +1,10 @@ +CREATE TABLE t(i INT) ENGINE ROCKSDB; +INSERT INTO t VALUES(1); +# xtrabackup backup +INSERT INTO t VALUES(2); +# xtrabackup prepare +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/xb_rocksdb_datadir.test b/mysql-test/suite/mariabackup/xb_rocksdb_datadir.test new file mode 100644 index 00000000..c2e90d90 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb_datadir.test @@ -0,0 +1,34 @@ +if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'rocksdb'`) +{ + --skip Requires rocksdb +} + + +CREATE TABLE t(i INT) ENGINE ROCKSDB; +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 + +INSERT INTO t VALUES(2); + + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +let $_datadir= `SELECT @@datadir`; +let $_rocksdb_datadir=`SELECT @@rocksdb_datadir`; +--source include/shutdown_mysqld.inc +rmdir $_datadir; +rmdir $_rocksdb_datadir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --move-back --target-dir=$targetdir --datadir=$_datadir --rocksdb_datadir=$_rocksdb_datadir; +--enable_result_log +--source include/start_mysqld.inc + + +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.opt b/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.opt new file mode 100644 index 00000000..0f069018 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.opt @@ -0,0 +1 @@ +--plugin-load=$HA_ROCKSDB_SO --loose-rocksdb-datadir=$MYSQLTEST_VARDIR/tmp/rocksdb_datadir
\ No newline at end of file diff --git a/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.result b/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.result new file mode 100644 index 00000000..76130c2f --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.result @@ -0,0 +1,10 @@ +CREATE TABLE t(i INT) ENGINE ROCKSDB; +INSERT INTO t VALUES(1); +# xtrabackup backup +INSERT INTO t VALUES(2); +# xtrabackup prepare +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.test b/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.test new file mode 100644 index 00000000..a71c63b9 --- /dev/null +++ b/mysql-test/suite/mariabackup/xb_rocksdb_datadir_debug.test @@ -0,0 +1,13 @@ +--source include/have_debug.inc +--source include/have_rocksdb.inc + +# Check how rocksdb backup works without hardlinks +let $backup_extra_param='--dbug=+d,no_hardlinks'; +let $copy_back_extra_param='--dbug=+d,no_hardlinks'; + +# Pretend that previous backup crashes, and left checkpoint directory +let $rocksdb_datadir= `SELECT @@rocksdb_datadir`; +mkdir $rocksdb_datadir/mariadb-checkpoint; + +--source xb_rocksdb_datadir.test + diff --git a/mysql-test/suite/mariabackup/xbstream.result b/mysql-test/suite/mariabackup/xbstream.result new file mode 100644 index 00000000..93f68eca --- /dev/null +++ b/mysql-test/suite/mariabackup/xbstream.result @@ -0,0 +1,13 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# xtrabackup backup to stream +# xbstream extract +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/xbstream.test b/mysql-test/suite/mariabackup/xbstream.test new file mode 100644 index 00000000..212ac598 --- /dev/null +++ b/mysql-test/suite/mariabackup/xbstream.test @@ -0,0 +1,24 @@ +--source include/innodb_page_size.inc + +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +mkdir $targetdir; +let $streamfile=$MYSQLTEST_VARDIR/tmp/backup.xb; + +echo # xtrabackup backup to stream; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --databases-exclude=foobar --stream=xbstream > $streamfile 2>$targetdir/backup_stream.log; +echo # xbstream extract; +--disable_result_log +exec $XBSTREAM -x -C $targetdir < $streamfile; + +echo # xtrabackup prepare; +exec $XTRABACKUP --prepare --target-dir=$targetdir; + +-- source include/restart_and_restore.inc +--enable_result_log +SELECT * FROM t; +DROP TABLE t; +rmdir $targetdir; + |