From 62d3063dc18d6251b55911af7d15163ab4adaab1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Mar 2007 15:43:36 +0200 Subject: [PATCH 1/3] Bug#25657 mysql-test-run.pl kill itself under ActiveState perl - Read the pid from pidfile in order to be able to kill the real process instead of the pseudo process. Most platforms will have the same real_pid as pid - Kill using the real pid mysql-test/lib/mtr_process.pl: Kill using the "real_pid" mysql-test/mysql-test-run.pl: Read the pid from pidfile in order to be able to kill the real process instead of the pseudo process. Most platforms will have the same real_pid as pid --- mysql-test/lib/mtr_process.pl | 25 +++++++++++++++---------- mysql-test/mysql-test-run.pl | 17 +++++++++++++---- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 53bf37bcc83..b20c9b65dd5 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -562,7 +562,7 @@ sub mtr_check_stop_servers ($) { # Return if no processes are defined return if ! @$spec; - #mtr_report("mtr_check_stop_servers"); + mtr_verbose("mtr_check_stop_servers"); mtr_ping_with_timeout(\@$spec); @@ -605,7 +605,10 @@ sub mtr_check_stop_servers ($) { { if ( $srv->{'pid'} ) { - $mysqld_pids{$srv->{'pid'}}= 1; + # Add the process pid to list of pids to kill + # if the process has a "real_pid" use it + $mysqld_pids{$srv->{'real_pid'} ? + $srv->{'real_pid'} : $srv->{'pid'}}= 1; } else { @@ -638,13 +641,9 @@ sub mtr_check_stop_servers ($) { # that for true Win32 processes, kill(0,$pid) will not return 1. # ---------------------------------------------------------------------- - start_reap_all(); # Avoid zombies - my @mysqld_pids= keys %mysqld_pids; mtr_kill_processes(\@mysqld_pids); - stop_reap_all(); # Get into control again - # ---------------------------------------------------------------------- # Now, we check if all we can find using kill(0,$pid) are dead, # and just assume the rest are. We cleanup socket and PID files. @@ -654,14 +653,15 @@ sub mtr_check_stop_servers ($) { my $errors= 0; foreach my $srv ( @$spec ) { - if ( $srv->{'pid'} ) + my $pid= $srv->{'real_pid'} ? $srv->{'real_pid'} : $srv->{'pid'}; + if ( $pid ) { - if ( kill(0,$srv->{'pid'}) ) + if ( kill(0, $pid) ) { # FIXME In Cygwin there seem to be some fast reuse # of PIDs, so dying may not be the right thing to do. $errors++; - mtr_warning("can't kill process $srv->{'pid'}"); + mtr_warning("can't kill process $pid"); } else { @@ -682,6 +682,8 @@ sub mtr_check_stop_servers ($) { mtr_warning("couldn't delete $file"); } } + # Reap the child + waitpid($srv->{'pid'},&WNOHANG); $srv->{'pid'}= 0; } } @@ -1063,7 +1065,10 @@ sub sleep_until_file_created ($$$) { { if ( -r $pidfile ) { - return $pid; + # Read real pid from pidfile + my $real_pid= mtr_fromfile($pidfile); + mtr_verbose("pid: $pid, real_pid: $real_pid"); + return $real_pid; } # Check if it died after the fork() was successful diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3166672dd89..70e51c288f4 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2549,10 +2549,16 @@ sub ndbcluster_wait_started($$){ sub mysqld_wait_started($){ my $mysqld= shift; - my $res= sleep_until_file_created($mysqld->{'path_pid'}, - $mysqld->{'start_timeout'}, - $mysqld->{'pid'}); - return $res == 0; + my $pid_from_pidfile= + sleep_until_file_created($mysqld->{'path_pid'}, + $mysqld->{'start_timeout'}, + $mysqld->{'pid'}); + + # On platforms with pseudo threads we need to save + # the real pid of mysqld read from pidfile + $mysqld->{'real_pid'}= $pid_from_pidfile; + + return $pid_from_pidfile == 0; } @@ -4047,6 +4053,7 @@ sub stop_all_servers () { push(@kill_pids,{ pid => $mysqld->{'pid'}, + real_pid => $mysqld->{'real_pid'}, pidfile => $mysqld->{'path_pid'}, sockfile => $mysqld->{'path_sock'}, port => $mysqld->{'port'}, @@ -4253,6 +4260,7 @@ sub run_testcase_stop_servers($$$) { push(@kill_pids,{ pid => $mysqld->{'pid'}, + real_pid => $mysqld->{'real_pid'}, pidfile => $mysqld->{'path_pid'}, sockfile => $mysqld->{'path_sock'}, port => $mysqld->{'port'}, @@ -4303,6 +4311,7 @@ sub run_testcase_stop_servers($$$) { push(@kill_pids,{ pid => $mysqld->{'pid'}, + real_pid => $mysqld->{'real_pid'}, pidfile => $mysqld->{'path_pid'}, sockfile => $mysqld->{'path_sock'}, port => $mysqld->{'port'}, From a632339f482aa642ecc2b8baaa20eb9c22d5abcf Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Mar 2007 16:43:15 +0200 Subject: [PATCH 2/3] Cset exclude: msvensson@shellback.(none)|ChangeSet|20070330134336|02280 mysql-test/lib/mtr_process.pl: Exclude mysql-test/mysql-test-run.pl: Exclude --- mysql-test/lib/mtr_process.pl | 25 ++++++++++--------------- mysql-test/mysql-test-run.pl | 17 ++++------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index b20c9b65dd5..53bf37bcc83 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -562,7 +562,7 @@ sub mtr_check_stop_servers ($) { # Return if no processes are defined return if ! @$spec; - mtr_verbose("mtr_check_stop_servers"); + #mtr_report("mtr_check_stop_servers"); mtr_ping_with_timeout(\@$spec); @@ -605,10 +605,7 @@ sub mtr_check_stop_servers ($) { { if ( $srv->{'pid'} ) { - # Add the process pid to list of pids to kill - # if the process has a "real_pid" use it - $mysqld_pids{$srv->{'real_pid'} ? - $srv->{'real_pid'} : $srv->{'pid'}}= 1; + $mysqld_pids{$srv->{'pid'}}= 1; } else { @@ -641,9 +638,13 @@ sub mtr_check_stop_servers ($) { # that for true Win32 processes, kill(0,$pid) will not return 1. # ---------------------------------------------------------------------- + start_reap_all(); # Avoid zombies + my @mysqld_pids= keys %mysqld_pids; mtr_kill_processes(\@mysqld_pids); + stop_reap_all(); # Get into control again + # ---------------------------------------------------------------------- # Now, we check if all we can find using kill(0,$pid) are dead, # and just assume the rest are. We cleanup socket and PID files. @@ -653,15 +654,14 @@ sub mtr_check_stop_servers ($) { my $errors= 0; foreach my $srv ( @$spec ) { - my $pid= $srv->{'real_pid'} ? $srv->{'real_pid'} : $srv->{'pid'}; - if ( $pid ) + if ( $srv->{'pid'} ) { - if ( kill(0, $pid) ) + if ( kill(0,$srv->{'pid'}) ) { # FIXME In Cygwin there seem to be some fast reuse # of PIDs, so dying may not be the right thing to do. $errors++; - mtr_warning("can't kill process $pid"); + mtr_warning("can't kill process $srv->{'pid'}"); } else { @@ -682,8 +682,6 @@ sub mtr_check_stop_servers ($) { mtr_warning("couldn't delete $file"); } } - # Reap the child - waitpid($srv->{'pid'},&WNOHANG); $srv->{'pid'}= 0; } } @@ -1065,10 +1063,7 @@ sub sleep_until_file_created ($$$) { { if ( -r $pidfile ) { - # Read real pid from pidfile - my $real_pid= mtr_fromfile($pidfile); - mtr_verbose("pid: $pid, real_pid: $real_pid"); - return $real_pid; + return $pid; } # Check if it died after the fork() was successful diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 70e51c288f4..3166672dd89 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2549,16 +2549,10 @@ sub ndbcluster_wait_started($$){ sub mysqld_wait_started($){ my $mysqld= shift; - my $pid_from_pidfile= - sleep_until_file_created($mysqld->{'path_pid'}, - $mysqld->{'start_timeout'}, - $mysqld->{'pid'}); - - # On platforms with pseudo threads we need to save - # the real pid of mysqld read from pidfile - $mysqld->{'real_pid'}= $pid_from_pidfile; - - return $pid_from_pidfile == 0; + my $res= sleep_until_file_created($mysqld->{'path_pid'}, + $mysqld->{'start_timeout'}, + $mysqld->{'pid'}); + return $res == 0; } @@ -4053,7 +4047,6 @@ sub stop_all_servers () { push(@kill_pids,{ pid => $mysqld->{'pid'}, - real_pid => $mysqld->{'real_pid'}, pidfile => $mysqld->{'path_pid'}, sockfile => $mysqld->{'path_sock'}, port => $mysqld->{'port'}, @@ -4260,7 +4253,6 @@ sub run_testcase_stop_servers($$$) { push(@kill_pids,{ pid => $mysqld->{'pid'}, - real_pid => $mysqld->{'real_pid'}, pidfile => $mysqld->{'path_pid'}, sockfile => $mysqld->{'path_sock'}, port => $mysqld->{'port'}, @@ -4311,7 +4303,6 @@ sub run_testcase_stop_servers($$$) { push(@kill_pids,{ pid => $mysqld->{'pid'}, - real_pid => $mysqld->{'real_pid'}, pidfile => $mysqld->{'path_pid'}, sockfile => $mysqld->{'path_sock'}, port => $mysqld->{'port'}, From ff979b76ca7c0e74b7fd7e8d9af78235b48d4339 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 31 Mar 2007 15:07:48 +0200 Subject: [PATCH 3/3] Bug#27049 Race condition in test mysqlbinlog.test - Add --local-load option to avoidthat the load data file requested by mysqlbinlog end up in local var/tmp dir and not in system global tmpdir mysql-test/t/mysqlbinlog.test: Add --local-load option to avoidthat the load data file requested by mysqlbinlog end up in local var/tmp dir and not in system global tmpdir --- mysql-test/t/mysqlbinlog.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 97239360507..35f8485a0bd 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -202,6 +202,6 @@ select hex(a) from t1; drop table t1; flush logs; --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000009 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000009 --echo End of 5.0 tests