From 39acc69b891405e228eecb1a3e34ed4319fdb4ed Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Tue, 19 Feb 2019 11:10:15 +0800 Subject: [PATCH] HBASE-21927 Always fail the locate request when error occur --- .../apache/hadoop/hbase/client/AsyncMetaRegionLocator.java | 2 +- .../hadoop/hbase/client/AsyncNonMetaRegionLocator.java | 5 +++-- .../apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMetaRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMetaRegionLocator.java index f5b3f92f65..175f8f2219 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMetaRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMetaRegionLocator.java @@ -78,7 +78,7 @@ class AsyncMetaRegionLocator { metaRelocateFuture.getAndSet(null).completeExceptionally(error); return; } - LOG.debug("The fetched meta region location is {}" + locs); + LOG.debug("The fetched meta region location is {}", locs); // Here we update cache before reset future, so it is possible that someone can get a // stale value. Consider this: // 1. update cache diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java index 5d5c7c3d6c..1f23a1d985 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java @@ -45,7 +45,6 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentNavigableMap; import java.util.concurrent.ConcurrentSkipListMap; import org.apache.commons.lang3.ObjectUtils; -import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.HBaseIOException; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionLocation; @@ -275,7 +274,9 @@ class AsyncNonMetaRegionLocator { } synchronized (tableCache) { tableCache.pendingRequests.remove(req); - if (error instanceof DoNotRetryIOException) { + if (error != null) { + // fail the request itself, no matter whether it is a DoNotRetryIOException, as we have + // already retried several times CompletableFuture future = tableCache.allRequests.remove(req); if (future != null) { future.completeExceptionally(error); diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java index 5c9c09154e..9ba36f637d 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java @@ -53,12 +53,12 @@ final class AsyncRegionLocatorHelper { Function cachedLocationSupplier, Consumer addToCache, Consumer removeFromCache) { HRegionLocation oldLoc = cachedLocationSupplier.apply(loc); - LOG.debug("Try updating {} , the old value is {}", loc, oldLoc, exception); + LOG.debug("Try updating {} , the old value is {}, error={}", loc, oldLoc, exception.toString()); if (!canUpdateOnError(loc, oldLoc)) { return; } Throwable cause = findException(exception); - LOG.debug("The actual exception when updating {}", loc, cause); + LOG.debug("The actual exception when updating {} is {}", loc, cause.toString()); if (cause == null || !isMetaClearingException(cause)) { LOG.debug("Will not update {} because the exception is null or not the one we care about", loc); -- 2.17.1