diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 5f59704..2f457d9 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -1447,6 +1447,12 @@ public class HRegion implements HeapSize { // , Writable{ status.setStatus(s); LOG.debug(s); + // sync unflushed WAL changes when deferred log flush is enabled + // see HBASE-8208 for details + if (wal != null && this.htableDescriptor.isDeferredLogFlush()) { + 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. diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java index dd7d37d..a375c8b 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java @@ -1071,6 +1071,11 @@ class FSHLog implements HLog, 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; @@ -1080,11 +1085,6 @@ class FSHLog implements HLog, Syncable { // See HBASE-4387, HBASE-5623, HBASE-7329. tempWriter = this.writer; } - // if the transaction that we are interested in is already - // synced, then return immediately. - if (txid <= this.syncedTillHere) { - return; - } try { long doneUpto; long now = EnvironmentEdgeManager.currentTimeMillis();