Bug #18415 known problem when mysql-test-run.pl run ActiveState perl for windows
Submitted: 22 Mar 2006 10:36 Modified: 10 Jul 2007 22:07
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0 + 5.1 OS:Windows (windows)
Assigned to: Magnus Blåudd CPU Architecture:Any

[22 Mar 2006 10:36] Magnus Blåudd
Description:
It's not possible to run the mysql-test-run.pl script with the ActiveState version of perl on Windows. mysql-test-run.pl will abort without any error message.

How to repeat:
Run mysql-test-run.pl with ActiveState perl.
[22 Mar 2006 10:38] Magnus Blåudd
Found one problem in mysql-test-run.pl where 'waitpid' is called. If the result from waitpid is < 0 we threat this as an error and say "Got lost somehow" but it's actually only -1 that indicates an error.

Change the check to "waitpid == -1"
[22 Mar 2006 10:42] Magnus Blåudd
Another problem seems to be that when the child redirects the output for STDOUT, it will also redirect the STDOUT from it's parent.

See this bug report: http://bugs.activestate.com/show_bug.cgi?id=24007

This is most likely caused by the child running as a thread in the same process.

No workaround found.
[22 Mar 2006 10:44] Magnus Blåudd
If the "wiatpid == -1" fix is made and the child does not redirect STDOUT it will run the tests all the way until it calls mysqadmin to shutdown the mysqld. It will however hang indefinitely waiting for "something" and never complete.

To be investigated...
[29 Mar 2006 8:57] Magnus Blåudd
Found another "waitpid > 0" and corrected that. This makes the tests complete under activestate. Horray!
[29 Mar 2006 9:05] Magnus Blåudd
The redirect of STDOUT problem is as follows.
Normally a "fork" will create a new process with it's own STDOUT, thus redirecting it to whatever file is no problem. However in the ActiveState perl version the "fork" command will just create a new thread. This means the STDOUT is the same both for parent and child. And so if the child redirects STDOUT, it will redirect it for the parent as well.

I have tried with IPC::open3 and managed to redirect both STDOUT and STDERR to it's own files, but I couldn't get the child to read it's input from a file. And this is very important for the bootstrapping of mysqld. But it should be possible to get it to work since what the IPC::open3 does is to execute the child in another process. I need som help to write a replacement for exec if we are running on ActiveState perl.

Something like:

use IPC::open3;

# Execute the command using open3
my $opid= open3($input, $output, $error, $cmd, $args);

# Wait for the process to return, this is done in a child thread, so let's wait forever
waitpid($opid, 0);
[29 Mar 2006 9:07] Magnus Blåudd
However, an easy workaround to this problem is to skip redirect of STDOUT "if ( $win32_perl )", this will have the sideffect that some additional printouts from mysqld etc can be seen on the screen, but at least we can run the tests.
[7 Apr 2006 13:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4637
[7 Apr 2006 13:34] Magnus Blåudd
There also seems to be some kind of memory leak. Especially when test cases are skipped, the memory consumption will increase rapidly and suddenly the perl interpreter will exit with out any error message.

To be investigated...
[10 Apr 2006 14:46] Magnus Blåudd
Kent, has sent me a review for this bug. Some fixes TBD.
[11 Apr 2006 14:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4802
[12 Apr 2006 6:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4834
[27 Apr 2006 13:06] Magnus Blåudd
Patch pushed. All printouts from mysqld etc will be printed to stdout. Have to find a workaround for that.
[3 Aug 2006 9:26] Magnus Blåudd
As I wrote earlier, this is working and mysql-test-run.pl will run. but all stdout printouts from mysqld etc will be printed to the console. Maybe there is a switch to mysqld that sends the output dircetly to the logfile.
[3 Aug 2006 9:51] Magnus Blåudd
guilhem maybe this one is what you are looking for:
guilhem   {"log-error", OPT_ERROR_LOG_FILE, "Error log file.",
guilhem    (gptr*) &log_error_file_ptr, (gptr*) &log_error_file_ptr, 0, GET_STR,
guilhem    OPT_ARG, 0, 0, 0, 0, 0, 0},
[15 Jun 2007 15:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/28875

ChangeSet@1.2531, 2007-06-15 17:33:00+02:00, msvensson@pilot.(none) +1 -0
  Bug#18415 known problem when mysql-test-run.pl run ActiveState perl for windows
   - Select STDOUT as default handle after having cloned the child
   - Disable check for "$error eq $output" to ptoperly redirect $error
[15 Jun 2007 15:42] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/28878

ChangeSet@1.2531, 2007-06-15 17:42:03+02:00, msvensson@pilot.(none) +1 -0
  Bug#18415 known problem when mysql-test-run.pl run ActiveState perl for windows
   - Select STDOUT as default handle after having cloned the child
   - Disable check for "$error eq $output" to ptoperly redirect $error
[20 Jun 2007 15:23] Daniel Fischer
Approved. Also tested running the test suite with ActivePerl.
[10 Jul 2007 13:27] Bugs System
Pushed into 5.1.21-beta
[10 Jul 2007 13:29] Bugs System
Pushed into 5.0.46
[10 Jul 2007 22:07] Paul DuBois
Noted in 5.0.46, 5.1.21 changelogs.

Under ActiveState Perl, mysql-test-run.pl would not run.