mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
MDEV-28187 mariadb-backup doesn't utilise innodb-undo-log-directory (if specified as a relative path) during copy-back operation
Make absolute destination path from relative one, basing on mysql data directory. Reviewed by Alexander Barkov.
This commit is contained in:
parent
a2cb6d8760
commit
f8c3d4c2d5
5 changed files with 77 additions and 8 deletions
|
|
@ -1816,13 +1816,28 @@ apply_log_finish()
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Copy_back_dst_dir
|
||||||
|
{
|
||||||
|
std::string buf;
|
||||||
|
|
||||||
|
public:
|
||||||
|
const char *make(const char *path)
|
||||||
|
{
|
||||||
|
if (!path || !path[0])
|
||||||
|
return mysql_data_home;
|
||||||
|
if (is_absolute_path(path))
|
||||||
|
return path;
|
||||||
|
return buf.assign(mysql_data_home).append(path).c_str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
copy_back()
|
copy_back()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
datadir_iter_t *it = NULL;
|
datadir_iter_t *it = NULL;
|
||||||
datadir_node_t node;
|
datadir_node_t node;
|
||||||
char *dst_dir;
|
const char *dst_dir;
|
||||||
|
|
||||||
memset(&node, 0, sizeof(node));
|
memset(&node, 0, sizeof(node));
|
||||||
|
|
||||||
|
|
@ -1875,9 +1890,9 @@ copy_back()
|
||||||
|
|
||||||
/* copy undo tablespaces */
|
/* copy undo tablespaces */
|
||||||
|
|
||||||
|
Copy_back_dst_dir dst_dir_buf;
|
||||||
|
|
||||||
dst_dir = (srv_undo_dir && *srv_undo_dir)
|
dst_dir = dst_dir_buf.make(srv_undo_dir);
|
||||||
? srv_undo_dir : mysql_data_home;
|
|
||||||
|
|
||||||
ds_data = ds_create(dst_dir, DS_TYPE_LOCAL);
|
ds_data = ds_create(dst_dir, DS_TYPE_LOCAL);
|
||||||
|
|
||||||
|
|
@ -1898,8 +1913,7 @@ copy_back()
|
||||||
|
|
||||||
/* copy redo logs */
|
/* copy redo logs */
|
||||||
|
|
||||||
dst_dir = (srv_log_group_home_dir && *srv_log_group_home_dir)
|
dst_dir = dst_dir_buf.make(srv_log_group_home_dir);
|
||||||
? srv_log_group_home_dir : mysql_data_home;
|
|
||||||
|
|
||||||
/* --backup generates a single ib_logfile0, which we must copy
|
/* --backup generates a single ib_logfile0, which we must copy
|
||||||
if it exists. */
|
if it exists. */
|
||||||
|
|
@ -1926,8 +1940,7 @@ copy_back()
|
||||||
|
|
||||||
/* copy innodb system tablespace(s) */
|
/* copy innodb system tablespace(s) */
|
||||||
|
|
||||||
dst_dir = (innobase_data_home_dir && *innobase_data_home_dir)
|
dst_dir = dst_dir_buf.make(innobase_data_home_dir);
|
||||||
? innobase_data_home_dir : mysql_data_home;
|
|
||||||
|
|
||||||
ds_data = ds_create(dst_dir, DS_TYPE_LOCAL);
|
ds_data = ds_create(dst_dir, DS_TYPE_LOCAL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ echo # shutdown server;
|
||||||
echo # remove datadir;
|
echo # remove datadir;
|
||||||
rmdir $_datadir;
|
rmdir $_datadir;
|
||||||
echo # xtrabackup move back;
|
echo # xtrabackup move back;
|
||||||
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir --parallel=2 --throttle=1;
|
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir --parallel=2 --throttle=1 $backup_opts;
|
||||||
--source include/start_mysqld.inc
|
--source include/start_mysqld.inc
|
||||||
|
|
|
||||||
1
mysql-test/suite/mariabackup/relative_path.opt
Normal file
1
mysql-test/suite/mariabackup/relative_path.opt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
--innodb-undo-tablespaces=2
|
||||||
20
mysql-test/suite/mariabackup/relative_path.result
Normal file
20
mysql-test/suite/mariabackup/relative_path.result
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
CREATE TABLE t(i INT) ENGINE INNODB;
|
||||||
|
INSERT INTO t VALUES(1);
|
||||||
|
# xtrabackup backup
|
||||||
|
# xtrabackup prepare
|
||||||
|
# shutdown server
|
||||||
|
# remove datadir
|
||||||
|
# xtrabackup move back
|
||||||
|
# restart
|
||||||
|
# shutdown server
|
||||||
|
# remove datadir
|
||||||
|
# xtrabackup move back
|
||||||
|
# restart
|
||||||
|
# shutdown server
|
||||||
|
# remove datadir
|
||||||
|
# xtrabackup move back
|
||||||
|
# restart
|
||||||
|
SELECT * FROM t;
|
||||||
|
i
|
||||||
|
1
|
||||||
|
DROP TABLE t;
|
||||||
35
mysql-test/suite/mariabackup/relative_path.test
Normal file
35
mysql-test/suite/mariabackup/relative_path.test
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
CREATE TABLE t(i INT) ENGINE INNODB;
|
||||||
|
INSERT INTO t VALUES(1);
|
||||||
|
|
||||||
|
echo # xtrabackup backup;
|
||||||
|
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
|
||||||
|
--let $backup_log=$MYSQLTEST_VARDIR/tmp/backup.log
|
||||||
|
|
||||||
|
--disable_result_log
|
||||||
|
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backup_log 2>&1;
|
||||||
|
--enable_result_log
|
||||||
|
|
||||||
|
echo # xtrabackup prepare;
|
||||||
|
--disable_result_log
|
||||||
|
exec $XTRABACKUP --prepare --target-dir=$targetdir;
|
||||||
|
|
||||||
|
# If MDEV-28187 is not fixed, the following tries to copy backup to data
|
||||||
|
# directory will fail, because their destination path will be the same as
|
||||||
|
# their source path
|
||||||
|
|
||||||
|
--let $backup_opts=--innodb_undo_directory=./
|
||||||
|
--source include/restart_and_restore.inc
|
||||||
|
|
||||||
|
--let $backup_opts=--innodb_log_group_home_dir=./
|
||||||
|
--source include/restart_and_restore.inc
|
||||||
|
|
||||||
|
--let $backup_opts=--innodb_data_home_dir=./
|
||||||
|
--source include/restart_and_restore.inc
|
||||||
|
|
||||||
|
--enable_result_log
|
||||||
|
|
||||||
|
SELECT * FROM t;
|
||||||
|
DROP TABLE t;
|
||||||
|
rmdir $targetdir;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue