Bug #47455 The myisam_crash_before_flush_keys test fails on Windows
Submitted: 19 Sep 22:10 Modified: 11 Nov 15:25
Reporter: Igor Babaev
Status: Closed
Category:Client Severity:S3 (Non-critical)
Version:5.1 OS:Microsoft Windows
Assigned to: Sergey Vojtovich Target Version:5.1+
Triage: Triaged: D3 (Medium)

[19 Sep 22:10] Igor Babaev
Description:
When working on Windows with the build created from the current mysql-5.1 tree 
(http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.1/) and trying to run

mysql-5.1\mysql-test>perl mysql-test-run.pl myisam_crash_before_flush_keys

I've got an unexpected result.

How to repeat:
Install MySQL from the build tree on Windows following the instructions that could be
found in win/README.

Run 

mysql-5.1\mysql-test>perl mysql-test-run.pl myisam_crash_before_flush_keys

You'll get something like this:

C:\mysql-5.1\mysql-test>perl mysql-test-run.pl myisam_crash_before_flush_keys
Logging: mysql-test-run.pl  myisam_crash_before_flush_keys
MySQL Version 5.1.40
Checking supported features...
 - skipping ndbcluster, mysqld not compiled with ndbcluster
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
vardir: C:/mysql-5.1/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory 'C:/mysql-5.1/mysql-test/var'...
Installing system database...
Using server port 3647

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
Could not open event or process 1952, error: 87
Couldn't open the winpid: 1952 for pid: 1952, try one more time
Could not open event or process 1952, error: 87
Couldn't open the winpid: 1952 for pid: 1952, continue and see what happens...
main.myisam_crash_before_flush_keys      [ fail ]
        Test ended at 2009-09-19 12:40:14

CURRENT_TEST: main.myisam_crash_before_flush_keys
mysqltest: At line 33: command "$MYISAMCHK -rs $MYSQLD_DATADIR/test/t1" failed

Output from before failure:
exec of 'C:\mysql-5.1\storage\myisam\debug\myisamchk.exe -rs
C:/mysql-5.1/mysql-test/var/mysqld.1/data//test/t1' failed, error: 1, status: 1, errno:
0

The result from queries just before the failure was:
< snip >
SET GLOBAL delay_key_write=ALL;
CREATE TABLE t1(a INT,
b INT,
PRIMARY KEY(a , b),
KEY(b)) ENGINE=MyISAM DELAY_KEY_WRITE = 1;
INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6);
# Setup the mysqld to crash at certain point
SET SESSION debug="d,crash_before_flush_keys";
# Write file to make mysql-test-run.pl expect crash
# Run the crashing query
FLUSH TABLE t1;
ERROR HY000: Lost connection to MySQL server during query
# Run MYISAMCHK tool to check the table t1 and repair
myisamchk.exe: MyISAM file MYSQLD_DATADIR/test/t1
myisamchk.exe: warning: 1 client is using or hasn't closed the table properly
myisamchk.exe: error: Size of indexfile is: 1024            Should be: 3072
MYISAMCHK: Unknown error 126
myisamchk.exe: error: Can't read indexpage from filepos: 1024
MyISAM-table 'MYSQLD_DATADIR/test/t1' is corrupted
Fix it using switch "-r" or "-o"

More results from queries before failure can be found in
C:\mysql-5.1\mysql-test\var\log\myisam

 - saving 'C:/mysql-5.1/mysql-test/var/log/main.myisam_crash_before_flush_keys/' to
'C:/mysql-5.1/mysql-test/var/log/main.myisam_crash_before_flush_keys/'
------------------------------------------------------------
The servers were restarted 0 times
Spent 0.000 of 41 seconds executing testcases

Failed 1/1 tests, 0.00% were successful.

Failing test(s): main.myisam_crash_before_flush_keys

The log files in var/log may give you some hint of what went wrong.

If you want to report this error, please read first the documentation
at http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html

mysql-test-run: *** ERROR: there were failing test cases

Suggested fix:
The problem is that the myisamchk utility exits in this test with the error code (int)
-1.
On Linux -1 is converted to 0xFF (255), while on on Windows it's converted to
0xFFFFFFFF.
[21 Sep 14:10] Miguel Solorzano
c:\build\mysql-5.1\mysql-test>perl mysql-test-run.pl myisam_crash_before_flush_keys
Found handle.exe version 3.42
Logging: mysql-test-run.pl  myisam_crash_before_flush_keys
090921  9:08:07 [Note] Plugin 'FEDERATED' is disabled.
090921  9:08:07 [Warning] Forcing shutdown of 1 plugins
MySQL Version 5.1.40
Checking supported features...
 - skipping ndbcluster, mysqld not compiled with ndbcluster
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
vardir: c:/build/mysql-5.1/mysql-test/var
Removing old var directory...
Creating var directory 'c:/build/mysql-5.1/mysql-test/var'...
Installing system database...
Using server port 50503

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
Could not open event or process 6148, error: 87
Couldn't open the winpid: 6148 for pid: 6148, try one more time
Could not open event or process 6148, error: 87
Couldn't open the winpid: 6148 for pid: 6148, continue and see what happens...
main.myisam_crash_before_flush_keys      [ fail ]
        Test ended at 2009-09-21 09:09:06

CURRENT_TEST: main.myisam_crash_before_flush_keys
mysqltest: At line 32: command "$MYISAMCHK -cs $MYSQLD_DATADIR/test/t1 2>&1" succeeded -
should have failed with errno 255...

The result from queries just before the failure was:
#
# BUG#41330 - Myisam table open count set to zero before index blocks are written.
#
# Don't test this under valgrind, memory leaks will occur
# Binary must be compiled with debug for crash to occur
SET GLOBAL delay_key_write=ALL;
[21 Sep 14:14] Miguel Solorzano
Thank you for the bug report.
[14 Oct 13:26] 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/86785

3167 Sergey Vojtovich	2009-10-14
      BUG#47455 - The myisam_crash_before_flush_keys test fails on Windows
      
      Simplified and made more determenistic myisam_crash_before_flush_keys
      test.
     @ mysql-test/r/myisam_crash_before_flush_keys.result
        We don't need myisamchk to test this bug fix. CHECK TABLE
        after server restart is enough to ensure that the fix
        works.
     @ mysql-test/t/myisam_crash_before_flush_keys.test
        We don't need myisamchk to test this bug fix. CHECK TABLE
        after server restart is enough to ensure that the fix
        works.
[4 Nov 10:25] Bugs System
Pushed into 5.1.41 (revid:joro@sun.com-20091104092152-qz96bzlf2o1japwc) (version source
revid:kristofer.pettersson@sun.com-20091020070001-gng3hmne2tyuhbxn) (merge vers: 5.1.41)
(pib:13)
[5 Nov 2:38] Paul DuBois
Test case changes. No changelog entry needed.

Setting report to NDI pending push to 5.0.x, 5.5.x, ...
[11 Nov 7:52] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091110093407-rw5g8dys2baqkt67) (version
source revid:alik@sun.com-20091109080109-7dxapd5y5pxlu08w) (merge vers: 6.0.14-alpha)
(pib:13)
[11 Nov 8:00] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091109115615-nuohp02h8mdrz8m2) (version
source revid:alik@sun.com-20091105090244-qlvr0xg4scrhf4k4) (merge vers: 5.5.0-beta)
(pib:13)
[11 Nov 15:25] Paul DuBois
Changes to test cases. No changelog entry needed.