Commit ddc1d690 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-14123: .rocksdb folder may break workflow which re-create data directory

Part2: make MyRocks add its directory into @@ignore_db_dirs when starting.

This is necessary because apparently not everybody are using plugin's my.cnf
So load ha_rocksdb.{so,dll} manually and then hit MDEV-12451, MDEV-14461
etc.
parent b8a0373e
......@@ -787,6 +787,57 @@ static void dispose_db_dir(void *ptr)
}
/*
Append an element into @@ignore_db_dirs
This is a function to be called after regular option processing has been
finalized.
*/
void ignore_db_dirs_append(const char *dirname_arg)
{
char *new_entry_buf;
LEX_STRING *new_entry;
size_t len= strlen(dirname_arg);
if (!my_multi_malloc(0,
&new_entry, sizeof(LEX_STRING),
&new_entry_buf, len + 1,
NullS))
return;
memcpy(new_entry_buf, dirname_arg, len+1);
new_entry->str = new_entry_buf;
new_entry->length= len;
if (my_hash_insert(&ignore_db_dirs_hash, (uchar *)new_entry))
{
// Either the name is already there or out-of-memory.
my_free(new_entry);
return;
}
// Append the name to the option string.
size_t curlen= strlen(opt_ignore_db_dirs);
// Add one for comma and one for \0.
size_t newlen= curlen + len + 1 + 1;
char *new_db_dirs;
if (!(new_db_dirs= (char*)my_malloc(newlen ,MYF(0))))
{
// This is not a critical condition
return;
}
memcpy(new_db_dirs, opt_ignore_db_dirs, curlen);
if (curlen != 0)
new_db_dirs[curlen]=',';
memcpy(new_db_dirs + (curlen + ((curlen!=0)?1:0)), dirname_arg, len+1);
if (opt_ignore_db_dirs)
my_free(opt_ignore_db_dirs);
opt_ignore_db_dirs= new_db_dirs;
}
bool
ignore_db_dirs_process_additions()
{
......
......@@ -111,6 +111,10 @@ bool thd_binlog_filter_ok(const MYSQL_THD thd);
MYSQL_PLUGIN_IMPORT bool my_disable_leak_check;
// Needed in rocksdb_init_func
void ignore_db_dirs_append(const char *dirname_arg);
namespace myrocks {
static st_global_stats global_stats;
......@@ -3934,6 +3938,7 @@ static rocksdb::Status check_rocksdb_options_compatibility(
return status;
}
/*
Storage Engine initialization function, invoked when plugin is loaded.
*/
......@@ -3962,6 +3967,11 @@ static int rocksdb_init_func(void *const p) {
mysql_mutex_init(rdb_mem_cmp_space_mutex_key, &rdb_mem_cmp_space_mutex,
MY_MUTEX_INIT_FAST);
const char* initial_rocksdb_datadir_for_ignore_dirs= rocksdb_datadir;
if (!strncmp(rocksdb_datadir, "./", 2))
initial_rocksdb_datadir_for_ignore_dirs += 2;
ignore_db_dirs_append(initial_rocksdb_datadir_for_ignore_dirs);
#if defined(HAVE_PSI_INTERFACE)
rdb_collation_exceptions =
new Regex_list_handler(key_rwlock_collation_exception_list);
......
#
# RocksDB plugin adds #rocksdb to ignore_db_dirs
#
select @@ignore_db_dirs;
@@ignore_db_dirs
#rocksdb
select @@ignore_db_dirs;
@@ignore_db_dirs
aa,bbb,#rocksdb
--ignore-db-dirs=#rocksdb --plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb
--plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb
--source include/have_rocksdb.inc
--echo #
--echo # RocksDB plugin adds #rocksdb to ignore_db_dirs
--echo #
select @@ignore_db_dirs;
--let $_mysqld_option=--ignore-db-dirs=aa --ignore-db-dirs=bbb
--source include/restart_mysqld_with_option.inc
select @@ignore_db_dirs;
--let $_mysqld_option=--ignore-db-dirs=#rocksdb
--source include/restart_mysqld_with_option.inc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment