mirror of
https://github.com/MariaDB/server.git
synced 2026-04-28 19:25:32 +02:00
MDEV-16300 : remove rocksdb checkpoint created by mariabackup.
Add variable rocksdb_remove_mariabackup_checkpoint. If set, it will remove $rocksdb_datadir/mariabackup-checkpoint directory. The variable is to be used by exclusively by mariabackup, to remove temporary checkpoints.
This commit is contained in:
parent
dc9c555415
commit
ea70586282
4 changed files with 78 additions and 1 deletions
|
|
@ -479,6 +479,7 @@ static uint32_t rocksdb_access_hint_on_compaction_start;
|
|||
static char *rocksdb_compact_cf_name;
|
||||
static char *rocksdb_checkpoint_name;
|
||||
static my_bool rocksdb_signal_drop_index_thread;
|
||||
static my_bool rocksdb_signal_remove_mariabackup_checkpoint;
|
||||
static my_bool rocksdb_strict_collation_check = 1;
|
||||
static my_bool rocksdb_ignore_unknown_options = 1;
|
||||
static my_bool rocksdb_enable_2pc = 0;
|
||||
|
|
@ -515,6 +516,67 @@ std::atomic<uint64_t> rocksdb_row_lock_wait_timeouts(0);
|
|||
std::atomic<uint64_t> rocksdb_snapshot_conflict_errors(0);
|
||||
std::atomic<uint64_t> rocksdb_wal_group_syncs(0);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Remove directory with files in it.
|
||||
Used to remove checkpoint created by mariabackup.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#include <direct.h> /* unlink*/
|
||||
#ifndef F_OK
|
||||
#define F_OK 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static int rmdir_force(const char *dir) {
|
||||
if (access(dir, F_OK))
|
||||
return true;
|
||||
|
||||
char path[FN_REFLEN];
|
||||
char sep[] = {FN_LIBCHAR, 0};
|
||||
int err = 0;
|
||||
|
||||
MY_DIR *dir_info = my_dir(dir, MYF(MY_DONT_SORT | MY_WANT_STAT));
|
||||
if (!dir_info)
|
||||
return 1;
|
||||
|
||||
for (uint i = 0; i < dir_info->number_of_files; i++) {
|
||||
FILEINFO *file = dir_info->dir_entry + i;
|
||||
|
||||
strxnmov(path, sizeof(path), dir, sep, file->name, NULL);
|
||||
|
||||
err = my_delete(path, 0);
|
||||
|
||||
if (err) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
my_dirend(dir_info);
|
||||
|
||||
if (!err)
|
||||
err = rmdir(dir);
|
||||
|
||||
return (err == 0) ? HA_EXIT_SUCCESS : HA_EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
static void rocksdb_remove_mariabackup_checkpoint(
|
||||
my_core::THD *const,
|
||||
struct st_mysql_sys_var *const ,
|
||||
void *const var_ptr, const void *const) {
|
||||
std::string mariabackup_checkpoint_dir(rocksdb_datadir);
|
||||
|
||||
mariabackup_checkpoint_dir.append("/mariabackup-checkpoint");
|
||||
|
||||
if (unlink(mariabackup_checkpoint_dir.c_str()) == 0)
|
||||
return;
|
||||
|
||||
rmdir_force(mariabackup_checkpoint_dir.c_str());
|
||||
}
|
||||
|
||||
|
||||
static std::unique_ptr<rocksdb::DBOptions> rdb_init_rocksdb_db_options(void) {
|
||||
auto o = std::unique_ptr<rocksdb::DBOptions>(new rocksdb::DBOptions());
|
||||
|
||||
|
|
@ -1312,6 +1374,11 @@ static MYSQL_SYSVAR_STR(create_checkpoint, rocksdb_checkpoint_name,
|
|||
rocksdb_create_checkpoint,
|
||||
rocksdb_create_checkpoint_stub, "");
|
||||
|
||||
static MYSQL_SYSVAR_BOOL(remove_mariabackup_checkpoint,
|
||||
rocksdb_signal_remove_mariabackup_checkpoint,
|
||||
PLUGIN_VAR_RQCMDARG, "Remove mariabackup checkpoint",
|
||||
nullptr, rocksdb_remove_mariabackup_checkpoint, FALSE);
|
||||
|
||||
static MYSQL_SYSVAR_BOOL(signal_drop_index_thread,
|
||||
rocksdb_signal_drop_index_thread, PLUGIN_VAR_RQCMDARG,
|
||||
"Wake up drop index thread", nullptr,
|
||||
|
|
@ -1675,7 +1742,7 @@ static struct st_mysql_sys_var *rocksdb_system_variables[] = {
|
|||
MYSQL_SYSVAR(datadir),
|
||||
MYSQL_SYSVAR(supported_compression_types),
|
||||
MYSQL_SYSVAR(create_checkpoint),
|
||||
|
||||
MYSQL_SYSVAR(remove_mariabackup_checkpoint),
|
||||
MYSQL_SYSVAR(checksums_pct),
|
||||
MYSQL_SYSVAR(store_row_debug_checksums),
|
||||
MYSQL_SYSVAR(verify_row_debug_checksums),
|
||||
|
|
|
|||
|
|
@ -959,6 +959,7 @@ rocksdb_print_snapshot_conflict_queries OFF
|
|||
rocksdb_rate_limiter_bytes_per_sec 0
|
||||
rocksdb_read_free_rpl_tables
|
||||
rocksdb_records_in_range 50
|
||||
rocksdb_remove_mariabackup_checkpoint OFF
|
||||
rocksdb_reset_stats OFF
|
||||
rocksdb_seconds_between_stat_computes 3600
|
||||
rocksdb_signal_drop_index_thread OFF
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
SET GLOBAL rocksdb_create_checkpoint=CONCAT(@@rocksdb_datadir,'/mariabackup-checkpoint');
|
||||
SET GLOBAL rocksdb_remove_mariabackup_checkpoint=ON;
|
||||
SET GLOBAL rocksdb_create_checkpoint=CONCAT(@@rocksdb_datadir,'/mariabackup-checkpoint');
|
||||
SET GLOBAL rocksdb_remove_mariabackup_checkpoint=ON;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Simulate creating and removing mariabackup checkpoint twice
|
||||
SET GLOBAL rocksdb_create_checkpoint=CONCAT(@@rocksdb_datadir,'/mariabackup-checkpoint');
|
||||
SET GLOBAL rocksdb_remove_mariabackup_checkpoint=ON;
|
||||
SET GLOBAL rocksdb_create_checkpoint=CONCAT(@@rocksdb_datadir,'/mariabackup-checkpoint');
|
||||
SET GLOBAL rocksdb_remove_mariabackup_checkpoint=ON;
|
||||
Loading…
Add table
Add a link
Reference in a new issue