mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Have mysqltest first send SIGABRT, then SIGKILL
This is to get core's in mysql-test-run if server doesn't die in shutdown
This commit is contained in:
@ -5102,7 +5102,9 @@ int query_get_string(MYSQL* mysql, const char* query,
|
|||||||
|
|
||||||
static int my_kill(int pid, int sig)
|
static int my_kill(int pid, int sig)
|
||||||
{
|
{
|
||||||
|
DBUG_PRINT("info", ("Killing server, pid: %d", pid));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#define SIGKILL 9 /* ignored anyway, see below */
|
||||||
HANDLE proc;
|
HANDLE proc;
|
||||||
if ((proc= OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid)) == NULL)
|
if ((proc= OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -5137,6 +5139,26 @@ static int my_kill(int pid, int sig)
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static int wait_until_dead(int pid, int timeout)
|
||||||
|
{
|
||||||
|
DBUG_ENTER("wait_until_dead");
|
||||||
|
/* Check that server dies */
|
||||||
|
while (timeout--)
|
||||||
|
{
|
||||||
|
if (my_kill(pid, 0) < 0)
|
||||||
|
{
|
||||||
|
DBUG_PRINT("info", ("Process %d does not exist anymore", pid));
|
||||||
|
DBUG_RETURN(0);
|
||||||
|
}
|
||||||
|
DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout));
|
||||||
|
/* Sleep one second */
|
||||||
|
my_sleep(1000000L);
|
||||||
|
}
|
||||||
|
DBUG_RETURN(1); // Did not die
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void do_shutdown_server(struct st_command *command)
|
void do_shutdown_server(struct st_command *command)
|
||||||
{
|
{
|
||||||
long timeout= opt_wait_for_pos_timeout ? opt_wait_for_pos_timeout / 5 : 300;
|
long timeout= opt_wait_for_pos_timeout ? opt_wait_for_pos_timeout / 5 : 300;
|
||||||
@ -5188,24 +5210,31 @@ void do_shutdown_server(struct st_command *command)
|
|||||||
}
|
}
|
||||||
DBUG_PRINT("info", ("Got pid %d", pid));
|
DBUG_PRINT("info", ("Got pid %d", pid));
|
||||||
|
|
||||||
/* Tell server to shutdown if timeout > 0*/
|
/*
|
||||||
|
If timeout == 0, it means we should kill the server hard, without
|
||||||
|
any shutdown or core (SIGKILL)
|
||||||
|
|
||||||
|
If timeout is given, then we do things in the following order:
|
||||||
|
- mysql_shutdown()
|
||||||
|
- If server is not dead within timeout
|
||||||
|
- kill SIGABRT (to get a core)
|
||||||
|
- If server is not dead within new timeout
|
||||||
|
- kill SIGKILL
|
||||||
|
*/
|
||||||
|
|
||||||
if (timeout && mysql_shutdown(mysql, SHUTDOWN_DEFAULT))
|
if (timeout && mysql_shutdown(mysql, SHUTDOWN_DEFAULT))
|
||||||
die("mysql_shutdown failed");
|
die("mysql_shutdown failed");
|
||||||
|
|
||||||
/* Check that server dies */
|
if (!timeout || wait_until_dead(pid, timeout))
|
||||||
while(timeout--){
|
{
|
||||||
if (my_kill(pid, 0) < 0){
|
if (timeout)
|
||||||
DBUG_PRINT("info", ("Process %d does not exist anymore", pid));
|
(void) my_kill(pid, SIGABRT);
|
||||||
DBUG_VOID_RETURN;
|
/* Give server a few seconds to die in all cases */
|
||||||
|
if (!timeout || wait_until_dead(pid, timeout < 5 ? 5 : timeout))
|
||||||
|
{
|
||||||
|
(void) my_kill(pid, SIGKILL);
|
||||||
}
|
}
|
||||||
DBUG_PRINT("info", ("Sleeping, timeout: %ld", timeout));
|
|
||||||
my_sleep(1000000L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Kill the server */
|
|
||||||
DBUG_PRINT("info", ("Killing server, pid: %d", pid));
|
|
||||||
(void)my_kill(pid, 9);
|
|
||||||
|
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ INSERT INTO bug56680_2 VALUES(1,_latin1 0xdf,1);
|
|||||||
SELECT HEX(b) FROM bug56680_2 LIMIT 3;
|
SELECT HEX(b) FROM bug56680_2 LIMIT 3;
|
||||||
CHECK TABLE bug56680_2;
|
CHECK TABLE bug56680_2;
|
||||||
|
|
||||||
--let $shutdown_timeout=1
|
--let $shutdown_timeout=0
|
||||||
--source include/restart_mysqld.inc
|
--source include/restart_mysqld.inc
|
||||||
|
|
||||||
CHECK TABLE bug56680_2;
|
CHECK TABLE bug56680_2;
|
||||||
|
Reference in New Issue
Block a user