Bug #35788 A few tests fail due to concurrent inserts
Submitted: 3 Apr 2008 8:33 Modified: 6 May 2008 18:32
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:Tests: Server Severity:S7 (Test Cases)
Version:5.1-bk OS:Any
Assigned to: Davi Arnaut CPU Architecture:Any

[3 Apr 2008 8:33] Alexander Nozdrin
Description:
A few tests have race condition due to the nature of
"concurrent inserts" feature. The problem is that when concurrent
insert is allowed, a client can receive Ok before the data is actually
int the table. Thus, consequent read in the separate connection will
not get the data. That results in sporadic failures.

The following tests suffer from this problem:
  - main.client_xml
  - main.federated
  - main.federated_bug_25714

I suggest that would be high-priority bug because
  - it makes our trees red, which is terrible;
  - it's pretty easy to fix.

How to repeat:
1. See pushbuild page.

2. In order to reproduce the bug, insert a sleep into dispatch_command()
in sql_parse.cc:

At the end of the function there is the following code:
  net_end_statement(thd);
  query_cache_end_of_result(thd);

  thd->proc_info= "closing tables";
  /* Free tables */
  close_thread_tables(thd);

Insert a sleep as follows:
  net_end_statement(thd);
  if (thd->lex->sql_command == SQLCOM_INSERT)
    sleep(1);
  ...

Suggested fix:
SET CONCURRENT_INSERT = 1
[3 Apr 2008 8:35] Alexander Nozdrin
Grr... Suggested fix is obviously:

SET CONCURRENT_INSERT = 0;

Sorry for the mess.
[7 Apr 2008 14:24] Susanne Ebrecht
Verified as described.
[30 Apr 2008 13:28] 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/46225

ChangeSet@1.2573, 2008-04-30 10:28:19-03:00, davi@mysql.com +6 -0
  Bug#35788 A few tests fail due to concurrent inserts
  
  The problem is that since MyISAM's concurrent_insert is on by
  default some concurrent SELECT statements might not see changes
  made by INSERT statements in other connections, even if the
  INSERT statement has returned.
  
  The solution is to disable concurrent_insert so that INSERT
  statements returns after the data is actually visible to other
  statements.
[30 Apr 2008 16:03] Davi Arnaut
Queued to 5.1-bugteam
[6 May 2008 0:29] Bugs System
Pushed into 5.1.25-rc
[6 May 2008 0:33] Bugs System
Pushed into 6.0.6-alpha
[6 May 2008 18:32] Paul DuBois
Test suite changes. No changelog entry needed.