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

mtr: fix a race condition

if a test can run in cond1,cond2 and cond1,cond3 then they can happen
to run in parallel and both wanting to create test,cond1.result~
This commit is contained in:
Sergei Golubchik
2022-06-15 14:53:51 +02:00
parent 2e7e89d6c9
commit f31e935c3e

View File

@ -3359,17 +3359,21 @@ sub do_before_run_mysqltest($)
if ($^O eq "MSWin32") {
push @cmd, '--binary';
}
push @cmd, (qw/-r - -f -s -o/, $dest, $base_result, $resfile);
push @cmd, (qw/-r - -f -s -o/, $dest . $$, $base_result, $resfile);
if (-w $resdir) {
# don't rebuild a file if it's up to date
unless (-e $dest and -M $dest < -M $resfile
and -M $dest < -M $base_result) {
run_system(@cmd);
rename $cmd[-3], $dest or unlink $cmd[-3];
}
} else {
$cmd[-3] = $dest = $opt_tmpdir . '/' . basename($dest);
$dest = $opt_tmpdir . '/' . basename($dest);
$cmd[-3] = $dest . $$;
run_system(@cmd);
rename $cmd[-3], $dest or unlink $cmd[-3];
}
$tinfo->{result_file} = $dest;
}