Commit 621fae3c authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-25802 mtr: race condition if the test quickly restarts twice

part II

need to tell SafeProcess not to collect the exited mysqld
in sleep_until_file_created(), so that it would be found in the
later wait_any_timeout() in run_testcase()

Removed a strange condition in SafeProcess::wait_one()
that treated return value of -1 from waitpid() as "process exists"
instead of as "no such child process" (see `perldoc -f waitpid`)
parent 1223cfe1
...@@ -395,10 +395,10 @@ sub _collect { ...@@ -395,10 +395,10 @@ sub _collect {
# 1 Still running # 1 Still running
# #
sub wait_one { sub wait_one {
my ($self, $timeout)= @_; my ($self, $timeout, $keep)= @_;
croak "usage: \$safe_proc->wait_one([timeout])" unless ref $self; croak "usage: \$safe_proc->wait_one([timeout] [, keep])" unless ref $self;
_verbose("wait_one $self, $timeout"); _verbose("wait_one $self, $timeout, $keep");
if ( ! defined($self->{SAFE_PID}) ) { if ( ! defined($self->{SAFE_PID}) ) {
# No pid => not running # No pid => not running
...@@ -472,16 +472,16 @@ sub wait_one { ...@@ -472,16 +472,16 @@ sub wait_one {
return 1; return 1;
} }
if ( not $blocking and $retpid == -1 ) { #if ( not $blocking and $retpid == -1 ) {
# still running # # still running
_verbose("still running"); # _verbose("still running");
return 1; # return 1;
} #}
#warn "wait_one: expected pid $pid but got $retpid" #warn "wait_one: expected pid $pid but got $retpid"
# unless( $retpid == $pid ); # unless( $retpid == $pid );
$self->_collect($exit_code); $self->_collect($exit_code) unless $keep;
return 0; return 0;
} }
......
...@@ -121,7 +121,7 @@ sub sleep_until_file_created ($$$$$) { ...@@ -121,7 +121,7 @@ sub sleep_until_file_created ($$$$$) {
my $seconds= ($loop * $sleeptime) / 1000; my $seconds= ($loop * $sleeptime) / 1000;
# Check if it died after the fork() was successful # Check if it died after the fork() was successful
if ( defined $proc and ! $proc->wait_one(0) ) if ( defined $proc and ! $proc->wait_one(0, 1) )
{ {
return 1 if -r $expectfile; return 1 if -r $expectfile;
mtr_warning("Process $proc died after mysql-test-run waited $seconds " . mtr_warning("Process $proc died after mysql-test-run waited $seconds " .
......
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