Skip to content

Commit 358624a

Browse files
hgromerHernan Gelaf-Romer
and
Hernan Gelaf-Romer
committed
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 e2684cc commit 358624a

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
@@ -223,13 +223,14 @@ public void run() {
223223
} catch (IOException e) {
224224
// The service itself failed . It may be an error coming from the communication
225225
// layer, but, as well, a functional error raised by the server.
226-
receiveGlobalFailure(multiAction, server, numAttempt, e, true);
226+
227+
receiveGlobalFailure(multiAction, server, numAttempt, e);
227228
return;
228229
} catch (Throwable t) {
229230
// This should not happen. Let's log & retry anyway.
230231
LOG.error("id=" + asyncProcess.id + ", caught throwable. Unexpected."
231232
+ " Retrying. Server=" + server + ", tableName=" + tableName, t);
232-
receiveGlobalFailure(multiAction, server, numAttempt, t, true);
233+
receiveGlobalFailure(multiAction, server, numAttempt, t);
233234
return;
234235
}
235236
if (res.type() == AbstractResponse.ResponseType.MULTI) {
@@ -577,7 +578,6 @@ private RegionLocations findAllLocationsOrFail(Action action, boolean useCache)
577578
*/
578579
void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttempt,
579580
List<Action> actionsForReplicaThread, boolean reuseThread) {
580-
boolean clearServerCache = true;
581581
// Run the last item on the same thread if we are already on a send thread.
582582
// We hope most of the time it will be the only item, so we can cut down on threads.
583583
int actionsRemaining = actionsByServer.size();
@@ -613,15 +613,14 @@ void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttemp
613613
LOG.warn("id=" + asyncProcess.id + ", task rejected by pool. Unexpected." + " Server="
614614
+ server.getServerName(), t);
615615
// Do not update cache if exception is from failing to submit action to thread pool
616-
clearServerCache = false;
617616
} else {
618617
// see #HBASE-14359 for more details
619618
LOG.warn("Caught unexpected exception/error: ", t);
620619
}
621620
asyncProcess.decTaskCounters(multiAction.getRegions(), server);
622621
// We're likely to fail again, but this will increment the attempt counter,
623622
// so it will finish.
624-
receiveGlobalFailure(multiAction, server, numAttempt, t, clearServerCache);
623+
receiveGlobalFailure(multiAction, server, numAttempt, t);
625624
}
626625
}
627626
}
@@ -771,13 +770,24 @@ private void failAll(MultiAction actions, ServerName server, int numAttempt,
771770
* @param t the throwable (if any) that caused the resubmit
772771
*/
773772
private void receiveGlobalFailure(MultiAction rsActions, ServerName server, int numAttempt,
774-
Throwable t, boolean clearServerCache) {
773+
Throwable t) {
775774
errorsByServer.reportServerError(server);
776775
Retry canRetry = errorsByServer.canTryMore(numAttempt) ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED;
776+
boolean clearServerCache;
777+
778+
if (t instanceof RejectedExecutionException) {
779+
clearServerCache = false;
780+
} else {
781+
clearServerCache = ClientExceptionsUtil.isMetaClearingException(t);
782+
}
777783

778784
// Do not update cache if exception is from failing to submit action to thread pool
779785
if (clearServerCache) {
780786
cleanServerCache(server, t);
787+
788+
if (LOG.isTraceEnabled()) {
789+
LOG.trace("Cleared meta cache for server {} due to global failure {}", server, t);
790+
}
781791
}
782792

783793
int failed = 0;
@@ -786,12 +796,8 @@ private void receiveGlobalFailure(MultiAction rsActions, ServerName server, int
786796
for (Map.Entry<byte[], List<Action>> e : rsActions.actions.entrySet()) {
787797
byte[] regionName = e.getKey();
788798
byte[] row = e.getValue().get(0).getAction().getRow();
789-
// Do not use the exception for updating cache because it might be coming from
790-
// any of the regions in the MultiAction and do not update cache if exception is
791-
// from failing to submit action to thread pool
792799
if (clearServerCache) {
793-
updateCachedLocations(server, regionName, row,
794-
ClientExceptionsUtil.isMetaClearingException(t) ? null : t);
800+
updateCachedLocations(server, regionName, row, t);
795801
}
796802
for (Action action : e.getValue()) {
797803
Retry retry =

0 commit comments

Comments
 (0)