You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2017/08/01 19:41:11 UTC

[3/6] hbase git commit: HBASE-18487 Minor fixes in row lock implementation

HBASE-18487 Minor fixes in row lock implementation

Signed-off-by: Andrew Purtell <ap...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2d9dbf27
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2d9dbf27
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2d9dbf27

Branch: refs/heads/branch-1.4
Commit: 2d9dbf27b302208aaa7589f311b472709c1b019d
Parents: 1650356
Author: James Taylor <ja...@apache.org>
Authored: Mon Jul 31 11:42:48 2017 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Tue Aug 1 11:28:31 2017 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/regionserver/HRegion.java     | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2d9dbf27/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
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 427c43b..d6ad5a4 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
@@ -5459,6 +5459,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
       traceScope.getSpan().addTimelineAnnotation("Getting a " + (readLock?"readLock":"writeLock"));
     }
 
+    boolean success = false;
     try {
       // Keep trying until we have a lock or error out.
       // TODO: do we need to add a time component here?
@@ -5500,8 +5501,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
           traceScope.getSpan().addTimelineAnnotation("Failed to get row lock");
         }
         result = null;
-        // Clean up the counts just in case this was the thing keeping the context alive.
-        rowLockContext.cleanUp();
         String message = "Timed out waiting for lock for row: " + rowKey + " in region "
             + getRegionInfo().getEncodedName();
         if (reachDeadlineFirst) {
@@ -5512,6 +5511,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
         }
       }
       rowLockContext.setThreadName(Thread.currentThread().getName());
+      success = true;
       return result;
     } catch (InterruptedException ie) {
       LOG.warn("Thread interrupted waiting for lock on row: " + rowKey);
@@ -5523,6 +5523,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
       Thread.currentThread().interrupt();
       throw iie;
     } finally {
+      // Clean up the counts just in case this was the thing keeping the context alive.
+      if (!success && rowLockContext != null) {
+        rowLockContext.cleanUp();
+      }
       if (traceScope != null) {
         traceScope.close();
       }
@@ -5580,7 +5584,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
       long c = count.decrementAndGet();
       if (c <= 0) {
         synchronized (lock) {
-          if (count.get() <= 0 ){
+          if (count.get() <= 0 && usable.get()){ // Don't attempt to remove row if already removed
             usable.set(false);
             RowLockContext removed = lockedRows.remove(row);
             assert removed == this: "we should never remove a different context";