Bug #38145 .frm file isn't sync'd with sync_frm enabled
Submitted: 15 Jul 2008 16:40 Modified: 11 Feb 2009 3:55
Reporter: Harrison Fisk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.56sp1 OS:Any
Assigned to: Chad MILLER CPU Architecture:Any

[15 Jul 2008 16:40] Harrison Fisk
Description:
When a non-temporary table is created, the FRM file is my_sync'd to disk based on the sync_frm parameter.

View FRM files are created via a different function which does not sync the file to disk.

In the event of a power outage immediately after the view is created, the FRM file contents might not be on disk, and can result in the error:

Incorrect information in file: './db/view.frm'

How to repeat:
1.  Create a view
2.  Immediately do a system crash afterwords
3.  Restart the system
4.  Get the above error

Suggested fix:
The sql_create_definition_file function in parse_file.cc should add a check to the sync_frm system variable and call my_sync based on that.  The check in mysql_create_frm in unireg.cc can be used as a basis:

  if (opt_sync_frm && !(create_info->options & HA_LEX_CREATE_TMP_TABLE) &&
      my_sync(file, MYF(MY_WME)))
    goto err2;
[27 Oct 2008 8:18] Georgi Kodinov
Note that this will not totally close the window described here : it will only make it shorter.
But since the other function is syncing as well I think it's a good idea to be consistent.
[14 Jan 2009 18:20] 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/63262

2713 Chad MILLER	2009-01-14
      Bug#38145: .frm file isn't sync'd with sync_frm enabled
      
      Views weren't sync()d the same way other structures were.
      
      In creating the FRM for views, obey the same rules for variable 
      "sync_frm" as for everything else.
[26 Jan 2009 18:18] Chad MILLER
Queued to 5.0-, 5.1-, and 6.0-bugteam trees.
[3 Feb 2009 9:11] Bugs System
Pushed into 5.0.78 (revid:joro@sun.com-20090203090422-v91rh3gmx2ulhbu9) (version source revid:chad@mysql.com-20090114161511-fqre48cu99zejhji) (merge vers: 5.0.76) (pib:6)
[3 Feb 2009 9:41] Bugs System
Pushed into 5.1.32 (revid:joro@sun.com-20090203090549-gos3v4320vimrzg6) (version source revid:chad@mysql.com-20090126152751-gvq25k7ncd4ls3ut) (merge vers: 5.1.32) (pib:6)
[4 Feb 2009 11:17] Bugs System
Pushed into 6.0.10-alpha (revid:kostja@sun.com-20090204104420-mw1i2u9lum4bxjo6) (version source revid:chad@mysql.com-20090126183534-dfake9zw49l5drms) (merge vers: 6.0.10-alpha) (pib:6)
[11 Feb 2009 3:55] Paul DuBois
Noted in 5.0.72, 5.1.32, 6.0.10 changelogs.

Enabling the sync_frm system variable had no effect on the handling
of .frm files for views.
[17 Feb 2009 14:57] Bugs System
Pushed into 5.1.32-ndb-6.3.23 (revid:tomas.ulin@sun.com-20090217131017-6u8qz1edkjfiobef) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 16:45] Bugs System
Pushed into 5.1.32-ndb-6.4.3 (revid:tomas.ulin@sun.com-20090217134419-5ha6xg4dpedrbmau) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 18:21] Bugs System
Pushed into 5.1.32-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090217134216-5699eq74ws4oxa0j) (version source revid:tomas.ulin@sun.com-20090202111723-1zzwax187rtls913) (merge vers: 5.1.32-ndb-6.2.17) (pib:6)