summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-06-15 14:53:51 +0200
committerSergei Golubchik <serg@mariadb.org>2022-06-15 14:55:35 +0200
commitf31e935c3e0649d36008ab440cd87cb7ff474bb3 (patch)
tree61514b49e884d2bec7d7818a9f4ffb08538586f4
parent2e7e89d6c94db51d473ddfb9e023d4f19925e524 (diff)
downloadmariadb-git-f31e935c3e0649d36008ab440cd87cb7ff474bb3.tar.gz
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~
-rwxr-xr-xmysql-test/mysql-test-run.pl8
1 files changed, 6 insertions, 2 deletions
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index a01de00e0c2..a5f576de0b3 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -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;
}