Commit 9f4d4f40 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-12747 - main.mysqld_option_err fails in buildbot with timeout

thd_destructor_proxy() may miss abort signal if innobase_end() is running
concurrently, which causes server hang in pthread_join() on shutdown.

The problem was that aborting wasn't protected by mutex:
proxy thr: while (!myvar->abort)
end thr: running->abort = 1;
end thr: mysql_cond_broadcast(...);
proxy thr: mysql_cond_wait(...); // nobody to awake it
end thr: pthread_join(...); // waits for proxy thr

Also made main.mysqld_option_err reentrant.
parent 37ffdb44
......@@ -56,4 +56,6 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
--error 2
--exec $MYSQLD_BOOTSTRAP_CMD --not-known-option --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
rmdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
--echo Done.
......@@ -4474,17 +4474,19 @@ innobase_end(handlerton*, ha_panic_function)
}
}
st_my_thread_var* running = reinterpret_cast<st_my_thread_var*>(
st_my_thread_var* r = reinterpret_cast<st_my_thread_var*>(
my_atomic_loadptr_explicit(
reinterpret_cast<void**>(&srv_running),
MY_MEMORY_ORDER_RELAXED));
if (!abort_loop && running) {
// may be UNINSTALL PLUGIN statement
running->abort = 1;
mysql_cond_broadcast(running->current_cond);
}
if (!srv_read_only_mode) {
if (r) {
ut_ad(!srv_read_only_mode);
if (!abort_loop) {
// may be UNINSTALL PLUGIN statement
mysql_mutex_lock(r->current_mutex);
r->abort = 1;
mysql_cond_broadcast(r->current_cond);
mysql_mutex_unlock(r->current_mutex);
}
pthread_join(thd_destructor_thread, NULL);
}
......
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