diff --git src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 47c178e..5cdd90d 100644 --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -1589,6 +1589,12 @@ public class HRegion implements HeapSize { // , Writable{ 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 { // , Writable{ * @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 MOCKED_LIST = new AbstractList() { diff --git src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java index 91baba4..8c4df44 100644 --- src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java +++ src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java @@ -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();