Skip to content

Commit d87ab89

Browse files
HBASE-27491: do not clear cache on RejectedExecutionException (#4914)
Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Bryan Beaudreault <[email protected]>
1 parent 66ddfb4 commit d87ab89

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ public void run() {
218218
} catch (IOException e) {
219219
// The service itself failed . It may be an error coming from the communication
220220
// layer, but, as well, a functional error raised by the server.
221-
receiveGlobalFailure(multiAction, server, numAttempt, e);
221+
receiveGlobalFailure(multiAction, server, numAttempt, e, true);
222222
return;
223223
} catch (Throwable t) {
224224
// This should not happen. Let's log & retry anyway.
225225
LOG.error("id=" + asyncProcess.id + ", caught throwable. Unexpected."
226226
+ " Retrying. Server=" + server + ", tableName=" + tableName, t);
227-
receiveGlobalFailure(multiAction, server, numAttempt, t);
227+
receiveGlobalFailure(multiAction, server, numAttempt, t, true);
228228
return;
229229
}
230230
if (res.type() == AbstractResponse.ResponseType.MULTI) {
@@ -563,6 +563,7 @@ private RegionLocations findAllLocationsOrFail(Action action, boolean useCache)
563563
*/
564564
void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttempt,
565565
List<Action> actionsForReplicaThread, boolean reuseThread) {
566+
boolean clearServerCache = true;
566567
// Run the last item on the same thread if we are already on a send thread.
567568
// We hope most of the time it will be the only item, so we can cut down on threads.
568569
int actionsRemaining = actionsByServer.size();
@@ -597,14 +598,16 @@ void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttemp
597598
// let's secure this a little.
598599
LOG.warn("id=" + asyncProcess.id + ", task rejected by pool. Unexpected." + " Server="
599600
+ server.getServerName(), t);
601+
// Do not update cache if exception is from failing to submit action to thread pool
602+
clearServerCache = false;
600603
} else {
601604
// see #HBASE-14359 for more details
602605
LOG.warn("Caught unexpected exception/error: ", t);
603606
}
604607
asyncProcess.decTaskCounters(multiAction.getRegions(), server);
605608
// We're likely to fail again, but this will increment the attempt counter,
606609
// so it will finish.
607-
receiveGlobalFailure(multiAction, server, numAttempt, t);
610+
receiveGlobalFailure(multiAction, server, numAttempt, t, clearServerCache);
608611
}
609612
}
610613
}
@@ -754,21 +757,28 @@ private void failAll(MultiAction actions, ServerName server, int numAttempt,
754757
* @param t the throwable (if any) that caused the resubmit
755758
*/
756759
private void receiveGlobalFailure(MultiAction rsActions, ServerName server, int numAttempt,
757-
Throwable t) {
760+
Throwable t, boolean clearServerCache) {
758761
errorsByServer.reportServerError(server);
759762
Retry canRetry = errorsByServer.canTryMore(numAttempt) ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED;
760763

761-
cleanServerCache(server, t);
764+
// Do not update cache if exception is from failing to submit action to thread pool
765+
if (clearServerCache) {
766+
cleanServerCache(server, t);
767+
}
768+
762769
int failed = 0;
763770
int stopped = 0;
764771
List<Action> toReplay = new ArrayList<>();
765772
for (Map.Entry<byte[], List<Action>> e : rsActions.actions.entrySet()) {
766773
byte[] regionName = e.getKey();
767774
byte[] row = e.getValue().get(0).getAction().getRow();
768775
// Do not use the exception for updating cache because it might be coming from
769-
// any of the regions in the MultiAction.
770-
updateCachedLocations(server, regionName, row,
771-
ClientExceptionsUtil.isMetaClearingException(t) ? null : t);
776+
// any of the regions in the MultiAction and do not update cache if exception is
777+
// from failing to submit action to thread pool
778+
if (clearServerCache) {
779+
updateCachedLocations(server, regionName, row,
780+
ClientExceptionsUtil.isMetaClearingException(t) ? null : t);
781+
}
772782
for (Action action : e.getValue()) {
773783
Retry retry =
774784
manageError(action.getOriginalIndex(), action.getAction(), canRetry, t, server);

0 commit comments

Comments
 (0)