Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 1374470) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -2214,10 +2214,8 @@ // ------------------------- // STEP 7. Sync wal. // ------------------------- - if (walEdit.size() > 0 && - (this.regionInfo.isMetaRegion() || - !this.htableDescriptor.isDeferredLogFlush())) { - this.log.sync(txid); + if (walEdit.size() > 0) { + syncOrDefer(txid); } walSyncSuccessful = true; // ------------------------------------------------------------------ @@ -4306,10 +4304,8 @@ } // 9. sync WAL if required - if (walEdit.size() > 0 && - (this.regionInfo.isMetaRegion() || - !this.htableDescriptor.isDeferredLogFlush())) { - this.log.sync(txid); + if (walEdit.size() > 0) { + syncOrDefer(txid); } walSyncSuccessful = true; @@ -4507,7 +4503,7 @@ releaseRowLock(lid); } if (writeToWAL) { - this.log.sync(txid); // sync the transaction log outside the rowlock + syncOrDefer(txid); // sync the transaction log outside the rowlock } } finally { closeRegionOperation(); @@ -4628,7 +4624,7 @@ releaseRowLock(lid); } if (writeToWAL) { - this.log.sync(txid); // sync the transaction log outside the rowlock + syncOrDefer(txid); // sync the transaction log outside the rowlock } } finally { closeRegionOperation(); @@ -4725,7 +4721,7 @@ releaseRowLock(lid); } if (writeToWAL) { - this.log.sync(txid); // sync the transaction log outside the rowlock + syncOrDefer(txid); // sync the transaction log outside the rowlock } } finally { closeRegionOperation(); @@ -5138,6 +5134,19 @@ } /** + * Calls sync with the given transaction ID if the region's table is not + * deferring it. + * @param txid should sync up to which transaction + * @throws IOException If anything goes wrong with DFS + */ + private void syncOrDefer(long txid) throws IOException { + if (this.regionInfo.isMetaRegion() || + !this.htableDescriptor.isDeferredLogFlush()) { + this.log.sync(txid); + } + } + + /** * A mocked list implementaion - discards all updates. */ private static final List MOCKED_LIST = new AbstractList() {