Repository: hbase
Updated Branches:
  refs/heads/branch-1.4 dab7b39f2 -> d625b212e
Updated Tags:  refs/tags/1.4.9RC1 [created] c5b401c4f


HBASE-21464 Splitting blocked with meta NSRE during split transaction

Signed-off-by: Lars Hofhansl <la...@apache.org>


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

Branch: refs/heads/branch-1.4
Commit: e7c79c722376aa152dae6f976c01faebefed224f
Parents: dab7b39
Author: Andrew Purtell <apurt...@apache.org>
Authored: Fri Nov 30 15:23:34 2018 -0800
Committer: Andrew Purtell <apurt...@apache.org>
Committed: Wed Dec 5 10:54:59 2018 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/client/ConnectionManager.java  | 42 ++++++++++++--------
 1 file changed, 25 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e7c79c72/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
----------------------------------------------------------------------
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
index 7cf09c2..35ffa3e 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
@@ -1231,38 +1231,46 @@ class ConnectionManager {
       }
     }
 
+    private volatile RegionLocations metaLocations = null;
+    private volatile long lastMetaLookupTime = 
EnvironmentEdgeManager.currentTime();
+    // cache meta location at most 10 seconds
+    private final static long META_LOOKUP_CACHE_INTERVAL = 10000;
+
     private RegionLocations locateMeta(final TableName tableName,
         boolean useCache, int replicaId) throws IOException {
-      // HBASE-10785: We cache the location of the META itself, so that we are 
not overloading
-      // zookeeper with one request for every region lookup. We cache the META 
with empty row
-      // key in MetaCache.
-      byte[] metaCacheKey = HConstants.EMPTY_START_ROW; // use byte[0] as the 
row for meta
-      RegionLocations locations = null;
+      // We cache the location of the META itself, so that we are not 
overloading
+      // zookeeper with one request for every region lookup. If relocating, 
bypass
+      // the cache immediately.
       if (useCache) {
-        locations = getCachedLocation(tableName, metaCacheKey);
-        if (locations != null && locations.getRegionLocation(replicaId) != 
null) {
-          return locations;
+        long now = EnvironmentEdgeManager.currentTime();
+        if (now - lastMetaLookupTime < META_LOOKUP_CACHE_INTERVAL) {
+          if (metaLocations != null &&
+              metaLocations.getRegionLocation(replicaId) != null) {
+            return metaLocations;
+          }
+        } else {
+          useCache = false;
         }
       }
-
       // only one thread should do the lookup.
       synchronized (metaRegionLock) {
         // Check the cache again for a hit in case some other thread made the
         // same query while we were waiting on the lock.
         if (useCache) {
-          locations = getCachedLocation(tableName, metaCacheKey);
-          if (locations != null && locations.getRegionLocation(replicaId) != 
null) {
-            return locations;
+          if (metaLocations != null &&
+              metaLocations.getRegionLocation(replicaId) != null) {
+            return metaLocations;
           }
         }
-
         // Look up from zookeeper
-        locations = this.registry.getMetaRegionLocation();
-        if (locations != null) {
-          cacheLocation(tableName, locations);
+        metaLocations = this.registry.getMetaRegionLocation();
+        lastMetaLookupTime = EnvironmentEdgeManager.currentTime();
+        if (metaLocations != null &&
+            metaLocations.getRegionLocation(replicaId) != null) {
+          return metaLocations;
         }
+        return null;
       }
-      return locations;
     }
 
     /*

Reply via email to