Commit 0f7e6479 authored by Bjorn Munch's avatar Bjorn Munch

Bug #41649 sporadic pb failure: mtr stopped, message "TIMEOUT (1200 seconds), ABORTING."

Potentially infinite loop in check_expected_crash_and_restart 
Replace with finite loop and some additional logic
parent 6494ae03
...@@ -537,6 +537,24 @@ sub wait_any { ...@@ -537,6 +537,24 @@ sub wait_any {
} }
# #
# Check if any process has exited, but don't wait.
#
# Returns a reference to the SafeProcess that
# exited or undefined
#
sub check_any {
for my $proc (values %running){
if ( $proc->is_child($$) ) {
if (not $proc->wait_one(0)) {
_verbose ("Found exited $proc");
return $proc;
}
}
}
return undef;
}
# Overload string operator # Overload string operator
# and fallback to default functions if no # and fallback to default functions if no
# overloaded function is found # overloaded function is found
......
...@@ -3286,10 +3286,38 @@ sub run_testcase ($) { ...@@ -3286,10 +3286,38 @@ sub run_testcase ($) {
} }
my $test= start_mysqltest($tinfo); my $test= start_mysqltest($tinfo);
# Set only when we have to keep waiting after expectedly died server
my $keep_waiting_proc = 0;
while (1) while (1)
{ {
my $proc= My::SafeProcess->wait_any(); my $proc;
if ($keep_waiting_proc)
{
# Any other process exited?
$proc = My::SafeProcess->check_any();
if ($proc)
{
mtr_verbose ("Found exited process $proc");
# If that was the timeout, cancel waiting
if ( $proc eq $test_timeout_proc )
{
$keep_waiting_proc = 0;
}
}
else
{
$proc = $keep_waiting_proc;
}
}
else
{
$proc= My::SafeProcess->wait_any();
}
# Will be restored if we need to keep waiting
$keep_waiting_proc = 0;
unless ( defined $proc ) unless ( defined $proc )
{ {
mtr_error("wait_any failed"); mtr_error("wait_any failed");
...@@ -3385,8 +3413,12 @@ sub run_testcase ($) { ...@@ -3385,8 +3413,12 @@ sub run_testcase ($) {
# ---------------------------------------------------- # ----------------------------------------------------
# Check if it was an expected crash # Check if it was an expected crash
# ---------------------------------------------------- # ----------------------------------------------------
if ( check_expected_crash_and_restart($proc) ) my $check_crash = check_expected_crash_and_restart($proc);
if ($check_crash)
{ {
# Keep waiting if it returned 2, if 1 don't wait or stop waiting.
$keep_waiting_proc = 0 if $check_crash == 1;
$keep_waiting_proc = $proc if $check_crash == 2;
next; next;
} }
...@@ -3727,16 +3759,16 @@ sub check_expected_crash_and_restart { ...@@ -3727,16 +3759,16 @@ sub check_expected_crash_and_restart {
{ {
mtr_verbose("Crash was expected, file '$expect_file' exists"); mtr_verbose("Crash was expected, file '$expect_file' exists");
while (1){ for (my $waits = 0; $waits < 50; $waits++)
{
# If last line in expect file starts with "wait" # If last line in expect file starts with "wait"
# sleep a little and try again, thus allowing the # sleep a little and try again, thus allowing the
# test script to control when the server should start # test script to control when the server should start
# up again # up again. Keep trying for up to 5s at a time.
my $last_line= mtr_lastlinesfromfile($expect_file, 1); my $last_line= mtr_lastlinesfromfile($expect_file, 1);
if ($last_line =~ /^wait/ ) if ($last_line =~ /^wait/ )
{ {
mtr_verbose("Test says wait before restart"); mtr_verbose("Test says wait before restart") if $waits == 0;
mtr_milli_sleep(100); mtr_milli_sleep(100);
next; next;
} }
...@@ -3746,11 +3778,11 @@ sub check_expected_crash_and_restart { ...@@ -3746,11 +3778,11 @@ sub check_expected_crash_and_restart {
# Start server with same settings as last time # Start server with same settings as last time
mysqld_start($mysqld, $mysqld->{'started_opts'}); mysqld_start($mysqld, $mysqld->{'started_opts'});
last; return 1;
} }
# Loop ran through: we should keep waiting after a re-check
return 2;
} }
return 1;
} }
# Not an expected crash # Not an expected crash
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment