Skip to content

Commit

Permalink
MDEV-34814 mysqld hangs on startup when --init-file target does not e…
Browse files Browse the repository at this point in the history
…xist

Set select_thread_in_use only when we're about to enter into the polling
loop, not sooner, allowing early proces aborts to exist cleanly: the
process won't be waiting for a polling loop that isn't yet polling.
  • Loading branch information
DaveGosselin-MariaDB committed Oct 9, 2024
1 parent b138f42 commit 5fade75
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5344,6 +5344,26 @@ static void test_lc_time_sz()
#endif//DBUG_OFF


static void signal_accept_connections()
{
select_thread=pthread_self();
mysql_mutex_lock(&LOCK_start_thread);
select_thread_in_use=1;
mysql_mutex_unlock(&LOCK_start_thread);

#ifdef _WIN32
handle_connections_win();
#else
handle_connections_sockets();

mysql_mutex_lock(&LOCK_start_thread);
select_thread_in_use=0;
mysql_cond_broadcast(&COND_start_thread);
mysql_mutex_unlock(&LOCK_start_thread);
#endif /* _WIN32 */
}


#ifdef __WIN__
int win_main(int argc, char **argv)
#else
Expand Down Expand Up @@ -5540,9 +5560,6 @@ int mysqld_main(int argc, char **argv)
SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size);
}

select_thread=pthread_self();
select_thread_in_use=1;

#ifdef HAVE_LIBWRAP
libwrapName= my_progname+dirname_length(my_progname);
openlog(libwrapName, LOG_PID, LOG_AUTH);
Expand Down Expand Up @@ -5596,7 +5613,6 @@ int mysqld_main(int argc, char **argv)
// Recover and exit.
if (wsrep_recovery)
{
select_thread_in_use= 0;
if (WSREP_ON)
wsrep_recover();
else
Expand Down Expand Up @@ -5671,7 +5687,6 @@ int mysqld_main(int argc, char **argv)

if (opt_bootstrap)
{
select_thread_in_use= 0; // Allow 'kill' to work
int bootstrap_error= bootstrap(mysql_stdin);
if (!abort_loop)
unireg_abort(bootstrap_error);
Expand Down Expand Up @@ -5751,16 +5766,7 @@ int mysqld_main(int argc, char **argv)
/* Memory used when everything is setup */
start_memory_used= global_status_var.global_memory_used;

#ifdef _WIN32
handle_connections_win();
#else
handle_connections_sockets();

mysql_mutex_lock(&LOCK_start_thread);
select_thread_in_use=0;
mysql_cond_broadcast(&COND_start_thread);
mysql_mutex_unlock(&LOCK_start_thread);
#endif /* _WIN32 */
signal_accept_connections();

/* Shutdown requested */
char *user= shutdown_user.load(std::memory_order_relaxed);
Expand Down

0 comments on commit 5fade75

Please sign in to comment.