mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
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.
This commit is contained in:
parent
b8a0373ed2
commit
ddc1d6904a
5 changed files with 88 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# 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
|
|
@ -1,2 +1,2 @@
|
|||
--ignore-db-dirs=#rocksdb --plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb
|
||||
--plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
--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
|
||||
|
Loading…
Add table
Reference in a new issue