Skip to content

Commit f1bfda1

Browse files
briaugenreichbbeaudreault
authored andcommitted
HBASE-27491 Do not clear cache on RejectedExecutionException (apache#4914)
Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Bryan Beaudreault <[email protected]>
1 parent cc86844 commit f1bfda1

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
@@ -219,13 +219,13 @@ 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);
222+
receiveGlobalFailure(multiAction, server, numAttempt, e, true);
223223
return;
224224
} catch (Throwable t) {
225225
// This should not happen. Let's log & retry anyway.
226226
LOG.error("id=" + asyncProcess.id + ", caught throwable. Unexpected."
227227
+ " Retrying. Server=" + server + ", tableName=" + tableName, t);
228-
receiveGlobalFailure(multiAction, server, numAttempt, t);
228+
receiveGlobalFailure(multiAction, server, numAttempt, t, true);
229229
return;
230230
}
231231
if (res.type() == AbstractResponse.ResponseType.MULTI) {
@@ -521,6 +521,7 @@ private RegionLocations findAllLocationsOrFail(Action action, boolean useCache)
521521
*/
522522
void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttempt,
523523
List<Action> actionsForReplicaThread, boolean reuseThread) {
524+
boolean clearServerCache = true;
524525
// Run the last item on the same thread if we are already on a send thread.
525526
// We hope most of the time it will be the only item, so we can cut down on threads.
526527
int actionsRemaining = actionsByServer.size();
@@ -555,14 +556,16 @@ void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttemp
555556
// let's secure this a little.
556557
LOG.warn("id=" + asyncProcess.id + ", task rejected by pool. Unexpected." + " Server="
557558
+ server.getServerName(), t);
559+
// Do not update cache if exception is from failing to submit action to thread pool
560+
clearServerCache = false;
558561
} else {
559562
// see #HBASE-14359 for more details
560563
LOG.warn("Caught unexpected exception/error: ", t);
561564
}
562565
asyncProcess.decTaskCounters(multiAction.getRegions(), server);
563566
// We're likely to fail again, but this will increment the attempt counter,
564567
// so it will finish.
565-
receiveGlobalFailure(multiAction, server, numAttempt, t);
568+
receiveGlobalFailure(multiAction, server, numAttempt, t, clearServerCache);
566569
}
567570
}
568571
}
@@ -717,21 +720,28 @@ private void failAll(MultiAction actions, ServerName server, int numAttempt,
717720
* @param t the throwable (if any) that caused the resubmit
718721
*/
719722
private void receiveGlobalFailure(MultiAction rsActions, ServerName server, int numAttempt,
720-
Throwable t) {
723+
Throwable t, boolean clearServerCache) {
721724
errorsByServer.reportServerError(server);
722725
Retry canRetry = errorsByServer.canTryMore(numAttempt) ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED;
723726

724-
cleanServerCache(server, t);
727+
// Do not update cache if exception is from failing to submit action to thread pool
728+
if (clearServerCache) {
729+
cleanServerCache(server, t);
730+
}
731+
725732
int failed = 0;
726733
int stopped = 0;
727734
List<Action> toReplay = new ArrayList<>();
728735
for (Map.Entry<byte[], List<Action>> e : rsActions.actions.entrySet()) {
729736
byte[] regionName = e.getKey();
730737
byte[] row = e.getValue().get(0).getAction().getRow();
731738
// Do not use the exception for updating cache because it might be coming from
732-
// any of the regions in the MultiAction.
733-
updateCachedLocations(server, regionName, row,
734-
ClientExceptionsUtil.isMetaClearingException(t) ? null : t);
739+
// any of the regions in the MultiAction and do not update cache if exception is
740+
// from failing to submit action to thread pool
741+
if (clearServerCache) {
742+
updateCachedLocations(server, regionName, row,
743+
ClientExceptionsUtil.isMetaClearingException(t) ? null : t);
744+
}
735745
for (Action action : e.getValue()) {
736746
Retry retry =
737747
manageError(action.getOriginalIndex(), action.getAction(), canRetry, t, server);

0 commit comments

Comments
 (0)