hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1376489 - /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Date Thu, 23 Aug 2012 13:48:39 GMT
Author: tedyu
Date: Thu Aug 23 13:48:39 2012
New Revision: 1376489

URL: http://svn.apache.org/viewvc?rev=1376489&view=rev
Log:
HBASE-5329 addRowLock() may allocate duplicate lock id, causing the client to be blocked (Ian
Varley)


Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1376489&r1=1376488&r2=1376489&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Thu Aug 23 13:48:39 2012
@@ -51,6 +51,7 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -320,7 +321,7 @@ public class  HRegionServer implements C
   // Port we put up the webui on.
   protected int webuiport = -1;
 
-  Map<String, Integer> rowlocks = new ConcurrentHashMap<String, Integer>();
+  ConcurrentMap<String, Integer> rowlocks = new ConcurrentHashMap<String, Integer>();
 
   // A state before we go into stopped state.  At this stage we're closing user
   // space regions.
@@ -2753,11 +2754,13 @@ public class  HRegionServer implements C
     return this.fsOk;
   }
 
-  protected long addRowLock(Integer r, HRegion region)
-      throws LeaseStillHeldException {
-    long lockId = nextLong();
-    String lockName = String.valueOf(lockId);
-    rowlocks.put(lockName, r);
+  protected long addRowLock(Integer r, HRegion region) throws LeaseStillHeldException {
+    String lockName = null;
+    long lockId;
+    do {
+      lockId = nextLong();
+      lockName = String.valueOf(lockId);
+    } while (rowlocks.putIfAbsent(lockName, r) != null);
     this.leases.createLease(lockName, this.rowLockLeaseTimeoutPeriod, new RowLockListener(lockName,
         region));
     return lockId;



Mime
View raw message