hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r922161 - in /hadoop/hbase/branches/0.20: CHANGES.txt src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Date Fri, 12 Mar 2010 07:18:26 GMT
Author: stack
Date: Fri Mar 12 07:18:25 2010
New Revision: 922161

URL: http://svn.apache.org/viewvc?rev=922161&view=rev
Log:
HBASE-2023 Client sync block can cause 1 thread of a multi-threaded client to block all others

Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=922161&r1=922160&r2=922161&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Fri Mar 12 07:18:25 2010
@@ -39,6 +39,8 @@ Release 0.20.4 - Unreleased
                seed over multiple testing threads (Tatsuya Kawano via Stack)
    HBASE-2287  TypeError in shell (Alexey Kovyrin via Stack)
    HBASE-2311  Not having assertions enabled causes index contrib tests to fail
+   HBASE-2034  Client sync block can cause 1 thread of a multi-threaded client
+               to block all others (Karthik Ranganathan via Stack)
 
   IMPROVEMENTS
    HBASE-2180  Bad read performance from synchronizing hfile.fddatainputstream

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=922161&r1=922160&r2=922161&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
(original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Fri Mar 12 07:18:25 2010
@@ -627,16 +627,12 @@ public class HConnectionManager implemen
           return this.rootRegionLocation;
         }        
       } else if (Bytes.equals(tableName, META_TABLE_NAME)) {
-        synchronized (metaRegionLock) {
-          // This block guards against two threads trying to load the meta 
-          // region at the same time. The first will load the meta region and
-          // the second will use the value that the first one found.
-          return locateRegionInMeta(ROOT_TABLE_NAME, tableName, row, useCache);
-        }
+        return locateRegionInMeta(ROOT_TABLE_NAME, tableName, row, useCache,
+                                  metaRegionLock);
       } else {
-        synchronized(userRegionLock){
-          return locateRegionInMeta(META_TABLE_NAME, tableName, row, useCache);
-        }
+        // Region not in the cache - have to go to the meta RS
+        return locateRegionInMeta(META_TABLE_NAME, tableName, row, useCache,
+                                  userRegionLock);
       }
     }
 
@@ -645,18 +641,17 @@ public class HConnectionManager implemen
       * info that contains the table and row we're seeking.
       */
     private HRegionLocation locateRegionInMeta(final byte [] parentTable,
-      final byte [] tableName, final byte [] row, boolean useCache)
+      final byte [] tableName, final byte [] row, boolean useCache,
+      Object regionLockObject)
     throws IOException {
       HRegionLocation location = null;
-      // If supposed to be using the cache, then check it for a possible hit.
-      // Otherwise, delete any existing cached location so it won't interfere.
+      // If we are supposed to be using the cache, look in the cache to see if
+      // we already have the region.
       if (useCache) {
         location = getCachedLocation(tableName, row);
         if (location != null) {
           return location;
         }
-      } else {
-        deleteCachedLocation(tableName, row);
       }
       
       // build the key of the meta region we should be looking for.
@@ -676,10 +671,29 @@ public class HConnectionManager implemen
           HRegionInterface server =
             getHRegionConnection(metaLocation.getServerAddress());
 
+          Result regionInfoRow = null;
+          // This block guards against two threads trying to load the meta
+          // region at the same time. The first will load the meta region and
+          // the second will use the value that the first one found.
+          synchronized(regionLockObject) {
+            // Check the cache again for a hit in case some other thread made the
+            // same query while we were waiting on the lock. If not supposed to
+            // be using the cache, delete any existing cached location so it won't
+            // interfere.
+            if (useCache) {
+              location = getCachedLocation(tableName, row);
+              if (location != null) {
+                return location;
+              }
+            } else {
+              deleteCachedLocation(tableName, row);
+            }
+
           // Query the root or meta region for the location of the meta region
-          Result regionInfoRow = server.getClosestRowBefore(
+            regionInfoRow = server.getClosestRowBefore(
             metaLocation.getRegionInfo().getRegionName(), metaKey,
             HConstants.CATALOG_FAMILY);
+          }
           if (regionInfoRow == null) {
             throw new TableNotFoundException(Bytes.toString(tableName));
           }



Mime
View raw message