Skip to content

Commit 8c11f86

Browse files
committed
MDEV-39585 mariadb bootstrap fails to perform plugin deinitalization
mariadbd under --bootstrap failed to preform plugin deinitialization. The sleep(2);exit is removed and replaced to a goto termination label to perform the same shutdown procedure of the server after all the connection closing. To prevent a compile error about char *user being uninitialized this sql_print_information(ER_DEFAULT(ER_NORMAL_SHUTDOWN)) is moved to its own block. The memory free did need to occur in the bootstrap mode too to avoid memory leak errors. wait_for_signal_thread_to_end(), was previously in close_connections() however its required too for --bootstrap.
1 parent 787c5cf commit 8c11f86

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

sql/mysqld.cc

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,12 +1842,6 @@ static void close_connections(void)
18421842
}
18431843
/* End of kill phase 2 */
18441844

1845-
/*
1846-
The signal thread can use server resources, e.g. when processing SIGHUP,
1847-
and it must end gracefully before clean_up()
1848-
*/
1849-
wait_for_signal_thread_to_end();
1850-
18511845
DBUG_PRINT("quit",("close_connections thread"));
18521846
DBUG_VOID_RETURN;
18531847
}
@@ -2079,7 +2073,6 @@ static void clean_up(bool print_message)
20792073

20802074

20812075
#ifndef EMBEDDED_LIBRARY
2082-
20832076
/**
20842077
This is mainly needed when running with purify, but it's still nice to
20852078
know that all child threads have died when mysqld exits.
@@ -6041,10 +6034,7 @@ int mysqld_main(int argc, char **argv)
60416034
if (!abort_loop)
60426035
unireg_abort(bootstrap_error);
60436036
else
6044-
{
6045-
sleep(2); // Wait for kill
6046-
exit(0);
6047-
}
6037+
goto termination;
60486038
}
60496039

60506040
/* Copy default global rpl_filter to global_rpl_filter */
@@ -6119,11 +6109,11 @@ int mysqld_main(int argc, char **argv)
61196109
run_main_loop();
61206110

61216111
/* Shutdown requested */
6122-
char *user= shutdown_user.load(std::memory_order_relaxed);
6123-
sql_print_information(ER_DEFAULT(ER_NORMAL_SHUTDOWN), my_progname,
6124-
user ? user : "unknown");
6125-
if (user)
6126-
my_free(user);
6112+
{
6113+
char *user= shutdown_user.load(std::memory_order_relaxed);
6114+
sql_print_information(ER_DEFAULT(ER_NORMAL_SHUTDOWN), my_progname,
6115+
user ? user : "unknown");
6116+
}
61276117

61286118
#ifdef WITH_WSREP
61296119
wsrep_shutdown();
@@ -6132,6 +6122,15 @@ int mysqld_main(int argc, char **argv)
61326122
#endif
61336123

61346124
close_connections();
6125+
6126+
termination:
6127+
my_free(shutdown_user.load(std::memory_order_relaxed));
6128+
/*
6129+
The signal thread can use server resources, e.g. when processing SIGHUP,
6130+
and it must end gracefully before clean_up()
6131+
*/
6132+
wait_for_signal_thread_to_end();
6133+
61356134
ha_pre_shutdown();
61366135
clean_up(1);
61376136
sd_notify(0, "STATUS=MariaDB server is down");

0 commit comments

Comments
 (0)