mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-8491 - On shutdown, report the user and the host executed that.
This commit is contained in:
parent
5c5034f9d4
commit
ea578c9d6f
6 changed files with 70 additions and 28 deletions
|
@ -5,3 +5,7 @@ create procedure try_shutdown() shutdown;
|
|||
drop procedure try_shutdown;
|
||||
shutdown;
|
||||
drop user user1@localhost;
|
||||
#
|
||||
# MDEV-8491 - On shutdown, report the user and the host executed that.
|
||||
#
|
||||
FOUND /mysqld \(root\[root\] @ localhost \[\]\): Normal shutdown/ in mysqld.1.err
|
||||
|
|
|
@ -30,3 +30,10 @@ drop procedure try_shutdown;
|
|||
|
||||
drop user user1@localhost;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-8491 - On shutdown, report the user and the host executed that.
|
||||
--echo #
|
||||
--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err
|
||||
--let SEARCH_RANGE= -50000
|
||||
--let SEARCH_PATTERN=mysqld \(root\[root\] @ localhost \[\]\): Normal shutdown
|
||||
--source include/search_pattern_in_file.inc
|
||||
|
|
|
@ -1806,10 +1806,35 @@ static void close_server_sock()
|
|||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
||||
void kill_mysql(void)
|
||||
/**
|
||||
Set shutdown user
|
||||
|
||||
@note this function may be called by multiple threads concurrently, thus
|
||||
it performs safe update of shutdown_user (first thread wins).
|
||||
*/
|
||||
|
||||
static volatile char *shutdown_user;
|
||||
static void set_shutdown_user(THD *thd)
|
||||
{
|
||||
char user_host_buff[MAX_USER_HOST_SIZE + 1];
|
||||
char *user, *expected_shutdown_user= 0;
|
||||
|
||||
make_user_name(thd, user_host_buff);
|
||||
|
||||
if ((user= my_strdup(user_host_buff, MYF(0))) &&
|
||||
!my_atomic_casptr((void **) &shutdown_user,
|
||||
(void **) &expected_shutdown_user, user))
|
||||
my_free(user);
|
||||
}
|
||||
|
||||
|
||||
void kill_mysql(THD *thd)
|
||||
{
|
||||
DBUG_ENTER("kill_mysql");
|
||||
|
||||
if (thd)
|
||||
set_shutdown_user(thd);
|
||||
|
||||
#if defined(SIGNALS_DONT_BREAK_READ) && !defined(EMBEDDED_LIBRARY)
|
||||
abort_loop=1; // Break connection loops
|
||||
close_server_sock(); // Force accept to wake up
|
||||
|
@ -1888,7 +1913,13 @@ static void __cdecl kill_server(int sig_ptr)
|
|||
if (sig != 0) // 0 is not a valid signal number
|
||||
my_sigset(sig, SIG_IGN); /* purify inspected */
|
||||
if (sig == MYSQL_KILL_SIGNAL || sig == 0)
|
||||
sql_print_information(ER_DEFAULT(ER_NORMAL_SHUTDOWN),my_progname);
|
||||
{
|
||||
char *user= (char *) my_atomic_loadptr((void**) &shutdown_user);
|
||||
sql_print_information(ER_DEFAULT(ER_NORMAL_SHUTDOWN), my_progname,
|
||||
user ? user : "unknown");
|
||||
if (user)
|
||||
my_free(user);
|
||||
}
|
||||
else
|
||||
sql_print_error(ER_DEFAULT(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ enum enum_slave_parallel_mode {
|
|||
};
|
||||
|
||||
/* Function prototypes */
|
||||
void kill_mysql(void);
|
||||
void kill_mysql(THD *thd= 0);
|
||||
void close_connection(THD *thd, uint sql_errno= 0);
|
||||
void handle_connection_in_main_thread(THD *thd);
|
||||
void create_thread_to_handle_connection(THD *thd);
|
||||
|
|
|
@ -1735,29 +1735,29 @@ ER_WRONG_AUTO_KEY 42000 S1009
|
|||
ER_UNUSED_9
|
||||
eng "You should never see it"
|
||||
ER_NORMAL_SHUTDOWN
|
||||
cze "%s: normální ukončení\n"
|
||||
dan "%s: Normal nedlukning\n"
|
||||
nla "%s: Normaal afgesloten \n"
|
||||
eng "%s: Normal shutdown\n"
|
||||
est "%s: MariaDB lõpetas\n"
|
||||
fre "%s: Arrêt normal du serveur\n"
|
||||
ger "%s: Normal heruntergefahren\n"
|
||||
greek "%s: Φυσιολογική διαδικασία shutdown\n"
|
||||
hun "%s: Normal leallitas\n"
|
||||
ita "%s: Shutdown normale\n"
|
||||
jpn "%s: 通常シャットダウン\n"
|
||||
kor "%s: 정상적인 shutdown\n"
|
||||
nor "%s: Normal avslutning\n"
|
||||
norwegian-ny "%s: Normal nedkopling\n"
|
||||
pol "%s: Standardowe zakończenie działania\n"
|
||||
por "%s: 'Shutdown' normal\n"
|
||||
rum "%s: Terminare normala\n"
|
||||
rus "%s: Корректная остановка\n"
|
||||
serbian "%s: Normalno gašenje\n"
|
||||
slo "%s: normálne ukončenie\n"
|
||||
spa "%s: Apagado normal\n"
|
||||
swe "%s: Normal avslutning\n"
|
||||
ukr "%s: Нормальне завершення\n"
|
||||
cze "%s (%s): normální ukončení\n"
|
||||
dan "%s (%s): Normal nedlukning\n"
|
||||
nla "%s (%s): Normaal afgesloten \n"
|
||||
eng "%s (%s): Normal shutdown\n"
|
||||
est "%s (%s): MariaDB lõpetas\n"
|
||||
fre "%s (%s): Arrêt normal du serveur\n"
|
||||
ger "%s (%s): Normal heruntergefahren\n"
|
||||
greek "%s (%s): Φυσιολογική διαδικασία shutdown\n"
|
||||
hun "%s (%s): Normal leallitas\n"
|
||||
ita "%s (%s): Shutdown normale\n"
|
||||
jpn "%s (%s): 通常シャットダウン\n"
|
||||
kor "%s (%s): 정상적인 shutdown\n"
|
||||
nor "%s (%s): Normal avslutning\n"
|
||||
norwegian-ny "%s (%s): Normal nedkopling\n"
|
||||
pol "%s (%s): Standardowe zakończenie działania\n"
|
||||
por "%s (%s): 'Shutdown' normal\n"
|
||||
rum "%s (%s): Terminare normala\n"
|
||||
rus "%s (%s): Корректная остановка\n"
|
||||
serbian "%s (%s): Normalno gašenje\n"
|
||||
slo "%s (%s): normálne ukončenie\n"
|
||||
spa "%s (%s): Apagado normal\n"
|
||||
swe "%s (%s): Normal avslutning\n"
|
||||
ukr "%s (%s): Нормальне завершення\n"
|
||||
ER_GOT_SIGNAL
|
||||
cze "%s: přijat signal %d, končím\n"
|
||||
dan "%s: Fangede signal %d. Afslutter!!\n"
|
||||
|
|
|
@ -1804,7 +1804,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
|||
DBUG_PRINT("quit",("Got shutdown command for level %u", level));
|
||||
general_log_print(thd, command, NullS);
|
||||
my_eof(thd);
|
||||
kill_mysql();
|
||||
kill_mysql(thd);
|
||||
error=TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -4907,7 +4907,7 @@ end_with_restore_list:
|
|||
#ifndef EMBEDDED_LIBRARY
|
||||
if (check_global_access(thd,SHUTDOWN_ACL))
|
||||
goto error;
|
||||
kill_mysql();
|
||||
kill_mysql(thd);
|
||||
my_ok(thd);
|
||||
#else
|
||||
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "embedded server");
|
||||
|
|
Loading…
Reference in a new issue