Bug #27049 Race condition in test mysqlbinlog.test
Submitted: 12 Mar 2007 15:08 Modified: 6 Apr 2007 18:07
Reporter: Kristian Nielsen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0-bk. 5.1-bk OS:Any (all U)
Assigned to: Magnus BlÄudd CPU Architecture:Any

[12 Mar 2007 15:08] Kristian Nielsen
Description:
There seems to be a race condition in test case mysqlbinlog.test.

It manifests itself in test output diffs like this:

    load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-1' INTO table t1/*!*/;

instead of this expected output:

    load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-0' INTO table t1/*!*/;

The difference is only a trailing number that create_unique_file() adds to avoid
conflicts with other files.

The exact name of the tmp file does not seem to be of any consequence for what
is meant to be tested, so it seems like a bug in the test case.

It would be interesting to know what causes the tmp file name conflict that
makes create_unique_file() choose a higher number than zero.

How to repeat:
mysql-test-run.pl mysqlbinlog

Timing dependent, seems to happen more often on slower hosts (Valgrind...).

Suggested fix:
Add this to the test case:

--replace_regex /SQL_LOAD_MB-([0-9]+)-[0-9]+/SQL_LOAD_MB-\1-0/
[22 Mar 2007 8:30] Joerg Bruehe
In the release build of 5.0.38, we have 89 (eighty-nine) test runs fail because of this till now, with more test runs still to follow.

Until now, it is only "--ps-protocol" runs which are affected, and it is so many failures (and too many passes of "default" runs) that I do not consider this a pure chance.

It affects all Unix platforms (there are no "--ps-protocol" runs on Windows).

Here is the full diff:
-------------------------------------------------------
*** r/mysqlbinlog.result
--- r/mysqlbinlog.reject
***************
*** 289,311
  SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
  create table t1 (a varchar(64) character set utf8)/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-0' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  SET @@session.collation_database=7/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-7-0' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  SET @@session.collation_database=DEFAULT/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-8-0' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-9-0' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  SET @@session.collation_database=7/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-a-0' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  SET @@session.collation_database=DEFAULT/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-b-0' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  drop table t1/*!*/;
  DELIMITER ;
--- 289,311
  SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
  create table t1 (a varchar(64) character set utf8)/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-1' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  SET @@session.collation_database=7/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-7-1' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  SET @@session.collation_database=DEFAULT/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-8-1' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-9-1' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  SET @@session.collation_database=7/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-a-1' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  SET @@session.collation_database=DEFAULT/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-b-1' INTO table t1/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
! load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-c-1' INTO table t1 character set koi8r/*!*/;
  SET TIMESTAMP=1000000000/*!*/;
  drop table t1/*!*/;
  DELIMITER ;
-------------------------------------------------------
[31 Mar 2007 13:07] 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/23463

ChangeSet@1.2439, 2007-03-31 15:07:48+02:00, msvensson@pilot.blaudden +1 -0
  Bug#27049 Race condition in test mysqlbinlog.test
   - Add --local-load option to avoidthat the load data file requested
     by mysqlbinlog end up in local var/tmp dir and not in system global
     tmpdir
[2 Apr 2007 8:15] 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/23508

ChangeSet@1.2441, 2007-04-02 10:14:45+02:00, msvensson@pilot.blaudden +1 -0
  Bug#27049 Race condition in test mysqlbinlog.test
  Remove the setting of --local-load parameter for mysqlbinlog and leave that to the testcases
  to decide what params to use.
[6 Apr 2007 17:22] Bugs System
Pushed into 5.0.40
[6 Apr 2007 17:25] Bugs System
Pushed into 5.1.18-beta
[6 Apr 2007 18:07] Paul DuBois
Test suite change. No changelog entry needed.
[12 Apr 2007 17:52] Bugs System
Pushed into 5.1.18-beta