Skip to content

Commit

Permalink
MDEV-18310: Aria engine: Undo phase failed with "Got error 121 when
Browse files Browse the repository at this point in the history
executing undo undo_key_delete" upon startup on datadir restored from
incremental backup

aria_log* files were not copied on --prepare --incremental-dir step from
incremental to destination backup directory.
  • Loading branch information
vlad-lesin committed Nov 29, 2019
1 parent 32ce530 commit bd11bd6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 15 deletions.
31 changes: 20 additions & 11 deletions extra/mariabackup/backup_copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,9 @@ ibx_copy_incremental_over_full()
}
}

if (!(ret = backup_files_from_datadir(xtrabackup_incremental_dir)))
goto cleanup;

/* copy buffer pool dump */
if (innobase_buffer_pool_filename) {
const char *src_name;
Expand Down Expand Up @@ -2180,20 +2183,26 @@ static bool backup_files_from_datadir(const char *dir_path)
if (info.type != OS_FILE_TYPE_FILE)
continue;

const char *pname = strrchr(info.name, IF_WIN('\\', '/'));
const char *pname = strrchr(info.name, OS_PATH_SEPARATOR);
if (!pname)
pname = info.name;

/* Copy aria log files, and aws keys for encryption plugins.*/
const char *prefixes[] = { "aria_log", "aws-kms-key" };
for (size_t i = 0; i < array_elements(prefixes); i++) {
if (starts_with(pname, prefixes[i])) {
ret = copy_file(ds_data, info.name, info.name, 1);
if (!ret) {
break;
}
}
}
if (!starts_with(pname, "aws-kms-key") &&
!starts_with(pname, "aria_log"))
/* For ES exchange the above line with the following code:
(!xtrabackup_prepare || !xtrabackup_incremental_dir ||
!starts_with(pname, "aria_log")))
*/
continue;

if (xtrabackup_prepare && xtrabackup_incremental_dir &&
file_exists(info.name))
unlink(info.name);

std::string full_path(dir_path);
full_path.append(1, OS_PATH_SEPARATOR).append(info.name);
if (!(ret = copy_file(ds_data, full_path.c_str() , info.name, 1)))
break;
}
os_file_closedir(dir);
return ret;
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/suite/mariabackup/incremental_backup.result
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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;
BEGIN;
INSERT INTO t VALUES(2);
Expand All @@ -11,11 +12,13 @@ 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
# Prepare full backup, apply incremental one
# Aria log file was updated during applying incremental backup
disconnect con1;
# Restore and check results
# shutdown server
Expand All @@ -27,3 +30,4 @@ i
1
2
DROP TABLE t;
DROP TABLE t_aria;
63 changes: 59 additions & 4 deletions mysql-test/suite/mariabackup/incremental_backup.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
--source include/have_aria.inc
--source include/innodb_page_size.inc

call mtr.add_suppression("InnoDB: New log files created");

let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1;
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;
BEGIN;
INSERT INTO t VALUES(2);
Expand All @@ -14,21 +16,73 @@ 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;
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;
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;
# 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;
Expand All @@ -37,6 +91,7 @@ let $targetdir=$basedir;

SELECT * FROM t;
DROP TABLE t;
DROP TABLE t_aria;

# Cleanup
rmdir $basedir;
Expand Down

0 comments on commit bd11bd6

Please sign in to comment.