summaryrefslogtreecommitdiff
path: root/mysql-test/suite/mariabackup/incremental_backup.test
blob: fed2d5e60a9f208d0a4830fd8753240144375c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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;
--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;