Skip to content
Permalink
Browse files
MDEV-12445 : Rocksdb does not shutdown worker threads and aborts in m…
…emleak 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.
  • Loading branch information
vaintroub committed Jul 6, 2017
1 parent 53d6325 commit 6f1f911
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
@@ -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);
}
@@ -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);
}

@@ -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

0 comments on commit 6f1f911

Please sign in to comment.