Skip to content

Commit 77a32f3

Browse files
Merge branch 'PXB-2724-8.0' into PXB-2724-8.4
2 parents 8e75524 + e1146f0 commit 77a32f3

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

storage/innobase/xtrabackup/src/backup_copy.cc

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ static bool copy_or_move_file(const char *src_file_path,
923923
ds_ctxt_t *datasink = ds_data; /* copy to datadir by default */
924924
bool ret;
925925

926-
/* File is located outsude of the datadir */
926+
/* File is located outside of the datadir */
927927
char external_dir[FN_REFLEN];
928928

929929
if (Fil_path::type_of_path(dst_file_path) == Fil_path::absolute) {
@@ -1298,20 +1298,27 @@ Myrocks_checkpoint::file_list Myrocks_checkpoint::data_files() const {
12981298
return Myrocks_datadir(checkpoint_dir).data_files();
12991299
}
13001300

1301-
static void par_copy_rocksdb_files(const Myrocks_datadir::const_iterator &start,
1302-
const Myrocks_datadir::const_iterator &end,
1303-
size_t thread_n, ds_ctxt_t *ds,
1304-
bool *result) {
1301+
static void par_copy_or_move_rocksdb_files(
1302+
const Myrocks_datadir::const_iterator &start,
1303+
const Myrocks_datadir::const_iterator &end, size_t thread_n, ds_ctxt_t *ds,
1304+
bool *result) {
13051305
for (auto it = start; it != end; it++) {
13061306
if (ends_with(it->path.c_str(), ".qp") ||
13071307
ends_with(it->path.c_str(), ".lz4") ||
13081308
ends_with(it->path.c_str(), ".zst") ||
13091309
ends_with(it->path.c_str(), ".xbcrypt")) {
13101310
continue;
13111311
}
1312-
if (!copy_file(ds, it->path.c_str(), it->rel_path.c_str(), thread_n,
1313-
FILE_PURPOSE_OTHER, it->file_size)) {
1314-
*result = false;
1312+
if (xtrabackup_copy_back) {
1313+
if (!copy_file(ds, it->path.c_str(), it->rel_path.c_str(), thread_n,
1314+
FILE_PURPOSE_OTHER, it->file_size)) {
1315+
*result = false;
1316+
}
1317+
} else {
1318+
if (!move_file(ds, it->path.c_str(), it->rel_path.c_str(), ds->root,
1319+
thread_n, FILE_PURPOSE_OTHER)) {
1320+
*result = false;
1321+
}
13151322
}
13161323
if (!*result) {
13171324
break;
@@ -1944,7 +1951,8 @@ bool copy_incremental_over_full() {
19441951
bool result = true;
19451952
std::function<void(const Myrocks_datadir::const_iterator &,
19461953
const Myrocks_datadir::const_iterator &, size_t)>
1947-
copy = std::bind(&par_copy_rocksdb_files, _1, _2, _3, ds_data, &result);
1954+
copy = std::bind(&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
1955+
&result);
19481956

19491957
par_for(PFS_NOT_INSTRUMENTED, rocksdb.files(), xtrabackup_parallel, copy);
19501958
}
@@ -2445,7 +2453,8 @@ bool copy_back(int argc, char **argv) {
24452453
using std::placeholders::_3;
24462454
std::function<void(const Myrocks_datadir::const_iterator &,
24472455
const Myrocks_datadir::const_iterator &, size_t)>
2448-
copy = std::bind(&par_copy_rocksdb_files, _1, _2, _3, ds_data, &ret);
2456+
copy = std::bind(&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
2457+
&ret);
24492458

24502459
if (rocksdb_wal_dir.empty()) {
24512460
par_for(PFS_NOT_INSTRUMENTED, rocksdb.files("", ""), xtrabackup_parallel,
@@ -2479,7 +2488,8 @@ bool copy_back(int argc, char **argv) {
24792488
using std::placeholders::_3;
24802489
std::function<void(const Myrocks_datadir::const_iterator &,
24812490
const Myrocks_datadir::const_iterator &, size_t)>
2482-
copy = std::bind(&par_copy_rocksdb_files, _1, _2, _3, ds_data, &ret);
2491+
copy = std::bind(&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
2492+
&ret);
24832493

24842494
par_for(PFS_NOT_INSTRUMENTED, rocksdb.wal_files(""), xtrabackup_parallel,
24852495
copy);

storage/innobase/xtrabackup/test/suites/rocksdb/ddl.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ stop_server
115115
rm -rf $mysql_datadir
116116
xtrabackup --move-back --target-dir=$topdir/backup
117117

118+
# Check if RocksDB files have been moved (--move-back).
119+
if ls $topdir/backup/.rocksdb/* 1>/dev/null 2>&1 ; then
120+
die "RocksDB files haven't been moved."
121+
fi
122+
118123
start_server
119124

120125
# Verify backup

0 commit comments

Comments
 (0)