Bug #38629 mysql-test-run.pl start-and-exit does not exit (ActiveState)
Submitted: 7 Aug 2008 13:54 Modified: 17 Oct 2008 18:22
Reporter: Vladislav Vaintroub Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Tests Severity:S7 (Test Cases)
Version:any OS:Microsoft Windows
Assigned to: Vladislav Vaintroub CPU Architecture:Any
Triage: Triaged: D3 (Medium)

[7 Aug 2008 13:54] Vladislav Vaintroub
Description:
if I start mysql-test-run.pl with --start-and-exit, perl does not exit.
Furthermore, it cannot be terminated with CTRL-C
Setting prio to serious,  because System QA tools depent on --start-and-exit 
and do not run without it

How to repeat:
Install Active State Perl
run mysql-test-run.pl --start-and-exit
[7 Aug 2008 14:18] Sveta Smirnova
Thank you for the report.

Verified as described. Workaround: use cygwin
[7 Aug 2008 16:35] Philip Stoev
Wlad, what version of ActiveState are you using? I think I once had a version that exited properly.

The one I have now, which is v5.8.8 built for MSWin32-x86-multi-thread, does not exit.
[7 Aug 2008 16:53] Vladislav Vaintroub
I've got v5.8.8 built for MSWin32-x86-multi-thread as well.
5.10 did not work for another reasons and does/did not have DBD::mysql available, which made it less useful for me.

Cygwin perl could probably work ok, but not on Vista x64, where it (cygwin in general) crashes.

So it looks it 5.8.8 ActiveState 32 bit is my only alternative for now.
[7 Aug 2008 16:54] Philip Stoev
v5.10.0 built for MSWin32-x86-multi-thread is also affected.
[22 Aug 2008 12:01] Philip Stoev
Magnus,

Can you please expedite this a bit? We are trying to run some stress tests unattended under Windows and they rely on --start-and-exit returning success or failure.

I think something may be wrong in the code that calls wait() -- I have seen mtr report errors such as "reaped unknown child -1" where -1 is the result code when the process does not have any more children.
[25 Aug 2008 13:03] Magnus Blåudd
The ActiveState perl code is buggy and requires all started processes to have exited before the main thread can exit.

Will help to find a good workaround.
[25 Aug 2008 13:58] Vladislav Vaintroub
Maybe Win32::Process already has all needed features, at least it looks like this (CreateProcess is there, optional Wait also there). I'm a tiny bit sceptical about using fork() on Windows.
[29 Aug 2008 12:04] Philip Stoev
One solution that appears to work is:

use POSIX qw[ _exit ];

# avoid perl exit which hangs in some circumstances
POSIX::_exit(0);
[29 Aug 2008 16:32] Philip Stoev
Magnus, can we expediate that? Danny does not want to have cygwin on PushBuild2 machines, so we need to make ActiveState work in order to run stress tests on PushBuild2. Ideally, this should be pushed next week.

The risk of the change can be made smaller by only using POSIX::_exit() on Windows, and only when exiting the --start-and-exit option. This way the rest of the script will remain unaffected.
[29 Aug 2008 16:35] Vladislav Vaintroub
tried the workaround described by Philip, it worked on fine for me.
I changed the only occurence of exit() in mysql-test-run.pl.
there might be another places where exit() is used, mtr_exit() maybe
[29 Aug 2008 16:46] Magnus Blåudd
Philip, that patch looks fine. Maybe you can add it within if's to only use it on Active State perl
if ($^O eq "mswin32") << or whatever "echo $^0" says
{
  use POSIX qw[ _exit ];
 
  # avoid perl exit which hangs in some circumstances
  POSIX::_exit(0);
}

Only apply it in the place where --start-and-exit will exit, no need to touch the other places.
[2 Oct 2008 14: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/55095

2694 Vladislav Vaintroub	2008-10-02
      Bug #38629  	
      mysql-test-run.pl --start-and-exit starts but does not exit
      Instead, it hangs with ActiveState perl. The error is
      believed to be a bug in ActiveState implementation.
      Workaround is using POSIX::_exit, as described here
      http://www.perlmonks.org/?node_id=334610
      
      Thanks to Philip Stoev for the idea of the patch.
[2 Oct 2008 16:44] 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/55120

2845 Vladislav Vaintroub	2008-10-02
      Bug #38629  	
      mysql-test-run.pl --start-and-exit starts but does not exit
      Instead, it hangs with ActiveState perl. The error is
      believed to be a bug in ActiveState implementation.
      Workaround is using POSIX::_exit, as described here
      http://www.perlmonks.org/?node_id=334610
        
      Thanks to Philip Stoev for the idea of the patch.
[9 Oct 2008 17:28] Bugs System
Pushed into 5.0.72  (revid:vvaintroub@mysql.com-20081002142941-hb04weh21nspg8iz) (version source revid:vvaintroub@mysql.com-20081002142941-hb04weh21nspg8iz) (pib:4)
[9 Oct 2008 17:42] Bugs System
Pushed into 5.1.30  (revid:vvaintroub@mysql.com-20081002142941-hb04weh21nspg8iz) (version source revid:mats@sun.com-20081008113713-2vxny72m5w1tywoi) (pib:4)
[15 Oct 2008 15:09] Paul Dubois
This is actually pushed to 5.1.29, not 5.1.30.
[15 Oct 2008 17:44] Paul Dubois
Noted in 5.0.72, 5.1.29 changelogs.

On ActiveState Perl, mysql-test-run.pl --start-and-exit started but
did not exit. 

Setting report to NDI pending push into 6.0.x.
[17 Oct 2008 16:45] Bugs System
Pushed into 6.0.8-alpha  (revid:vvaintroub@mysql.com-20081002142941-hb04weh21nspg8iz) (version source revid:vvaintroub@mysql.com-20081002155921-5rreymbqfi3wk3rx) (pib:5)
[17 Oct 2008 18:22] Paul Dubois
Noted in 6.0.8 changelog.
[28 Oct 2008 21:04] Bugs System
Pushed into 5.1.29-ndb-6.2.17  (revid:vvaintroub@mysql.com-20081002142941-hb04weh21nspg8iz) (version source revid:tomas.ulin@sun.com-20081028140209-u4emkk1xphi5tkfb) (pib:5)
[28 Oct 2008 22:23] Bugs System
Pushed into 5.1.29-ndb-6.3.19  (revid:vvaintroub@mysql.com-20081002142941-hb04weh21nspg8iz) (version source revid:tomas.ulin@sun.com-20081028194045-0353yg8cvd2c7dd1) (pib:5)
[1 Nov 2008 9:49] Bugs System
Pushed into 5.1.29-ndb-6.4.0  (revid:vvaintroub@mysql.com-20081002142941-hb04weh21nspg8iz) (version source revid:jonas@mysql.com-20081101082305-qx5a1bj0z7i8ueys) (pib:5)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:33] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)