List:Commits« Previous MessageNext Message »
From:msvensson Date:April 11 2006 4:58pm
Subject:bk commit into 5.1 tree (msvensson:1.2303) BUG#18415
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2303 06/04/11 16:58:47 msvensson@neptunus.(none) +1 -0
  Bug#18415 mysql-test-run.pl does not run on ActiveState perl
   - Part 1, better handling of subprocess and stdout to be done

  mysql-test/lib/mtr_process.pl
    1.29 06/04/11 16:58:43 msvensson@neptunus.(none) +36 -47
    - Dont redirect stdout if ActiveState perl since fork creates a new thread and not another process.
    - Change waitpid to allow for negative pid as we get on Windows, strange but 
      that is how it is. It should never create a process with pid -1 though.
    - Remove an "if" for cygwin that does not do anything.
    - Add "print" in the potentially hanging while loop in "start_reap_all"
    - Dont use "getpgrp" on windows.
    - Remove "sleep 2" in mtr_exit
    - Remove the initial ping of mysqld's in 'mysql_admin_shutdown', instead just start one 
      mysqladmin for each expected mysqld server and wait for them to return.
      Then perform the ping of the mysqld server's. Those ping's normally return immediately.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/my51-bug18415

--- 1.28/mysql-test/lib/mtr_process.pl	2006-03-06 11:33:42 +01:00
+++ 1.29/mysql-test/lib/mtr_process.pl	2006-04-11 16:58:43 +02:00
@@ -144,17 +144,6 @@
 
       $SIG{INT}= 'DEFAULT';         # Parent do some stuff, we don't
 
-      if ( $::glob_cygwin_shell and $mode eq 'test' )
-      {
-        # Programs started from mysqltest under Cygwin, are to
-        # execute them within Cygwin. Else simple things in test
-        # files like
-        # --system "echo 1 > file"
-        # will fail.
-        # FIXME not working :-(
-#       $ENV{'COMSPEC'}= "$::glob_cygwin_shell -c";
-      }
-
       my $log_file_open_mode = '>';
 
       if ($spawn_opts and $spawn_opts->{'append_log_file'})
@@ -164,7 +153,15 @@
 
       if ( $output )
       {
-        if ( ! open(STDOUT,$log_file_open_mode,$output) )
+	if ( $::glob_win32_perl )
+	{
+	  # Don't redirect stdout on ActiveState perl since this is
+          # just another thread in the same process.
+          # Should be fixed so that the thread that is created with fork
+          # executes the exe in another process and wait's for it to return.
+          # In the meanwhile, we get all the output from mysqld's to screen
+	}
+        elsif ( ! open(STDOUT,$log_file_open_mode,$output) )
         {
           mtr_child_error("can't redirect STDOUT to \"$output\": $!");
         }
@@ -216,8 +213,7 @@
     {
       # Simple run of command, we wait for it to return
       my $ret_pid= waitpid($pid,0);
-
-      if ( $ret_pid <= 0 )
+      if ( $ret_pid != $pid )
       {
         mtr_error("$path ($pid) got lost somehow");
       }
@@ -245,7 +241,6 @@
         # Someone terminated, don't know who. Collect
         # status info first before $? is lost,
         # but not $exit_value, this is flagged from
-        # 
 
         my $timer_name= mtr_timer_timeout($::glob_timers, $ret_pid);
         if ( $timer_name )
@@ -310,7 +305,7 @@
 
         $ret_pid= waitpid($pid,0);
 
-        if ( $ret_pid == -1 )
+        if ( $ret_pid != $pid )
         {
           mtr_error("$path ($pid) got lost somehow");
         }
@@ -361,7 +356,7 @@
   # First, kill all masters and slaves that would conflict with
   # this run. Make sure to remove the PID file, if any.
   # FIXME kill IM manager first, else it will restart the servers, how?!
-
+  print "mtr_kill_leftovers\n";
   my @args;
 
   for ( my $idx; $idx < 2; $idx++ )
@@ -651,22 +646,10 @@
   my $adm_shutdown_tmo= shift;
 
   my %mysql_admin_pids;
-  my @to_kill_specs;
 
+  # Start one "mysqladmin shutdown" for each server
   foreach my $srv ( @$spec )
   {
-    if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
-    {
-      push(@to_kill_specs, $srv);
-    }
-  }
-
-
-  foreach my $srv ( @to_kill_specs )
-  {
-    # FIXME wrong log.....
-    # FIXME, stderr.....
-    # Shutdown time must be high as slave may be in reconnect
     my $args;
 
     mtr_init_args(\$args);
@@ -674,6 +657,7 @@
     mtr_add_arg($args, "--no-defaults");
     mtr_add_arg($args, "--user=%s", $::opt_user);
     mtr_add_arg($args, "--password=");
+    mtr_add_arg($args, "--silent");
     if ( -e $srv->{'sockfile'} )
     {
       mtr_add_arg($args, "--socket=%s", $srv->{'sockfile'});
@@ -687,26 +671,27 @@
       mtr_add_arg($args, "--protocol=tcp"); # Needed if no --socket
     }
     mtr_add_arg($args, "--connect_timeout=5");
+    # Shutdown time must be high as slave may be in reconnect
     mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo");
     mtr_add_arg($args, "shutdown");
-    # We don't wait for termination of mysqladmin
+    # Start mysqladmin in paralell and wait for termination later
     my $pid= mtr_spawn($::exe_mysqladmin, $args,
                        "", $::path_manager_log, $::path_manager_log, "",
                        { append_log_file => 1 });
+    # Save the pid of the mysqladmin process
     $mysql_admin_pids{$pid}= 1;
   }
 
+  # Wait for all the started mysqladmin to exit
   # As mysqladmin is such a simple program, we trust it to terminate.
   # I.e. we wait blocking, and wait wait for them all before we go on.
-  while (keys %mysql_admin_pids)
+  while ((my $pid) = each %mysql_admin_pids)
   {
-    foreach my $pid (keys %mysql_admin_pids)
-    {
-      if ( waitpid($pid,0) > 0 )
-      {
-        delete $mysql_admin_pids{$pid};
-      }
-    }
+    my $ret_pid= waitpid($pid,0);
+
+    # If this was any of the mysqladmin's we waited for, delete its
+    # pid from list
+    delete $mysql_admin_pids{$ret_pid} if exists $mysql_admin_pids{$ret_pid};
   }
 
   # If we trusted "mysqladmin --shutdown_timeout= ..." we could just
@@ -721,7 +706,7 @@
  TIME:
   while ( $timeout-- )
   {
-    foreach my $srv ( @to_kill_specs )
+    foreach my $srv ( @$spec )
     {
       $res= 1;                          # We are optimistic
       if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
@@ -754,9 +739,9 @@
 
   my $ret_pid;
 
-  # FIXME the man page says to wait for -1 to terminate,
-  # but on OS X we get '0' all the time...
-  while ( ($ret_pid= waitpid(-1,&WNOHANG)) > 0 )
+  # Wait without blockinng to see if any processes had died
+  # -1 or 0 means there are no more procesess to wait for
+  while ( ($ret_pid= waitpid(-1,&WNOHANG)) != 0 and $ret_pid != -1)
   {
     mtr_debug("waitpid() catched exit of child $ret_pid");
     foreach my $idx (0..1)
@@ -789,7 +774,11 @@
   # here. If a process terminated before setting $SIG{CHLD} (but after
   # any attempt to waitpid() it), it will still be a zombie. So we
   # have to handle any such process here.
-  while(waitpid(-1, &WNOHANG) > 0) { };
+  my $pid;
+  while(($pid= waitpid(-1, &WNOHANG)) != 0 and $pid != -1)
+  {
+    print "start_reap_all: pid: $pid.\n";
+  };
 }
 
 sub stop_reap_all {
@@ -843,7 +832,7 @@
     }
 
     # Check if it died after the fork() was successful 
-    if ( $pid > 0 && waitpid($pid,&WNOHANG) == $pid )
+    if ( $pid != 0 && waitpid($pid,&WNOHANG) == $pid )
     {
       return 0;
     }
@@ -905,8 +894,8 @@
   # set ourselves as the group leader at startup (with
   # POSIX::setpgrp(0,0)), but then care must be needed to always do
   # proper child process cleanup.
-  kill('HUP', -$$) if $$ == getpgrp();
-  sleep 2;
+  kill('HUP', -$$) if !$::glob_win32_perl and $$ == getpgrp();
+
   exit($code);
 }
 
Thread
bk commit into 5.1 tree (msvensson:1.2303) BUG#18415msvensson11 Apr