You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2013/04/06 05:16:47 UTC

svn commit: r1465174 - in /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver: HRegion.java wal/HLog.java

Author: larsh
Date: Sat Apr  6 03:16:47 2013
New Revision: 1465174

URL: http://svn.apache.org/r1465174
Log:
HBASE-8208 In some situations data is not replicated to slaves when deferredLogSync is enabled (Jeffrey Zhong)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1465174&r1=1465173&r2=1465174&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Sat Apr  6 03:16:47 2013
@@ -1589,6 +1589,12 @@ public class HRegion implements HeapSize
     status.setStatus(s);
     LOG.debug(s);
 
+    // sync unflushed WAL changes when deferred log sync is enabled
+    // see HBASE-8208 for details
+    if (wal != null && isDeferredLogSyncEnabled()) {
+      wal.sync();
+    }
+
     // wait for all in-progress transactions to commit to HLog before
     // we can start the flush. This prevents
     // uncommitted transactions from being written into HFiles.
@@ -5829,13 +5835,19 @@ public class HRegion implements HeapSize
    * @throws IOException If anything goes wrong with DFS
    */
   private void syncOrDefer(long txid) throws IOException {
-    if (this.regionInfo.isMetaRegion() ||
-      !this.htableDescriptor.isDeferredLogFlush() || this.deferredLogSyncDisabled) {
+    if (this.getRegionInfo().isMetaRegion() || !isDeferredLogSyncEnabled()) {
       this.log.sync(txid);
     }
   }
 
   /**
+   * check if current region is deferred sync enabled.
+   */
+  private boolean isDeferredLogSyncEnabled() {
+    return (this.htableDescriptor.isDeferredLogFlush() && !this.deferredLogSyncDisabled);
+  }
+
+  /**
    * A mocked list implementaion - discards all updates.
    */
   private static final List<KeyValue> MOCKED_LIST = new AbstractList<KeyValue>() {

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java?rev=1465174&r1=1465173&r2=1465174&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java Sat Apr  6 03:16:47 2013
@@ -1321,16 +1321,16 @@ public class HLog implements Syncable {
 
   // sync all transactions upto the specified txid
   private void syncer(long txid) throws IOException {
+    // if the transaction that we are interested in is already
+    // synced, then return immediately.
+    if (txid <= this.syncedTillHere) {
+      return;
+    }
     Writer tempWriter;
     synchronized (this.updateLock) {
       if (this.closed) return;
       tempWriter = this.writer; // guaranteed non-null
     }
-    // if the transaction that we are interested in is already 
-    // synced, then return immediately.
-    if (txid <= this.syncedTillHere) {
-      return;
-    }
     try {
       long doneUpto;
       long now = System.currentTimeMillis();