Skip to content

Commit 62a946f

Browse files
author
Hernan Gelaf-Romer
committed
Metrics for meta cache clears should contain the actual exception, not 'UknownException'
1 parent 923282d commit 62a946f

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,14 @@ public void run() {
219219
} catch (IOException e) {
220220
// The service itself failed . It may be an error coming from the communication
221221
// layer, but, as well, a functional error raised by the server.
222-
receiveGlobalFailure(multiAction, server, numAttempt, e, true);
222+
223+
receiveGlobalFailure(multiAction, server, numAttempt, e);
223224
return;
224225
} catch (Throwable t) {
225226
// This should not happen. Let's log & retry anyway.
226227
LOG.error("id=" + asyncProcess.id + ", caught throwable. Unexpected."
227228
+ " Retrying. Server=" + server + ", tableName=" + tableName, t);
228-
receiveGlobalFailure(multiAction, server, numAttempt, t, true);
229+
receiveGlobalFailure(multiAction, server, numAttempt, t);
229230
return;
230231
}
231232
if (res.type() == AbstractResponse.ResponseType.MULTI) {
@@ -570,7 +571,6 @@ private RegionLocations findAllLocationsOrFail(Action action, boolean useCache)
570571
*/
571572
void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttempt,
572573
List<Action> actionsForReplicaThread, boolean reuseThread) {
573-
boolean clearServerCache = true;
574574
// Run the last item on the same thread if we are already on a send thread.
575575
// We hope most of the time it will be the only item, so we can cut down on threads.
576576
int actionsRemaining = actionsByServer.size();
@@ -606,15 +606,14 @@ void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttemp
606606
LOG.warn("id=" + asyncProcess.id + ", task rejected by pool. Unexpected." + " Server="
607607
+ server.getServerName(), t);
608608
// Do not update cache if exception is from failing to submit action to thread pool
609-
clearServerCache = false;
610609
} else {
611610
// see #HBASE-14359 for more details
612611
LOG.warn("Caught unexpected exception/error: ", t);
613612
}
614613
asyncProcess.decTaskCounters(multiAction.getRegions(), server);
615614
// We're likely to fail again, but this will increment the attempt counter,
616615
// so it will finish.
617-
receiveGlobalFailure(multiAction, server, numAttempt, t, clearServerCache);
616+
receiveGlobalFailure(multiAction, server, numAttempt, t);
618617
}
619618
}
620619
}
@@ -764,13 +763,24 @@ private void failAll(MultiAction actions, ServerName server, int numAttempt,
764763
* @param t the throwable (if any) that caused the resubmit
765764
*/
766765
private void receiveGlobalFailure(MultiAction rsActions, ServerName server, int numAttempt,
767-
Throwable t, boolean clearServerCache) {
766+
Throwable t) {
768767
errorsByServer.reportServerError(server);
769768
Retry canRetry = errorsByServer.canTryMore(numAttempt) ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED;
769+
boolean clearServerCache;
770+
771+
if (t instanceof RejectedExecutionException) {
772+
clearServerCache = false;
773+
} else {
774+
clearServerCache = ClientExceptionsUtil.isMetaClearingException(t);
775+
}
770776

771777
// Do not update cache if exception is from failing to submit action to thread pool
772778
if (clearServerCache) {
773779
cleanServerCache(server, t);
780+
781+
if (LOG.isTraceEnabled()) {
782+
LOG.trace("Cleared meta cache for server {} due to global failure {}", server, t);
783+
}
774784
}
775785

776786
int failed = 0;
@@ -779,12 +789,8 @@ private void receiveGlobalFailure(MultiAction rsActions, ServerName server, int
779789
for (Map.Entry<byte[], List<Action>> e : rsActions.actions.entrySet()) {
780790
byte[] regionName = e.getKey();
781791
byte[] row = e.getValue().get(0).getAction().getRow();
782-
// Do not use the exception for updating cache because it might be coming from
783-
// any of the regions in the MultiAction and do not update cache if exception is
784-
// from failing to submit action to thread pool
785792
if (clearServerCache) {
786-
updateCachedLocations(server, regionName, row,
787-
ClientExceptionsUtil.isMetaClearingException(t) ? null : t);
793+
updateCachedLocations(server, regionName, row, t);
788794
}
789795
for (Action action : e.getValue()) {
790796
Retry retry =

hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ClientExceptionsUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ public static Throwable findException(Object exception) {
122122
* below.
123123
*/
124124
@RestrictedApi(explanation = "Should only be called in tests", link = "",
125-
allowedOnPath = ".*/src/test/.*")
125+
allowedOnPath = ".*/src/test/.*")
126126
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "MS_EXPOSE_REP",
127-
justification = "test only")
127+
justification = "test only")
128128
public static Set<Class<? extends Throwable>> getConnectionExceptionTypes() {
129129
return CONNECTION_EXCEPTION_TYPES;
130130
}

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaCache.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static org.junit.Assert.assertNull;
2323
import static org.junit.Assert.assertTrue;
2424
import static org.junit.Assert.fail;
25-
2625
import java.io.IOException;
2726
import java.util.Arrays;
2827
import java.util.List;
@@ -59,10 +58,8 @@
5958
import org.junit.function.ThrowingRunnable;
6059
import org.slf4j.Logger;
6160
import org.slf4j.LoggerFactory;
62-
6361
import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
6462
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
65-
6663
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
6764
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetResponse;
6865
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;

0 commit comments

Comments
 (0)