1#
2# If MDEV-20755 bug is no fixed, incremental prepare will fail.
3#
4--source include/have_debug.inc
5--source include/have_file_key_management.inc
6
7--let $base_dir=$MYSQLTEST_VARDIR/tmp/backup
8--let $inc_dir=$MYSQLTEST_VARDIR/tmp/backup_inc
9
10SET @old_innodb_log_optimize_ddl=@@global.innodb_log_optimize_ddl;
11SET GLOBAL innodb_log_optimize_ddl=ON;
12
13# Disable pages flushing to allow redo log records to be executed on --prepare.
14SET @old_debug_dbug=@@global.debug_dbug;
15SET GLOBAL debug_dbug="+d,ib_log_checkpoint_avoid";
16SET @old_innodb_page_cleaner_disabled_debug=@@global.innodb_page_cleaner_disabled_debug;
17SET GLOBAL innodb_page_cleaner_disabled_debug=ON;
18
19CREATE TABLE t1 (c INT) ENGINE=InnoDB;
20INSERT INTO t1 VALUES (1);
21
22--echo # backup
23--disable_result_log
24--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$base_dir
25--enable_result_log
26
27# Do not log crypt data to avoid it's execution on --prepare.
28SET GLOBAL debug_dbug="+d,ib_do_not_log_crypt_data";
29INSERT INTO t1 VALUES (2);
30
31--disable_result_log
32
33# Execute OPTIMIZE TABLE after the table is copied to execute optimized ddl
34# callback during backup, which, in turns, will create t1.new file in backup
35# directory.
36--let after_copy_test_t1=OPTIMIZE TABLE test.t1;
37
38--echo # incremental backup
39--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$inc_dir --incremental-basedir=$base_dir --dbug=+d,mariabackup_events
40
41--echo # prepare
42--exec $XTRABACKUP --prepare --target-dir=$base_dir
43
44# If the tablespace is created during delta tablespace open procedure, then
45# crypt data will be not written, and page corruption test will not pass
46# when some redo log event is executed, and --prepare will fail.
47--echo # incremental prepare
48--exec $XTRABACKUP --prepare --target-dir=$base_dir --incremental-dir=$inc_dir
49
50--enable_result_log
51
52SET GLOBAL innodb_log_optimize_ddl=@old_innodb_log_optimize_ddl;
53SET GLOBAL innodb_page_cleaner_disabled_debug=@old_innodb_page_cleaner_disabled_debug;
54SET GLOBAL debug_dbug=@old_debug_dbug;
55
56--echo # Restore and check results
57--let $targetdir=$base_dir
58--source include/restart_and_restore.inc
59--enable_result_log
60
61SELECT count(*) FROM t1;
62
63# Cleanup
64DROP TABLE t1;
65--rmdir $base_dir
66--rmdir $inc_dir
67