diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-07-05 21:46:00 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-07-06 16:12:13 +0200 |
commit | 1223cfe1d3d72598e788582701989f9bb35695fb (patch) | |
tree | 05ea529d510be17db56edfd94f920e7b340d9644 | |
parent | 6a466db00ab5656bfc091f81abf363b00248d1f8 (diff) | |
download | mariadb-git-1223cfe1d3d72598e788582701989f9bb35695fb.tar.gz |
MDEV-25802 mtr: race condition if the test quickly restarts twice
expect file is always removed before starting a server.
So if it exists here, it means the server started successfully,
mysqltest continued executing the test, created a new expect file,
and shut down the server. All while we were waiting for the server
to start.
In other words, if the expect file exists, the server did actually start.
Even if it isn't running now.
This fixes occasional failures of innodb.log_corruption (in 10.6)
-rw-r--r-- | mysql-test/lib/mtr_process.pl | 6 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 11 |
2 files changed, 10 insertions, 7 deletions
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index cee9f2b6ed6..c568f8dc48c 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -40,7 +40,7 @@ BEGIN eval 'sub USE_NETPING { $use_netping }'; } -sub sleep_until_file_created ($$$$); +sub sleep_until_file_created ($$$$$); sub mtr_ping_port ($); sub mtr_ping_port ($) { @@ -102,8 +102,9 @@ sub mtr_ping_port ($) { # FIXME check that the pidfile contains the expected pid! -sub sleep_until_file_created ($$$$) { +sub sleep_until_file_created ($$$$$) { my $pidfile= shift; + my $expectfile = shift; my $timeout= shift; my $proc= shift; my $warn_seconds = shift; @@ -122,6 +123,7 @@ sub sleep_until_file_created ($$$$) { # Check if it died after the fork() was successful if ( defined $proc and ! $proc->wait_one(0) ) { + return 1 if -r $expectfile; mtr_warning("Process $proc died after mysql-test-run waited $seconds " . "seconds for $pidfile to be created."); return 0; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a91bdc0b751..29aaebd44b0 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2845,11 +2845,11 @@ sub mysql_server_start($) { sub mysql_server_wait { my ($mysqld, $tinfo) = @_; + my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect"; - if (!sleep_until_file_created($mysqld->value('pid-file'), - $opt_start_timeout, - $mysqld->{'proc'}, - $warn_seconds)) + if (!sleep_until_file_created($mysqld->value('pid-file'), $expect_file, + $opt_start_timeout, $mysqld->{'proc'}, + $warn_seconds)) { $tinfo->{comment}= "Failed to start ".$mysqld->name() . "\n"; return 1; @@ -5123,7 +5123,8 @@ sub mysqld_start ($$) { $mysqld->{'started_opts'}= $extra_opts; - return sleep_until_file_created($mysqld->value('pid-file'), + my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect"; + return sleep_until_file_created($mysqld->value('pid-file'), $expect_file, $opt_start_timeout, $mysqld->{'proc'}, $warn_seconds); } |