From b5c84ff24a47dc56442ff2ff95e77e7a0e0afde6 Mon Sep 17 00:00:00 2001 From: chenheng Date: Thu, 28 Apr 2016 14:50:36 +0800 Subject: [PATCH] HBASE-15714 We are calling checkRow() twice in doMiniBatchMutation() --- .../java/org/apache/hadoop/hbase/regionserver/HRegion.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 1210253..4931d80 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 @@ -3031,7 +3031,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi // If we haven't got any rows in our batch, we should block to get the next one. RowLock rowLock = null; try { - rowLock = getRowLock(mutation.getRow(), true); + rowLock = getRowLockInternal(mutation.getRow(), true); } catch (IOException ioe) { LOG.warn("Failed getting lock, row=" + Bytes.toStringBinary(mutation.getRow()), ioe); } @@ -3429,13 +3429,14 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi checkReadOnly(); // TODO, add check for value length also move this check to the client checkResources(); + checkRow(row, "doCheckAndRowMutate"); startRegionOperation(); try { Get get = new Get(row); checkFamily(family); get.addColumn(family, qualifier); // Lock row - note that doBatchMutate will relock this row if called - RowLock rowLock = getRowLock(get.getRow()); + RowLock rowLock = getRowLockInternal(get.getRow(), false); try { if (mutation != null && this.getCoprocessorHost() != null) { // Call coprocessor. @@ -5119,8 +5120,11 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi */ @Override public RowLock getRowLock(byte[] row, boolean readLock) throws IOException { - // Make sure the row is inside of this region before getting the lock for it. checkRow(row, "row lock"); + return getRowLockInternal(row, readLock); + } + + private RowLock getRowLockInternal(byte[] row, boolean readLock) throws IOException { // create an object to use a a key in the row lock map HashedBytes rowKey = new HashedBytes(row); @@ -6867,7 +6871,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi for (byte[] row : rowsToLock) { // Attempt to lock all involved rows, throw if any lock times out // use a writer lock for mixed reads and writes - acquiredRowLocks.add(getRowLock(row)); + acquiredRowLocks.add(getRowLockInternal(row, false)); } // STEP 3. Region lock lock(this.updatesLock.readLock(), acquiredRowLocks.size() == 0 ? 1 : acquiredRowLocks.size()); @@ -7047,7 +7051,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi startRegionOperation(op); long accumulatedResultSize = 0; List results = returnResults? new ArrayList(mutation.size()): null; - RowLock rowLock = getRowLock(mutation.getRow()); + RowLock rowLock = getRowLockInternal(mutation.getRow(), false); try { lock(this.updatesLock.readLock()); try { -- 1.9.3 (Apple Git-50)