accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [3/6] git commit: ACCUMULO-2842 Allow configuration of FSDataOutputStream method used to sync WALs.
Date Fri, 23 May 2014 20:08:16 GMT
ACCUMULO-2842 Allow configuration of FSDataOutputStream method used to sync WALs.

A critical piece of the bigtable design is using write-ahead logs to ensure
recovery after node failure. The append only file structure is meant to provide
a durable log of events so that the correct state can be reconstructed after
a failure when key-values have not been yet serialized to disk.

Hadoop 2 offers two levels of durability in regards to writes to files in HDFS. HFlush
ensures that all others clients who try to read the file you just wrote data to will
see that new data that was written. HSync will ensure that the data you wrote for that
file is actually sent to the underlying disk. As such, HFlush does not provide durability
when the node crashes without that data being flushed to the drive, while HSync does. HSync
does, however, increase the amount of time needed for sync/flush to complete (as hitting disk
consistently is slower than not).


Branch: refs/heads/master
Commit: f654e7faadb9e94e2923087af334a707a4d2c81a
Parents: 74acc30
Author: Josh Elser <>
Authored: Fri May 23 14:40:37 2014 -0400
Committer: Josh Elser <>
Committed: Fri May 23 15:46:55 2014 -0400

 .../java/org/apache/accumulo/core/conf/  |  3 +++
 .../accumulo/server/tabletserver/log/   | 14 +++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ b/core/src/main/java/org/apache/accumulo/core/conf/
index 557ca1f..3d82046 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/
+++ b/core/src/main/java/org/apache/accumulo/core/conf/
@@ -204,6 +204,9 @@ public enum Property {
       "The number of threads for the distributed workq.  These threads are used for copying
failed bulk files."),
   TSERV_WAL_SYNC("tserver.wal.sync", "true", PropertyType.BOOLEAN,
       "Use the SYNC_BLOCK create flag to sync WAL writes to disk. Prevents problems recovering
from sudden system resets."),
+  TSERV_WAL_SYNC_METHOD("tserver.wal.sync.method", "hsync", PropertyType.STRING, "The method
to invoke when sync'ing WALs. HSync will provide " +
+      "resiliency in the face of unexpected power outages, at the cost of speed. If method
is not available, the legacy 'sync' method " +
+      "will be used to ensure backwards compatibility with older Hadoop versions"),
   // properties that are specific to logger server behavior
   LOGGER_PREFIX("logger.", null, PropertyType.PREFIX, "Properties in this category affect
the behavior of the write-ahead logger servers"),
diff --git a/server/src/main/java/org/apache/accumulo/server/tabletserver/log/
index 120c844..01c2448 100644
--- a/server/src/main/java/org/apache/accumulo/server/tabletserver/log/
+++ b/server/src/main/java/org/apache/accumulo/server/tabletserver/log/
@@ -264,13 +264,17 @@ public class DfsLogger {
         logFile = fs.create(logPath, true, fs.getConf().getInt("io.file.buffer.size", 4096),
replication, blockSize);
+      String syncMethod = conf.getConfiguration().get(Property.TSERV_WAL_SYNC_METHOD);
       try {
-        // sync: send data to datanodes
-        sync = logFile.getClass().getMethod("sync");
         try {
-          // hsych: send data to datanodes and sync the data to disk
-          sync = logFile.getClass().getMethod("hsync");
-        } catch (NoSuchMethodException ex) {}
+          // hsync: send data to datanodes and sync the data to disk
+          sync = logFile.getClass().getMethod(syncMethod);
+        } catch (NoSuchMethodException ex) {
+          log.warn("Could not find configured " + syncMethod + " method, trying to fall back
to old Hadoop sync method", ex);
+          // sync: send data to datanodes
+          sync = logFile.getClass().getMethod("sync");
+        }
       } catch (Exception e) {
         throw new RuntimeException(e);

View raw message