Bug #55780 RQG: kill of periodic reporting process on Windows fails with runall-new.pl
Submitted: 5 Aug 2010 12:23 Modified: 9 Jan 2015 14:45
Reporter: John Embretsen Email Updates:
Status: Won't fix Impact on me:
None 
Category:Tools: Random Query Generator Severity:S1 (Critical)
Version:bzr_revno_509 OS:Windows
Assigned to: Bernt Marius Johnsen CPU Architecture:Any

[5 Aug 2010 12:23] John Embretsen
Description:
runall-new.pl (the MTR-independent version of runall.pl) has some issues on the Windows platform. One issue is that sometimes a test run can end abruptly without notice.

Platform details: Windows 7 64-bit, ActiveState Perl 5.1.10.
Also observed on Win 2003.

It seems like this is related to a call to kill() in GenTest::App::GenTest.pm, around line 372, as shown below. Here I have added a code line to indicate that the kill() call has finished:

if ($periodic_died == 0) {
    # Wait for periodic process to return the status of its last execution
    Time::HiRes::sleep(1);
    say("Killing periodic reporting process with pid $periodic_pid...");
    my $returnval = kill(15, $periodic_pid);
    say("#### kill returned $returnval");     # <---- Added this line
            
    if (osWindows()) {
        # We use sleep() + non-blocking waitpid() due to a bug in ActiveState Perl
        Time::HiRes::sleep(1);
        waitpid($periodic_pid, &POSIX::WNOHANG() );
    } else {
        waitpid($periodic_pid, 0);
    }
(...)

When running a test using a simple example grammar (conf/examples/example.yy) with runall.pl, bottom part of output is:

# 2010-08-05T14:14:32 Creating MySQL table DD, size 100 rows, engine  .
# 2010-08-05T14:14:32 Reporters: Shutdown, ErrorLog, Backtrace
# 2010-08-05T14:14:33 Validators: ErrorMessageCorruption
# 2010-08-05T14:14:33 Starting 1 processes, 10000 queries each, duration 40 seconds.
# 2010-08-05T14:14:33 Started periodic reporting process...
# 2010-08-05T14:14:33 Executor initialized, id 1
# 2010-08-05T14:14:33 Default schema: test
# 2010-08-05T14:14:33 Caching metadata for dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test
# 2010-08-05T14:14:34 GenTest::ErrorFilter(1) started
# 2010-08-05T14:14:37 Query: INSERT INTO `d` ( `pk` ) VALUES ( 7 ) failed: 1062 Duplicate entry '%s' for key '%s'. Further errors of this kind will be suppressed.
# 2010-08-05T14:15:13 Child process completed successfully.
# 2010-08-05T14:15:14 Killing periodic reporting process with pid -3112...
# 2010-08-05T14:15:14 #### kill returned 1
# 2010-08-05T14:15:15 Shutting down the server...
# 2010-08-05T14:15:15 Test completed successfully.
# 2010-08-05T14:15:15 gentest.pl exited with exit status 0

However, when using runall-new.pl, the corresponding output is:

# 2010-08-05T13:56:44 Creating MySQL table DD, size 100 rows, engine  .
# 2010-08-05T13:56:44 Reporters: ErrorLog, Backtrace
# 2010-08-05T13:56:45 Validators: ErrorMessageCorruption
# 2010-08-05T13:56:45 Starting 1 processes, 10000 queries each, duration 40 seconds.
# 2010-08-05T13:56:45 Started periodic reporting process...
# 2010-08-05T13:56:46 Executor initialized, id 1
# 2010-08-05T13:56:46 Default schema: test
# 2010-08-05T13:56:46 Caching metadata for dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test
# 2010-08-05T13:56:46 GenTest::ErrorFilter(1) started
# 2010-08-05T13:56:47 Query: INSERT INTO `c` ( `pk` ) VALUES ( 7 ) failed: 1062 Duplicate entry '%s' for key '%s'. Further errors of this kind will be suppressed.
# 2010-08-05T13:57:13 Child process completed successfully.
# 2010-08-05T13:57:14 Killing periodic reporting process with pid -2696...

and then the Perl process ends with a non-zero exit code.

This issue is not present on Unix, where the kill() call apparently returns 1 with both runall.pl and runall-new.pl.

How to repeat:
perl ./runall-new.pl --basedir=C:\path\to\mysql --grammar=conf/examples/example.yy --queries=10000 --duration=40 --threads=1
[17 Aug 2010 13:07] Bernt Marius Johnsen
Seems to work in Windows Server 2007 SP2. I guess this is one of the problems that is caused by perl's fork emulation. The proper solution would be to use Perl Threads on Windows (and preferrably on all other platforms, but there are Solaris issues wrt. perl Threads).
[2 Nov 2010 5:05] Anitha Gopi
If this problem is not seen on windows 7  can we upgrade the PB2 windows machines.