mirror of
https://github.com/MariaDB/server.git
synced 2026-05-02 13:15:32 +02:00
MDEV-24197: Add "innodb_force_recovery" for "mariabackup --prepare"
During the prepare phase of restoring backups, "mariabackup" does not seem to allow (or recognize) the option "innodb_force_recovery" for the embedded InnoDB server instance that it starts. If page corruption observed during page recovery, the prepare step fails. While this is indeed the correct behavior ideally, allowing this option to be set in case of emergencies might be useful when the current backup is the only copy available. Some error messages during "--prepare" suggest to set "innodb_force_recovery" to 1: [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption. For backwards compatibility, "mariabackup --innobackupex --apply-log" should also have this option. Signed-off-by: Srinidhi Kaushik <shrinidhi.kaushik@gmail.com>
This commit is contained in:
parent
f93e087d74
commit
5bc5ecce08
6 changed files with 233 additions and 9 deletions
26
mysql-test/suite/mariabackup/innodb_force_recovery.result
Normal file
26
mysql-test/suite/mariabackup/innodb_force_recovery.result
Normal file
|
|
@ -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 server
|
||||
SELECT * FROM t;
|
||||
i
|
||||
1
|
||||
DROP TABLE t;
|
||||
138
mysql-test/suite/mariabackup/innodb_force_recovery.test
Normal file
138
mysql-test/suite/mariabackup/innodb_force_recovery.test
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue