Skip to content

Commit 49b2502

Browse files
committed
Fix assertion/hang in read_init_file()
If there are other threads running (for example binlog background thread), then the thread count may not drop to zero at the end of do_handle_bootstrap(). This caused an assertion and missing wakeup of the main thread. The missing wakeup is because THD::~THD() only signals the COND_thread_count mutex when the number of threads drops to zero. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent be2b833 commit 49b2502

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sql/sql_parse.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,20 @@ void do_handle_bootstrap(THD *thd)
10821082
end:
10831083
in_bootstrap= FALSE;
10841084
delete thd;
1085+
if (!opt_bootstrap)
1086+
{
1087+
/*
1088+
We need to wake up main thread in case of read_init_file().
1089+
This is not done by THD::~THD() when there are other threads running
1090+
(binlog background thread, for example). So do it here again.
1091+
*/
1092+
mysql_mutex_lock(&LOCK_thread_count);
1093+
mysql_cond_broadcast(&COND_thread_count);
1094+
mysql_mutex_unlock(&LOCK_thread_count);
1095+
}
10851096

10861097
#ifndef EMBEDDED_LIBRARY
1087-
DBUG_ASSERT(thread_count == 0);
1098+
DBUG_ASSERT(!opt_bootstrap || thread_count == 0);
10881099
my_thread_end();
10891100
pthread_exit(0);
10901101
#endif

0 commit comments

Comments
 (0)