Bug #22310 dead/deceptive code in FileLogHandler::writeFooter() and File_class::flush
Submitted: 13 Sep 2006 13:22 Modified: 3 Jan 2007 2:57
Reporter: Stewart Smith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:5.0,5.1 OS:
Assigned to: Stewart Smith CPU Architecture:Any

[13 Sep 2006 13:22] Stewart Smith
Description:
In FileLogHandler::writeFooter(),

00128   // Needed on Cello since writes to the flash disk does not happen until 
00129   // we flush and fsync.
00130   m_pLogFile->flush();

00172 int
00173 File_class::flush() const
00174 {
00175 #if defined NDB_OSE || defined NDB_SOFTOSE
00176   ::fflush(m_file);
00177   return ::fsync(::fileno(m_file));
00178 #else
00179   return 0;
00180 #endif
00181 }

So things are rather deceiving here...

There can be two possible intentions for this code:
1) implement periodic flushing of dirty pages to disk on Cello.
2) log messages should be persistent on disk on system failure.

2 isn't possible with a text log file and 1 is old and confusing (especially if another user of File_class were to come along and try to flush() thinking it put things on disk).

How to repeat:
not repeat - dead code

Suggested fix:
remove dead code so to avoid confusing coders in the future.
[27 Oct 2006 8:08] 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/14458

ChangeSet@1.2275, 2006-10-27 18:08:08+10:00, stewart@willster.(none) +2 -0
  BUG#22310 dead/deceptive code in FileLogHandler::writeFooter() and File_class::flush
  
  make the File_class::flush() method actually flush the stdio buffers.
[29 Dec 2006 0:35] Stewart Smith
5.0 smaller patch, just correcting the functionality (slight possibility to cause real-world issue, probably not) pushed to 5.0-ndb tree
[29 Dec 2006 8:19] Stewart Smith
pushed to 5.0.34
[3 Jan 2007 2:57] Jon Stephens
Does not appear to impact end-user functionality; closed without further action.