summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/mariabackup/innodb_force_recovery.test
blob: 3a7b3c6106c6d42f070181392506c1b7b89e6771 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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