Skip to content

Commit 39ef6c0

Browse files
fdiarygrooverdan
authored andcommitted
MDEV-34425 mroonga files are not copied by mariabackup
Backing up with mariabackup a datadir containing ENGINE=Mroonga tables leaves behind the corresponding *.mrn* files. Those tables are therefore broken once such backup is restored. minor style/mtr changes by Daniel Black
1 parent 72d2b76 commit 39ef6c0

File tree

5 files changed

+87
-1
lines changed

5 files changed

+87
-1
lines changed

extra/mariabackup/backup_copy.cc

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,8 @@ backup_files(ds_ctxt *ds_data, const char *from)
13471347
}
13481348
}
13491349
}
1350+
if (!backup_mroonga_files_from_datadir(ds_data, from))
1351+
goto out;
13501352
msg("Finished backing up non-InnoDB tables and files");
13511353
out:
13521354
datadir_iter_free(it);
@@ -1509,7 +1511,9 @@ ibx_copy_incremental_over_full()
15091511
"aws-kms-key")) ||
15101512
!(ret = backup_files_from_datadir(ds_data,
15111513
xtrabackup_incremental_dir,
1512-
"aria_log")))
1514+
"aria_log")) ||
1515+
!(ret = backup_mroonga_files_from_datadir(ds_data,
1516+
xtrabackup_incremental_dir)))
15131517
goto cleanup;
15141518

15151519
/* copy supplementary files */
@@ -2068,6 +2072,47 @@ bool backup_files_from_datadir(ds_ctxt_t *ds_data,
20682072
return ret;
20692073
}
20702074

2075+
bool backup_mroonga_files_from_datadir(ds_ctxt_t *ds_data,
2076+
const char *dir_path)
2077+
{
2078+
os_file_dir_t dir= os_file_opendir(dir_path);
2079+
if (dir == IF_WIN(INVALID_HANDLE_VALUE, nullptr)) return false;
2080+
2081+
os_file_stat_t info;
2082+
bool ret= true;
2083+
while (os_file_readdir_next_file(dir_path, dir, &info) == 0)
2084+
{
2085+
2086+
if (info.type != OS_FILE_TYPE_FILE)
2087+
continue;
2088+
2089+
const char *pname = strrchr(info.name, '/');
2090+
#ifdef _WIN32
2091+
if (const char *last = strrchr(info.name, '\\'))
2092+
{
2093+
if (!pname || last > pname)
2094+
pname = last;
2095+
}
2096+
#endif
2097+
if (!pname)
2098+
pname = info.name;
2099+
2100+
if (!strstr(pname, ".mrn"))
2101+
continue;
2102+
2103+
if (xtrabackup_prepare && xtrabackup_incremental_dir &&
2104+
file_exists(info.name))
2105+
unlink(info.name);
2106+
2107+
std::string full_path(dir_path);
2108+
full_path.append(1, '/').append(info.name);
2109+
if (!(ret = ds_data->copy_file(full_path.c_str() , info.name, 1)))
2110+
break;
2111+
}
2112+
os_file_closedir(dir);
2113+
return ret;
2114+
}
2115+
20712116

20722117
static int rocksdb_remove_checkpoint_directory()
20732118
{

extra/mariabackup/backup_copy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ const char *trim_dotslash(const char *path);
5252
bool backup_files_from_datadir(ds_ctxt_t *ds_data,
5353
const char *dir_path,
5454
const char *prefix);
55+
bool backup_mroonga_files_from_datadir(ds_ctxt_t *ds_data,
56+
const char *dir_path);
5557

5658
bool is_system_table(const char *dbname, const char *tablename);
5759
std::unique_ptr<std::vector<std::string>>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--loose-plugin-load-add=$HA_MROONGA_SO --loose-plugin-mroonga=ON
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# MDEV-34425 mroonga files are not copied by mariabackup
3+
#
4+
CREATE TABLE t(c TEXT, FULLTEXT(c)) ENGINE=Mroonga;
5+
INSERT INTO t VALUES('Once upon a time'),('There was a wicked witch'),('Who ate everybody up');
6+
# mariadb-backup backup
7+
# shutdown server
8+
# remove datadir
9+
# xtrabackup move back
10+
# restart
11+
SELECT * FROM t WHERE MATCH(c) AGAINST('wicked');
12+
c
13+
There was a wicked witch
14+
DROP TABLE t;
15+
# End 10.11 tests
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'mroonga' AND PLUGIN_STATUS='ACTIVE'`)
2+
{
3+
--skip needs mroonga plugin
4+
}
5+
6+
--echo #
7+
--echo # MDEV-34425 mroonga files are not copied by mariabackup
8+
--echo #
9+
10+
CREATE TABLE t(c TEXT, FULLTEXT(c)) ENGINE=Mroonga;
11+
INSERT INTO t VALUES('Once upon a time'),('There was a wicked witch'),('Who ate everybody up');
12+
echo # mariadb-backup backup;
13+
let $targetdir=$MYSQL_TMP_DIR/backup;
14+
--disable_result_log
15+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
16+
exec $XTRABACKUP --prepare --target-dir=$targetdir;
17+
-- source include/restart_and_restore.inc
18+
--enable_result_log
19+
SELECT * FROM t WHERE MATCH(c) AGAINST('wicked');
20+
DROP TABLE t;
21+
rmdir $targetdir;
22+
23+
--echo # End 10.11 tests

0 commit comments

Comments
 (0)