Skip to content

Commit b1f7956

Browse files
hgromerHernan Gelaf-Romer
authored andcommitted
HBASE-29372 Meta cache clear metrics and logs shouldn't use "UnknownException" (apache#6961)
Co-authored-by: Hernan Gelaf-Romer <[email protected]> Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Ray Mattingly <[email protected]>
1 parent 8d719b5 commit b1f7956

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
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 =

0 commit comments

Comments
 (0)