MDEV-12445 : Rocksdb does not shutdown worker threads and aborts in memleak check on server shutdown

Disable memory leak check in debug server, if rocksdb is loaded.
There is some subtle bug somewhere in 3rd party code we cannot
do much about.

The bug is manifested as follows

Rocksdb does not shutdown worker threads, when plugin is shut down. Thus
OS does not unload the library since there are some active threads using
this library's code. Thus global destructors in the library do not run,
and there is still some memory allocated when server exits.

The workaround disables server's memory leak check, if rocksdb engine was
loaded.
This commit is contained in:
Vladislav Vaintroub 2017-07-05 19:37:57 +00:00
commit 6f1f911497
3 changed files with 12 additions and 2 deletions

View file

@ -365,6 +365,7 @@ static bool volatile select_thread_in_use, signal_thread_in_use;
static volatile bool ready_to_exit;
static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
static my_bool opt_short_log_format= 0, opt_silent_startup= 0;
bool my_disable_leak_check= false;
uint kill_cached_threads;
static uint wake_thread;
@ -2155,7 +2156,7 @@ static void mysqld_exit(int exit_code)
shutdown_performance_schema(); // we do it as late as possible
#endif
set_malloc_size_cb(NULL);
if (!opt_debugging)
if (!opt_debugging && !my_disable_leak_check)
{
DBUG_ASSERT(global_status_var.global_memory_used == 0);
}

View file

@ -97,6 +97,8 @@ int thd_binlog_format(const MYSQL_THD thd);
bool thd_binlog_filter_ok(const MYSQL_THD thd);
}
MYSQL_PLUGIN_IMPORT bool my_disable_leak_check;
namespace myrocks {
static st_global_stats global_stats;
@ -3593,6 +3595,14 @@ static int rocksdb_init_func(void *const p) {
#endif
sql_print_information("RocksDB instance opened");
/**
Rocksdb does not always shutdown its threads, when
plugin is shut down. Disable server's leak check
at exit to avoid crash.
*/
my_disable_leak_check = true;
DBUG_RETURN(HA_EXIT_SUCCESS);
}

View file

@ -60,7 +60,6 @@ rocksdb_deadlock_stress_rr: stress test
# MDEV-12474 Regularly failing tests on Buildbot
autoinc_vars_thread : MDEV-12474 Regularly fails on buildbot
validate_datadic : MDEV-12474 Regularly fails on buildbot
unique_check : MDEV-12474 Regularly fails on buildbot
bloomfilter : MDEV-12474 Regularly fails on buildbot