Skip to content

Commit 9b70ec0

Browse files
BUG# 20798617 - MYSQL CALLS EXIT(MYSQLD_ABORT_EXIT) WITHOUT
SHUTTING DOWN INNODB. The test innodb.log_file can occasionally crash due to an error in the startup error handling. In test step 12 of the innodb. log_file cause mysqld startup to abort by calling exit.Thus InnoDB is not shutdown properly with some InnoDB threads being active causing sporadic test case failure. The fix is to exit via unireg_abort which does InnoDB to gracefully shutdown. Also move the start of signal handler thread before bootstrap in the initialization sequence. Terminate signal handler thread when SIGTERM and SIGQUIT irrespective of whether abort_loop is set or unset.
1 parent b569324 commit 9b70ec0

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

sql/mysqld.cc

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,7 +2199,7 @@ static void start_signal_handler()
21992199
}
22002200

22012201

2202-
/** This threads handles all signals and alarms. */
2202+
/** This thread handles SIGTERM, SIGQUIT and SIGHUP signals. */
22032203
/* ARGSUSED */
22042204
extern "C" void *signal_hand(void *arg __attribute__((unused)))
22052205
{
@@ -2276,10 +2276,10 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
22762276
mysql_mutex_unlock(&LOCK_socket_listener_active);
22772277

22782278
close_connections();
2279-
my_thread_end();
2280-
my_thread_exit(0);
2281-
return NULL; // Avoid compiler warnings
22822279
}
2280+
my_thread_end();
2281+
my_thread_exit(0);
2282+
return NULL; // Avoid compiler warnings
22832283
break;
22842284
case SIGHUP:
22852285
if (!abort_loop)
@@ -4878,16 +4878,8 @@ int mysqld_main(int argc, char **argv)
48784878
my_str_free= &my_str_free_mysqld;
48794879
my_str_realloc= &my_str_realloc_mysqld;
48804880

4881-
/*
4882-
init signals & alarm
4883-
After this we can't quit by a simple unireg_abort
4884-
*/
48854881
error_handler_hook= my_message_sql;
48864882

4887-
#ifndef _WIN32
4888-
start_signal_handler();
4889-
#endif
4890-
48914883
/* Save pid of this process in a file */
48924884
if (!opt_bootstrap)
48934885
create_pid_file();
@@ -4902,18 +4894,15 @@ int mysqld_main(int argc, char **argv)
49024894
{
49034895
abort_loop= true;
49044896

4905-
#ifndef _WIN32
4906-
(void) pthread_kill(signal_thread_id.thread, SIGTERM);
4907-
#endif
4908-
49094897
delete_pid_file(MYF(MY_WME));
49104898

49114899
if (mysqld_socket_acceptor != NULL)
49124900
{
49134901
delete mysqld_socket_acceptor;
49144902
mysqld_socket_acceptor= NULL;
49154903
}
4916-
exit(MYSQLD_ABORT_EXIT);
4904+
4905+
unireg_abort(MYSQLD_ABORT_EXIT);
49174906
}
49184907

49194908
if (!opt_noacl)
@@ -4972,6 +4961,11 @@ int mysqld_main(int argc, char **argv)
49724961
if (Events::init(opt_noacl || opt_bootstrap))
49734962
unireg_abort(MYSQLD_ABORT_EXIT);
49744963

4964+
#ifndef _WIN32
4965+
// Start signal handler thread.
4966+
start_signal_handler();
4967+
#endif
4968+
49754969
if (opt_bootstrap)
49764970
{
49774971
start_processing_signals();

0 commit comments

Comments
 (0)