diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 74539c8..74e4c2b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -3126,7 +3126,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi } // ------------------------- - // STEP 4. Append the final edit to WAL. Do not sync wal. + // STEP 4. Append the final edit to WAL. // ------------------------- Mutation mutation = batchOp.getMutation(firstIndex); if (isInReplay) { @@ -3146,6 +3146,14 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi } txid = this.wal.append(this.htableDescriptor, this.getRegionInfo(), walKey, walEdit, true); } + + // ------------------------- + // STEP 7. Sync wal. + // ------------------------- + if (txid != 0) { + syncOrDefer(txid, durability); + } + // ------------------------------------ // Acquire the latest mvcc number // ---------------------------------- @@ -3179,6 +3187,20 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi addedSize += applyFamilyMapToMemstore(familyMaps[i], mvccNum, isInReplay); } + // ------------------------------------------------------------------ + // STEP 8. Advance mvcc. This will make this put visible to scanners and getters. + // ------------------------------------------------------------------ + if (writeEntry != null) { + mvcc.completeAndWait(writeEntry); + writeEntry = null; + } else if (isInReplay) { + // ensure that the sequence id of the region is at least as big as orig log seq id + mvcc.advanceTo(mvccNum); + } + + // REORDER.. SYNC FIRST, THEN LET GO OF ROW LOCKS AFTER WAITING ON MVCC. + + // ------------------------------- // STEP 6. Release row locks, etc. // ------------------------------- @@ -3188,13 +3210,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi } releaseRowLocks(acquiredRowLocks); - // ------------------------- - // STEP 7. Sync wal. - // ------------------------- - if (txid != 0) { - syncOrDefer(txid, durability); - } - doRollBackMemstore = false; // calling the post CP hook for batch mutation if (!isInReplay && coprocessorHost != null) { @@ -3204,17 +3219,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi coprocessorHost.postBatchMutate(miniBatchOp); } - // ------------------------------------------------------------------ - // STEP 8. Advance mvcc. This will make this put visible to scanners and getters. - // ------------------------------------------------------------------ - if (writeEntry != null) { - mvcc.completeAndWait(writeEntry); - writeEntry = null; - } else if (isInReplay) { - // ensure that the sequence id of the region is at least as big as orig log seq id - mvcc.advanceTo(mvccNum); - } - for (int i = firstIndex; i < lastIndexExclusive; i ++) { if (batchOp.retCodeDetails[i] == OperationStatus.NOT_RUN) { batchOp.retCodeDetails[i] = OperationStatus.SUCCESS;