Bug #34638 Handling of O_DIRECT and O_SYNC in ndb
Submitted: 18 Feb 2008 14:05 Modified: 21 Oct 2008 22:56
Reporter: Christoffer Hall Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Disk Data Severity:S3 (Non-critical)
Version:* OS:Any
Assigned to: Stewart Smith CPU Architecture:Any

[18 Feb 2008 14:05] Christoffer Hall
Description:
The current code for checking which flags to open a file with in ndb (mysql-6.0-ndb tree). The condition in the second if condition is only checked if OM_DIRECT is set on platforms where O_DIRECT is undefined.

###################################################
if (flags & FsOpenReq::OM_DIRECT)
#ifdef O_DIRECT
{
    new_flags |= O_DIRECT;
}
#endif

if ((flags & FsOpenReq::OM_SYNC) && ! (flags & FsOpenReq::OM_INIT))
{
#ifdef O_SYNC
    new_flags |= O_SYNC;
#endif
}
###################################################

Setting OM_SYNC on non-linux where O_DIRECT is undef depens on OM_DIRECT being set.

How to repeat:
I have not produced the problem while running but just reading the code.

Suggested fix:
Change that brackets such that the ifdef for O_DIRECT is moved inside the brackets. Like this:

if (flags & FsOpenReq::OM_DIRECT)
{

#ifdef O_DIRECT
    new_flags |= O_DIRECT;
#endif

}
[18 Feb 2008 14:19] Stewart Smith
Yep, it's a bug. will patch tomorrow.
[20 Feb 2008 12:18] Stewart Smith
patch for 5.1

Attachment: bug34638.patch (text/x-patch), 847 bytes.

[20 Feb 2008 12:19] Stewart Smith
For telco, this will be in PosixAsyncFile.cpp, but the same patch.
[21 Oct 2008 12:41] 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/56682

2703 Jonas Oreland	2008-10-21
      ndb - bug#34638 - O_SYNC incorrectly got disabled if os didnt have O_DIRECT (solaris)
[21 Oct 2008 12:41] 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/56683

2703 Jonas Oreland	2008-10-21
      ndb - bug#34638 - O_SYNC incorrectly got disabled if os didnt have O_DIRECT (solaris)
[21 Oct 2008 15:43] Jonas Oreland
pushed int 62, 63 and 64
[21 Oct 2008 15:43] Jonas Oreland
6.2.17 and 6.3.19
[21 Oct 2008 22:56] Jon Stephens
Documented bugfix in the NDB-6.2.17 and NDB-6.3.19 changelogs as follows:

        O_SYNC was incorrectly disabled on platforms that do not support
        O_DIRECT. This issue was noted on Solaris but could have affected other
        platforms not having O_DIRECT capability.
[24 Oct 2008 1:18] Bugs System
Pushed into 5.1.28-ndb-6.2.17  (revid:jonas@mysql.com-20081021124536-y9bv24q0go4cf1m2) (version source revid:jonas@mysql.com-20081021124536-y9bv24q0go4cf1m2) (pib:5)
[24 Oct 2008 1:18] Bugs System
Pushed into 5.1.28-ndb-6.3.19  (revid:jonas@mysql.com-20081021124536-y9bv24q0go4cf1m2) (version source revid:jonas@mysql.com-20081021131310-ypz6rb6glgt74zeq) (pib:5)
[24 Oct 2008 1:18] Bugs System
Pushed into 5.1.28-ndb-6.4.0  (revid:jonas@mysql.com-20081021124536-y9bv24q0go4cf1m2) (version source revid:jonas@mysql.com-20081021132059-7qmkuuv9k5c313gp) (pib:5)
[12 Dec 2008 23:26] Bugs System
Pushed into 6.0.9-alpha  (revid:jonas@mysql.com-20081021124536-y9bv24q0go4cf1m2) (version source revid:tomas.ulin@sun.com-20081209185954-9svcixh2p5hsfi6w) (pib:5)