Bug #46591 .frm file isn't sync'd with sync_frm enabled for CREATE TABLE...LIKE...
Submitted: 6 Aug 2009 21:39 Modified: 19 Dec 2009 0:00
Reporter: Harrison Fisk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.0.76 OS:Any
Assigned to: Satya B CPU Architecture:Any
Tags: CREATE TABLE LIKE, sync_frm

[6 Aug 2009 21:39] Harrison Fisk
Description:
If you use the CREATE TABLE ... LIKE ...; then the newly created table does not have the FRM file fsync'd properly.

CREATE TABLE...LIKE... uses a different code path than normal CREATE TABLE so additional handling for sync_frm needs to be implemented.

How to repeat:
Run mysqld and use strace (or truss) and run the two following statements:

1.  CREATE TABLE t1 (id int);
2.  CREATE TABLE t2 LIKE t1;

Notice that fdatasync or fsync is never called for the second one.

Suggested fix:
Add the sync code to mysql_create_like_table().  

For examples, see http://lists.mysql.com/commits/63262 or Bug #38145.
[20 Aug 2009 11:00] 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/81156

2790 Satya B	2009-08-20
      Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                          CREATE TABLE...LIKE...
      
      The mysql server option 'sync_frm' is ignored when table is created with syntax
      CREATE TABLE .. LIKE.. 
      
      Fixed by calling my_sync() method after the copying of frm file for destination
      table is done.
      
      Note: TestCase is not attached and can be tested manually using debugger.
      modified:
        sql/sql_table.cc
[27 Aug 2009 9:23] 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/81684

2795 Satya B	2009-08-27
      Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                          CREATE TABLE...LIKE...
            
      The mysql server option 'sync_frm' is ignored when table is created with 
      syntax CREATE TABLE .. LIKE.. 
            
      Fixed by adding the MY_SYNC flag and calling my_sync() from my_copy() when
      the flag is set.
      
      In mysql_create_table(), when the 'sync_frm' is set, MY_SYNC flag is passed 
      to my_copy().
            
      Note: TestCase is not attached and can be tested manually using debugger.
      modified:
        client/Makefile.am
        include/my_sys.h
        mysys/my_copy.c
        sql/sql_table.cc
[27 Aug 2009 12:18] 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/81718

2795 Satya B	2009-08-27
      Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                          CREATE TABLE...LIKE...
            
      The mysql server option 'sync_frm' is ignored when table is created with 
      syntax CREATE TABLE .. LIKE.. 
            
      Fixed by adding the MY_SYNC flag and calling my_sync() from my_copy() when
      the flag is set
      
      In mysql_create_table(), when the 'sync_frm' is set, MY_SYNC flag is passed 
      to my_copy 
            
      Note: TestCase is not attached and can be tested manually using debugger.
      modified:
        client/Makefile.am
        include/my_sys.h
        mysys/my_copy.c
        sql/sql_table.cc
[31 Aug 2009 8:59] 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/81988

2794 Satya B	2009-08-31
      Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                          CREATE TABLE...LIKE...
            
      The mysql server option 'sync_frm' is ignored when table is created with 
      syntax CREATE TABLE .. LIKE.. 
            
      Fixed by adding the MY_SYNC flag and calling my_sync() from my_copy() when
      the flag is set
      
      In mysql_create_table(), when the 'sync_frm' is set, MY_SYNC flag is passed 
      to my_copy 
            
      Note: TestCase is not attached and can be tested manually using debugger.
      modified:
        client/Makefile.am
        include/my_sys.h
        mysys/my_copy.c
        sql/sql_table.cc
[3 Sep 2009 9:55] 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/82311

2804 Satya B	2009-09-03
      Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                          CREATE TABLE...LIKE...
            
      The mysql server option 'sync_frm' is ignored when table is created with 
      syntax CREATE TABLE .. LIKE.. 
            
      Fixed by adding the MY_SYNC flag and calling my_sync() from my_copy() when
      the flag is set.
      
      In mysql_create_table(), when the 'sync_frm' is set, MY_SYNC flag is passed 
      to my_copy(). 
            
      Note: TestCase is not attached and can be tested manually using debugger.
     @ client/Makefile.am
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                    CREATE TABLE...LIKE...
            
        add my_sync to sources as it is used in my_copy() method
     @ include/my_sys.h
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                    CREATE TABLE...LIKE...
            
        MY_SYNC flag is added to call my_sync() method
     @ mysys/my_copy.c
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                    CREATE TABLE...LIKE...
            
        my_sync() is method is called when MY_SYNC is set in my_copy()
     @ sql/sql_table.cc
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                    CREATE TABLE...LIKE...
            
        Fixed mysql_create_like_table() to call my_sync() when opt_sync_frm variable
        is set
[3 Sep 2009 10:50] 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/82318

2804 Satya B	2009-09-03
      Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                          CREATE TABLE...LIKE...
            
      The mysql server option 'sync_frm' is ignored when table is created with 
      syntax CREATE TABLE .. LIKE.. 
            
      Fixed by adding the MY_SYNC flag and calling my_sync() from my_copy() when
      the flag is set.
      
      In mysql_create_table(), when the 'sync_frm' is set, MY_SYNC flag is passed 
      to my_copy(). 
            
      Note: TestCase is not attached and can be tested manually using debugger.
     @ client/Makefile.am
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                    CREATE TABLE...LIKE...
            
        add my_sync to sources as it is used in my_copy() method
     @ include/my_sys.h
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                    CREATE TABLE...LIKE...
            
        MY_SYNC flag is added to call my_sync() method
     @ mysys/my_copy.c
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                    CREATE TABLE...LIKE...
            
        my_sync() is method is called when MY_SYNC is set in my_copy()
     @ sql/sql_table.cc
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
                    CREATE TABLE...LIKE...
            
        Fixed mysql_create_like_table() to call my_sync() when opt_sync_frm variable
        is set
[4 Sep 2009 5:52] 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/82399

2806 Satya B	2009-09-04
      Addition to Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled
                                      for CREATE TABLE...LIKE...
      
      Add my_sync.c to mysqltest sources list in CMakeLists.txt
     @ client/CMakeLists.txt
        BUG#46591 - .frm file isn't sync'd with sync_frm enabled
                    for CREATE TABLE...LIKE...
        
        Add my_sync.c to mysqltest sources list
[4 Sep 2009 5:58] 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/82400

3109 Satya B	2009-09-04 [merge]
      NULL merge the additional fix for BUG#46591 from mysql-5.0-bugteam to mysql-5.1-bugteam
[14 Sep 2009 16:06] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (version source revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (merge vers: 5.4.4-alpha) (pib:11)
[16 Sep 2009 0:47] Paul Dubois
Noted in 5.4.4 changelog.

The server ignored the setting of sync_frm for CREATE TABLE ... LIKE.

Setting report to NDI pending push into 5.1.x.
[6 Oct 2009 8:57] Bugs System
Pushed into 5.0.87 (revid:joro@sun.com-20091006073202-rj21ggvo2gw032ks) (version source revid:satya.bn@sun.com-20090904054944-t64i7ax2wso2h2tn) (merge vers: 5.0.86) (pib:11)
[6 Oct 2009 9:01] Bugs System
Pushed into 5.1.40 (revid:joro@sun.com-20091006073316-lea2cpijh9r6on7c) (version source revid:mikael@mysql.com-20090907102257-fflwgm6rp5m5kmfw) (merge vers: 5.1.39) (pib:11)
[6 Oct 2009 23:24] Paul Dubois
Noted in 5.0.87, 5.1.40 changelogs.
[7 Oct 2009 0:42] Paul Dubois
The 5.4 fix has also been pushed into 5.4.3.
[18 Dec 2009 10:35] Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:51] Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 11:06] Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:20] Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)