Skip to content

Commit 551dd2b

Browse files
grooverdanThirunarayanan
authored andcommitted
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 376fbd5 commit 551dd2b

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
@@ -1871,12 +1871,6 @@ static void close_connections(void)
18711871
}
18721872
/* End of kill phase 2 */
18731873

1874-
/*
1875-
The signal thread can use server resources, e.g. when processing SIGHUP,
1876-
and it must end gracefully before clean_up()
1877-
*/
1878-
wait_for_signal_thread_to_end();
1879-
18801874
DBUG_PRINT("quit",("close_connections thread"));
18811875
DBUG_VOID_RETURN;
18821876
}
@@ -2109,7 +2103,6 @@ static void clean_up(bool print_message)
21092103

21102104

21112105
#ifndef EMBEDDED_LIBRARY
2112-
21132106
/**
21142107
This is mainly needed when running with purify, but it's still nice to
21152108
know that all child threads have died when mysqld exits.
@@ -6352,10 +6345,7 @@ int mysqld_main(int argc, char **argv)
63526345
if (!abort_loop)
63536346
unireg_abort(bootstrap_error);
63546347
else
6355-
{
6356-
sleep(2); // Wait for kill
6357-
exit(0);
6358-
}
6348+
goto termination;
63596349
}
63606350

63616351
/* Copy default global rpl_filter to global_rpl_filter */
@@ -6430,11 +6420,11 @@ int mysqld_main(int argc, char **argv)
64306420
run_main_loop();
64316421

64326422
/* Shutdown requested */
6433-
char *user= shutdown_user.load(std::memory_order_relaxed);
6434-
sql_print_information(ER_DEFAULT(ER_NORMAL_SHUTDOWN), my_progname,
6435-
user ? user : "unknown");
6436-
if (user)
6437-
my_free(user);
6423+
{
6424+
char *user= shutdown_user.load(std::memory_order_relaxed);
6425+
sql_print_information(ER_DEFAULT(ER_NORMAL_SHUTDOWN), my_progname,
6426+
user ? user : "unknown");
6427+
}
64386428

64396429
#ifdef WITH_WSREP
64406430
wsrep_shutdown();
@@ -6443,6 +6433,15 @@ int mysqld_main(int argc, char **argv)
64436433
#endif
64446434

64456435
close_connections();
6436+
6437+
termination:
6438+
my_free(shutdown_user.load(std::memory_order_relaxed));
6439+
/*
6440+
The signal thread can use server resources, e.g. when processing SIGHUP,
6441+
and it must end gracefully before clean_up()
6442+
*/
6443+
wait_for_signal_thread_to_end();
6444+
64466445
ha_pre_shutdown();
64476446
clean_up(1);
64486447
sd_notify(0, "STATUS=MariaDB server is down");

0 commit comments

Comments
 (0)