Commit cd0cd4e0 authored by Magnus Svensson's avatar Magnus Svensson

Make events_restart more stable by waiting for the server to be stopped before starting it again

parent 5a9938e5
......@@ -4174,7 +4174,7 @@ void do_shutdown_server(struct st_command *command)
/* Check that server dies */
while(timeout--){
if (my_kill(0, pid) < 0){
DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout));
DBUG_PRINT("info", ("Process %d does not exist anymore", pid));
break;
}
DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout));
......
# Write file to make mysql-test-run.pl expect crash and restart
# Write file to make mysql-test-run.pl expect the "crash", but don't start
# it until it's told to
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
wait
EOF
# Send shutdown to the connected server and give
# it 10 seconds to die before zapping it
shutdown_server 10;
# Check server is gone
--source include/wait_until_disconnected.inc
# Write file to make mysql-test-run.pl start up the server again
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
# Turn on reconnect
--enable_reconnect
......
......@@ -26,7 +26,7 @@ sub mtr_tonewfile($@);
sub mtr_appendfile_to_file ($$);
sub mtr_grab_file($);
sub mtr_printfile($);
sub mtr_lastlinefromfile ($);
# Read a whole file, stripping leading and trailing whitespace.
sub mtr_fromfile ($) {
......@@ -94,5 +94,17 @@ sub mtr_printfile($) {
return;
}
sub mtr_lastlinefromfile ($) {
my $file= shift;
my $text;
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
while (my $line= <FILE>)
{
$text= $line;
}
close FILE;
return $text;
}
1;
......@@ -3320,10 +3320,29 @@ sub check_expected_crash_and_restart {
my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
if ( -f $expect_file )
{
mtr_report("Crash was expected, file '$expect_file' exists");
# Start server with same settings as last time
mysqld_start($mysqld, $mysqld->{'started_opts'});
unlink($expect_file);
mtr_verbose("Crash was expected, file '$expect_file' exists");
while (1){
# If last line in expect file starts with "wait"
# sleep a little and try again, thus allowing the
# test script to control when the server should start
# up again
my $last_line= mtr_lastlinefromfile($expect_file);
if ($last_line =~ /^wait/ )
{
mtr_verbose("Test says wait before restart");
mtr_milli_sleep(100);
next;
}
unlink($expect_file);
# Start server with same settings as last time
mysqld_start($mysqld, $mysqld->{'started_opts'});
last;
}
}
return 1;
......
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