Bug #6678 CREATE TABLE ... SELECT ... has too weak locking on dest table
Submitted: 17 Nov 2004 10:09 Modified: 1 Jun 2005 3:45
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.0 OS:Any (all)
Assigned to: Sergei Golubchik CPU Architecture:Any

[17 Nov 2004 10:09] Guilhem Bichot
Description:
Two problems:
- one documented in sql_table.cc, known as WL#1484
- even after this race condition is avoided, there remains that there is too weak locking on destination table, at least if InnoDB is used (InnoDB converts TL_WRITE to some weak lock):
CREATE TABLE u TYPE=INNODB SELECT * FROM t; (t must be a big table)
while it runs do in another connection:
INSERT INTO u VALUES(10);
then in binlog you get
INSERT INTO u VALUES(10);
CREATE TABLE u TYPE=INNODB SELECT * FROM t;
which is absurd.
MyISAM is probably safe from this second problem if it uses a table lock (but that should be checked).

How to repeat:
see description.
[27 May 2005 13:28] Sergei Golubchik
fixed in 4.1
[27 May 2005 18:46] 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/internals/25323
[31 May 2005 2:13] Paul DuBois
Noted in 4.1.13 changelog. Entry states that
the problem is for InnoDB.
[31 May 2005 12:15] Heikki Tuuri
Paul,

the bug was both in InnoDB and MyISAM. For InnoDB, it was fixed already in 4.1.11.

Regards,

Heikki
[1 Jun 2005 3:45] Paul DuBois
Heikki, thanks.  I'll make separate entries for InnoDB
and MyISAM in the 4.1.11 and 4.1.13 changelog sections,
respectively.