Skip to content

Commit bcc26dc

Browse files
committed
Revert "Fix mtr to be able to wait for >1 exited mysqld"
This reverts commit 72deed5 which was merged as commit 29d4ac2. The change caused regressions, such as mysql-test-run failing to run at all with --valgrind, or aborting on Windows on the first test failure.
1 parent b4c5e4a commit bcc26dc

File tree

1 file changed

+117
-128
lines changed

1 file changed

+117
-128
lines changed

mysql-test/mysql-test-run.pl

Lines changed: 117 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -3961,32 +3961,32 @@ ($$)
39613961
}
39623962

39633963
my $test= $tinfo->{suite}->start_test($tinfo);
3964-
# Set to a list of processes we have to keep waiting (expectedly died servers)
3965-
my %keep_waiting_proc = ();
3964+
# Set only when we have to keep waiting after expectedly died server
3965+
my $keep_waiting_proc = 0;
39663966
my $print_timeout= start_timer($print_freq * 60);
39673967

39683968
while (1)
39693969
{
39703970
my $proc;
3971-
if (scalar(keys(%keep_waiting_proc)) > 0)
3971+
if ($keep_waiting_proc)
39723972
{
39733973
# Any other process exited?
39743974
$proc = My::SafeProcess->check_any();
39753975
if ($proc)
39763976
{
39773977
mtr_verbose ("Found exited process $proc");
3978-
$keep_waiting_proc{$proc} = 1;
39793978
}
39803979
else
39813980
{
3981+
$proc = $keep_waiting_proc;
39823982
# Also check if timer has expired, if so cancel waiting
39833983
if ( has_expired($test_timeout) )
39843984
{
3985-
%keep_waiting_proc = ();
3985+
$keep_waiting_proc = 0;
39863986
}
39873987
}
39883988
}
3989-
if (scalar(keys(%keep_waiting_proc)) == 0)
3989+
if (! $keep_waiting_proc)
39903990
{
39913991
if($test_timeout > $print_timeout)
39923992
{
@@ -4003,148 +4003,137 @@ ($$)
40034003
else
40044004
{
40054005
$proc= My::SafeProcess->wait_any_timeout($test_timeout);
4006-
$keep_waiting_proc{$proc} = 1;
40074006
}
40084007
}
40094008

4010-
if (scalar(keys(%keep_waiting_proc)) == 0)
4009+
# Will be restored if we need to keep waiting
4010+
$keep_waiting_proc = 0;
4011+
4012+
unless ( defined $proc )
40114013
{
40124014
mtr_error("wait_any failed");
40134015
}
4014-
mtr_verbose("Got " . join(",", keys(%keep_waiting_proc)));
4016+
mtr_verbose("Got $proc");
40154017

40164018
mark_time_used('test');
4017-
my $expected_exit = 1;
4018-
foreach $proc (keys(%keep_waiting_proc)) {
4019-
# ----------------------------------------------------
4020-
# Was it the test program that exited
4021-
# ----------------------------------------------------
4022-
if ($proc eq $test)
4023-
{
4024-
my $res= $test->exit_status();
4019+
# ----------------------------------------------------
4020+
# Was it the test program that exited
4021+
# ----------------------------------------------------
4022+
if ($proc eq $test)
4023+
{
4024+
my $res= $test->exit_status();
40254025

4026-
if (($res == 0 or $res == 62) and $opt_warnings and check_warnings($tinfo) )
4027-
{
4028-
# If test case suceeded, but it has produced unexpected
4029-
# warnings, continue with $res == 1;
4030-
# but if the test was skipped, it should remain skipped
4031-
$res= 1 if $res == 0;
4032-
resfile_output($tinfo->{'warnings'}) if $opt_resfile;
4033-
}
4026+
if (($res == 0 or $res == 62) and $opt_warnings and check_warnings($tinfo) )
4027+
{
4028+
# If test case suceeded, but it has produced unexpected
4029+
# warnings, continue with $res == 1;
4030+
# but if the test was skipped, it should remain skipped
4031+
$res= 1 if $res == 0;
4032+
resfile_output($tinfo->{'warnings'}) if $opt_resfile;
4033+
}
40344034

4035-
if ( $res == 0 )
4036-
{
4037-
my $check_res;
4038-
if ( $opt_check_testcases and
4039-
$check_res= check_testcase($tinfo, "after"))
4040-
{
4041-
if ($check_res == 1) {
4042-
# Test case had sideeffects, not fatal error, just continue
4043-
if ($opt_warnings) {
4044-
# Checking error logs for warnings, so need to stop server
4045-
# gracefully so that memory leaks etc. can be properly detected.
4046-
stop_servers(reverse all_servers());
4047-
check_warnings_post_shutdown($server_socket);
4048-
# Even if we got warnings here, we should not fail this
4049-
# particular test, as the warnings may be caused by an earlier
4050-
# test.
4051-
} else {
4052-
# Not checking warnings, so can do a hard shutdown.
4053-
stop_all_servers($opt_shutdown_timeout);
4054-
}
4055-
mtr_report("Resuming tests...\n");
4056-
resfile_output($tinfo->{'check'}) if $opt_resfile;
4057-
}
4058-
else {
4059-
# Test case check failed fatally, probably a server crashed
4060-
report_failure_and_restart($tinfo);
4061-
return 1;
4035+
if ( $res == 0 )
4036+
{
4037+
my $check_res;
4038+
if ( $opt_check_testcases and
4039+
$check_res= check_testcase($tinfo, "after"))
4040+
{
4041+
if ($check_res == 1) {
4042+
# Test case had sideeffects, not fatal error, just continue
4043+
if ($opt_warnings) {
4044+
# Checking error logs for warnings, so need to stop server
4045+
# gracefully so that memory leaks etc. can be properly detected.
4046+
stop_servers(reverse all_servers());
4047+
check_warnings_post_shutdown($server_socket);
4048+
# Even if we got warnings here, we should not fail this
4049+
# particular test, as the warnings may be caused by an earlier
4050+
# test.
4051+
} else {
4052+
# Not checking warnings, so can do a hard shutdown.
4053+
stop_all_servers($opt_shutdown_timeout);
40624054
}
4063-
}
4064-
mtr_report_test_passed($tinfo);
4065-
}
4066-
elsif ( $res == 62 )
4067-
{
4068-
# Testcase itself tell us to skip this one
4069-
$tinfo->{skip_detected_by_test}= 1;
4070-
# Try to get reason from test log file
4071-
find_testcase_skipped_reason($tinfo);
4072-
mtr_report_test_skipped($tinfo);
4073-
# Restart if skipped due to missing perl, it may have had side effects
4074-
if ( $tinfo->{'comment'} =~ /^perl not found/ )
4075-
{
4076-
stop_all_servers($opt_shutdown_timeout);
4077-
}
4078-
}
4079-
elsif ( $res == 65 )
4080-
{
4081-
# Testprogram killed by signal
4082-
$tinfo->{comment}=
4083-
"testprogram crashed(returned code $res)";
4084-
report_failure_and_restart($tinfo);
4085-
}
4086-
elsif ( $res == 1 )
4087-
{
4088-
# Check if the test tool requests that
4089-
# an analyze script should be run
4090-
my $analyze= find_analyze_request();
4091-
if ($analyze){
4092-
run_on_all($tinfo, "analyze-$analyze");
4093-
}
4094-
4095-
# Wait a bit and see if a server died, if so report that instead
4096-
mtr_milli_sleep(100);
4097-
my $srvproc= My::SafeProcess::check_any();
4098-
if ($srvproc && grep($srvproc eq $_, started(all_servers()))) {
4099-
$proc= $srvproc;
4100-
goto SRVDIED;
4101-
}
4102-
4103-
# Test case failure reported by mysqltest
4104-
report_failure_and_restart($tinfo);
4105-
}
4106-
else
4107-
{
4108-
# mysqltest failed, probably crashed
4109-
$tinfo->{comment}=
4110-
"mysqltest failed with unexpected return code $res\n";
4111-
report_failure_and_restart($tinfo);
4112-
}
4113-
4114-
# Save info from this testcase run to mysqltest.log
4115-
if( -f $path_current_testlog)
4116-
{
4117-
if ($opt_resfile && $res && $res != 62) {
4118-
resfile_output_file($path_current_testlog);
4119-
}
4120-
mtr_appendfile_to_file($path_current_testlog, $path_testlog);
4121-
unlink($path_current_testlog);
4122-
}
4123-
4124-
return ($res == 62) ? 0 : $res;
4125-
4055+
mtr_report("Resuming tests...\n");
4056+
resfile_output($tinfo->{'check'}) if $opt_resfile;
4057+
}
4058+
else {
4059+
# Test case check failed fatally, probably a server crashed
4060+
report_failure_and_restart($tinfo);
4061+
return 1;
4062+
}
4063+
}
4064+
mtr_report_test_passed($tinfo);
41264065
}
4127-
4128-
# ----------------------------------------------------
4129-
# Check if it was an expected crash
4130-
# ----------------------------------------------------
4131-
my $check_crash = check_expected_crash_and_restart($proc);
4132-
if ($check_crash == 0) # unexpected exit/crash of $proc
4066+
elsif ( $res == 62 )
4067+
{
4068+
# Testcase itself tell us to skip this one
4069+
$tinfo->{skip_detected_by_test}= 1;
4070+
# Try to get reason from test log file
4071+
find_testcase_skipped_reason($tinfo);
4072+
mtr_report_test_skipped($tinfo);
4073+
# Restart if skipped due to missing perl, it may have had side effects
4074+
if ( $tinfo->{'comment'} =~ /^perl not found/ )
4075+
{
4076+
stop_all_servers($opt_shutdown_timeout);
4077+
}
4078+
}
4079+
elsif ( $res == 65 )
4080+
{
4081+
# Testprogram killed by signal
4082+
$tinfo->{comment}=
4083+
"testprogram crashed(returned code $res)";
4084+
report_failure_and_restart($tinfo);
4085+
}
4086+
elsif ( $res == 1 )
41334087
{
4134-
$expected_exit = 0;
4135-
last;
4088+
# Check if the test tool requests that
4089+
# an analyze script should be run
4090+
my $analyze= find_analyze_request();
4091+
if ($analyze){
4092+
run_on_all($tinfo, "analyze-$analyze");
4093+
}
4094+
4095+
# Wait a bit and see if a server died, if so report that instead
4096+
mtr_milli_sleep(100);
4097+
my $srvproc= My::SafeProcess::check_any();
4098+
if ($srvproc && grep($srvproc eq $_, started(all_servers()))) {
4099+
$proc= $srvproc;
4100+
goto SRVDIED;
4101+
}
4102+
4103+
# Test case failure reported by mysqltest
4104+
report_failure_and_restart($tinfo);
41364105
}
4137-
elsif ($check_crash == 1) # $proc was started again by check_expected_crash_and_restart()
4106+
else
41384107
{
4139-
delete $keep_waiting_proc{$proc};
4108+
# mysqltest failed, probably crashed
4109+
$tinfo->{comment}=
4110+
"mysqltest failed with unexpected return code $res\n";
4111+
report_failure_and_restart($tinfo);
41404112
}
4141-
elsif ($check_crash == 2) # we must keep waiting
4113+
4114+
# Save info from this testcase run to mysqltest.log
4115+
if( -f $path_current_testlog)
41424116
{
4143-
# do nothing
4117+
if ($opt_resfile && $res && $res != 62) {
4118+
resfile_output_file($path_current_testlog);
4119+
}
4120+
mtr_appendfile_to_file($path_current_testlog, $path_testlog);
4121+
unlink($path_current_testlog);
41444122
}
4123+
4124+
return ($res == 62) ? 0 : $res;
4125+
41454126
}
41464127

4147-
if ($expected_exit) {
4128+
# ----------------------------------------------------
4129+
# Check if it was an expected crash
4130+
# ----------------------------------------------------
4131+
my $check_crash = check_expected_crash_and_restart($proc);
4132+
if ($check_crash)
4133+
{
4134+
# Keep waiting if it returned 2, if 1 don't wait or stop waiting.
4135+
$keep_waiting_proc = 0 if $check_crash == 1;
4136+
$keep_waiting_proc = $proc if $check_crash == 2;
41484137
next;
41494138
}
41504139

0 commit comments

Comments
 (0)