From: <tho...@us...> - 2013-11-08 19:43:04
|
Revision: 7516 http://bigdata.svn.sourceforge.net/bigdata/?rev=7516&view=rev Author: thompsonbry Date: 2013-11-08 19:42:57 +0000 (Fri, 08 Nov 2013) Log Message: ----------- Bug fix for "logically empty HALog" due to failure to flush the file when writing the closing root block on the HALog. Also added doubleSync parameter that is set from com.bigdata.journal.Options.DOUBLE_SYNC and now also controls whether we double sync the HALog (before and after writing the closing root block). See #679 (Logically empty HALog) See #738 (Longevity testing) See #724 (Sudden kill tests) Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogWriter.java branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HALogNexus.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogWriter.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogWriter.java 2013-11-08 18:08:21 UTC (rev 7515) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogWriter.java 2013-11-08 19:42:57 UTC (rev 7516) @@ -110,6 +110,21 @@ /** HA log directory. */ private final File m_haLogDir; + /** + * When <code>true</code>, the HALog is flushed to the disk before the + * closing root block is written and then once again after the closing root + * block is written. When <code>false</code>, the HALog is flushed only + * once, after the closing root block is written. + * + * @see <a + * href="http://sourceforge.net/apps/trac/bigdata/ticket/738#comment:13" + * >Longevity and stress test protocol for HA QA </a> + * + * @see <a href="http://sourceforge.net/apps/trac/bigdata/ticket/679"> + * HAJournalServer can not restart due to logically empty log file </a> + */ + private final boolean doubleSync; + /** * The root block of the leader at the start of the current write set. */ @@ -250,13 +265,45 @@ } - public HALogWriter(final File logDir) { + /** + * + * @param logDir + * The directory in which the HALog files reside. + * @param doubleSync + * When <code>true</code>, the HALog is flushed to the disk + * before the closing root block is written and then once again + * after the closing root block is written. When + * <code>false</code>, the HALog is flushed only once, after the + * closing root block is written. + * + * @see <a + * href="http://sourceforge.net/apps/trac/bigdata/ticket/738#comment:13" + * >Longevity and stress test protocol for HA QA </a> + * + * @see <a href="http://sourceforge.net/apps/trac/bigdata/ticket/679"> + * HAJournalServer can not restart due to logically empty log file </a> + */ + public HALogWriter(final File logDir, final boolean doubleSync) { m_haLogDir = logDir; + + this.doubleSync = doubleSync; } /** + * + * @param logDir + * + * @deprecated This is ony used by the test suite. + */ + HALogWriter(final File logDir) { + + this(logDir, true/* doubleSync */); + + } + + /** * Open an HA log file for the write set starting with the given root block. * * @param rootBlock @@ -430,7 +477,26 @@ } - flush(); // current streamed data + if (doubleSync) { + /** + * Flush the HALog records to the disk. + * + * Note: This is intended to avoid the possibility that the + * writes might be reordered such that closing root block was + * written to the disk before the HALog records were flushed to + * the disk. However, better durability guarantees are provided + * by battery backup on the disk controller and similar such + * nicities. If such techniques are used, you can disable the + * doubleSync option and still have a guarantee that writes on + * the HALog are durable and respect the applications ordering + * of write requests (in terms of restart safe visibility). + * + * @see <a + * href="http://sourceforge.net/apps/trac/bigdata/ticket/738#comment:13" + * >Longevity and stress test protocol for HA QA </a> + */ + flush(); + } /* * The closing root block is written into which ever slot @@ -442,8 +508,14 @@ */ writeRootBlock(rootBlock.isRootBlock0(), rootBlock); - // // The closing root block is always in slot 1. - // writeRootBlock(false/* isRootBlock0 */, rootBlock); + /** + * Flush the backing channel. + * + * @see <a + * href="http://sourceforge.net/apps/trac/bigdata/ticket/738#comment:13" + * >Longevity and stress test protocol for HA QA </a> + */ + flush(); m_state.committed(); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HALogNexus.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HALogNexus.java 2013-11-08 18:08:21 UTC (rev 7515) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HALogNexus.java 2013-11-08 19:42:57 UTC (rev 7516) @@ -236,7 +236,7 @@ } // Set up the HA log writer. - haLogWriter = new HALogWriter(haLogDir); + haLogWriter = new HALogWriter(haLogDir, journal.isDoubleSync()); haLogIndex = HALogIndex.createTransient(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |