1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Small fix for test suite:

- fix for IM stopping routine;
  - polishing.
This commit is contained in:
anozdrin@mysql.com
2006-06-19 14:15:26 +04:00
parent 2e56e82180
commit a142a4d97b
2 changed files with 61 additions and 10 deletions

View File

@ -890,19 +890,28 @@ sub mtr_kill_processes ($) {
sub mtr_kill_process ($$$$) { sub mtr_kill_process ($$$$) {
my $pid= shift; my $pid= shift;
my $signal= shift; my $signal= shift;
my $retries= shift; my $total_retries= shift;
my $timeout= shift; my $timeout= shift;
while (1) for (my $cur_attempt= 1; $cur_attempt <= $total_retries; ++$cur_attempt)
{ {
mtr_debug("Sending $signal to $pid...");
kill($signal, $pid); kill($signal, $pid);
last unless kill (0, $pid) and $retries--; unless (kill (0, $pid))
{
mtr_debug("Process $pid died.");
return;
}
mtr_debug("Sleep $timeout second waiting for processes to die"); mtr_debug("Sleeping $timeout second(s) waiting for processes to die...");
sleep($timeout); sleep($timeout);
} }
mtr_debug("Process $pid is still alive after $total_retries " .
"of sending signal $signal.");
} }
############################################################################## ##############################################################################

View File

@ -2843,22 +2843,58 @@ sub im_stop($) {
# Try graceful shutdown. # Try graceful shutdown.
mtr_debug("IM-main pid: $instance_manager->{'pid'}");
mtr_debug("Stopping IM-main...");
mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1); mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1);
# If necessary, wait for angel process to die.
if (defined $instance_manager->{'angel_pid'})
{
mtr_debug("IM-angel pid: $instance_manager->{'angel_pid'}");
mtr_debug("Waiting for IM-angel to die...");
my $total_attempts= 10;
for (my $cur_attempt=1; $cur_attempt <= $total_attempts; ++$cur_attempt)
{
unless (kill (0, $instance_manager->{'angel_pid'}))
{
mtr_debug("IM-angel died.");
last;
}
sleep(1);
}
}
# Check that all processes died. # Check that all processes died.
my $clean_shutdown= 0; my $clean_shutdown= 0;
while (1) while (1)
{ {
last if kill (0, $instance_manager->{'pid'}); if (kill (0, $instance_manager->{'pid'}))
{
mtr_debug("IM-main is still alive.");
last;
}
last if (defined $instance_manager->{'angel_pid'}) && if (defined $instance_manager->{'angel_pid'} &&
kill (0, $instance_manager->{'angel_pid'}); kill (0, $instance_manager->{'angel_pid'}))
{
mtr_debug("IM-angel is still alive.");
last;
}
foreach my $pid (@mysqld_pids) foreach my $pid (@mysqld_pids)
{ {
last if kill (0, $pid); if (kill (0, $pid))
{
mtr_debug("Guarded mysqld ($pid) is still alive.");
last;
}
} }
$clean_shutdown= 1; $clean_shutdown= 1;
@ -2869,15 +2905,21 @@ sub im_stop($) {
unless ($clean_shutdown) unless ($clean_shutdown)
{ {
mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
if defined $instance_manager->{'angel_pid'}; if (defined $instance_manager->{'angel_pid'})
{
mtr_debug("Killing IM-angel...");
mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
}
mtr_debug("Killing IM-main...");
mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10, 1); mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10, 1);
# Shutdown managed mysqld-processes. Some of them may be nonguarded, so IM # Shutdown managed mysqld-processes. Some of them may be nonguarded, so IM
# will not stop them on shutdown. So, we should firstly try to end them # will not stop them on shutdown. So, we should firstly try to end them
# legally. # legally.
mtr_debug("Killing guarded mysqld(s)...");
mtr_kill_processes(\@mysqld_pids); mtr_kill_processes(\@mysqld_pids);
# Complain in error log so that a warning will be shown. # Complain in error log so that a warning will be shown.