Index: hbase-server/src/main/java/org/apache/hadoop/hbase/client/Mutation.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/client/Mutation.java (revision 1446978) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/client/Mutation.java (working copy) @@ -37,6 +37,7 @@ public abstract class Mutation extends OperationWithAttributes implements Row { // Attribute used in Mutations to indicate the originating cluster. private static final String CLUSTER_ID_ATTR = "_c.id_"; + private static final String DEFER_FLUSH_ATTR = "_d.f_"; protected byte [] row = null; protected long ts = HConstants.LATEST_TIMESTAMP; @@ -128,6 +129,20 @@ } /** + * Indicate for this mutation we can defer the log flush. + * @param defer + */ + public void setDeferWALFlush(boolean defer) { + setAttribute(DEFER_FLUSH_ATTR, Bytes.toBytes(defer)); + } + + /** Get deferred flush setting */ + public boolean getDeferWALFlush() { + byte[] attr = getAttribute(DEFER_FLUSH_ATTR); + return attr == null ? false : Bytes.toBoolean(attr); + } + + /** * Method for retrieving the put's familyMap * @return familyMap */ Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/BaseRowProcessor.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/BaseRowProcessor.java (revision 1446978) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/BaseRowProcessor.java (working copy) @@ -48,4 +48,9 @@ public String getName() { return this.getClass().getSimpleName().toLowerCase(); } + + @Override + public boolean shouldSyncToWAL() { + return true; + } } Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 1446978) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -2208,6 +2208,7 @@ // ------------------------------------ // STEP 4. Build WAL edit // ---------------------------------- + boolean shouldSyncWal = false; for (int i = firstIndex; i < lastIndexExclusive; i++) { // Skip puts that were determined to be invalid during preprocessing if (batchOp.retCodeDetails[i].getOperationStatusCode() @@ -2222,6 +2223,8 @@ recordPutWithoutWal(m.getFamilyMap()); } continue; + } else if (!shouldSyncWal) { + shouldSyncWal |= !m.getDeferWALFlush(); } // Add WAL edits by CP WALEdit fromCP = batchOp.walEditsFromCoprocessors[i]; @@ -2258,7 +2261,7 @@ // STEP 7. Sync wal. // ------------------------- if (walEdit.size() > 0) { - syncOrDefer(txid); + syncOrDefer(txid, shouldSyncWal); } walSyncSuccessful = true; // ------------------------------------------------------------------ @@ -4617,7 +4620,7 @@ } // 10. Sync edit log if (txid != 0) { - syncOrDefer(txid); + syncOrDefer(txid, processor.shouldSyncToWAL()); } walSyncSuccessful = true; } @@ -4856,7 +4859,7 @@ releaseRowLock(lid); } if (writeToWAL) { - syncOrDefer(txid); // sync the transaction log outside the rowlock + syncOrDefer(txid, !append.getDeferWALFlush()); // sync the transaction log outside the rowlock } } finally { if (w != null) { @@ -4996,7 +4999,7 @@ releaseRowLock(lid); } if (writeToWAL) { - syncOrDefer(txid); // sync the transaction log outside the rowlock + syncOrDefer(txid, true); // sync the transaction log outside the rowlock } } finally { if (w != null) { @@ -5422,11 +5425,12 @@ * Calls sync with the given transaction ID if the region's table is not * deferring it. * @param txid should sync up to which transaction + * @param syncRequested true if the caller requested a sync * @throws IOException If anything goes wrong with DFS */ - private void syncOrDefer(long txid) throws IOException { + private void syncOrDefer(long txid, boolean syncRequested) throws IOException { if (this.regionInfo.isMetaRegion() || - !this.htableDescriptor.isDeferredLogFlush()) { + (!this.htableDescriptor.isDeferredLogFlush() && syncRequested)) { this.log.sync(txid); } } Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MultiRowMutationProcessor.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MultiRowMutationProcessor.java (revision 1446978) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MultiRowMutationProcessor.java (working copy) @@ -140,4 +140,15 @@ public void initialize(MultiRowMutationProcessorRequest msg) { //nothing } + + @Override + public boolean shouldSyncToWAL() { + // return true when at least one mutation requested a WAL flush (default) + for (Mutation m : mutations) { + if (m.getWriteToWAL() && !m.getDeferWALFlush()) { + return true; + } + } + return false; + } } Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowProcessor.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowProcessor.java (revision 1446978) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowProcessor.java (working copy) @@ -133,4 +133,9 @@ * @throws IOException */ void initialize(S msg) throws IOException; + + /** + * @return true of the resulting edit should sync'ed to the WAL, false if not. + */ + boolean shouldSyncToWAL(); } \ No newline at end of file