@@ -223,13 +223,14 @@ public void run() {
223
223
} catch (IOException e ) {
224
224
// The service itself failed . It may be an error coming from the communication
225
225
// 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 );
227
228
return ;
228
229
} catch (Throwable t ) {
229
230
// This should not happen. Let's log & retry anyway.
230
231
LOG .error ("id=" + asyncProcess .id + ", caught throwable. Unexpected."
231
232
+ " Retrying. Server=" + server + ", tableName=" + tableName , t );
232
- receiveGlobalFailure (multiAction , server , numAttempt , t , true );
233
+ receiveGlobalFailure (multiAction , server , numAttempt , t );
233
234
return ;
234
235
}
235
236
if (res .type () == AbstractResponse .ResponseType .MULTI ) {
@@ -577,7 +578,6 @@ private RegionLocations findAllLocationsOrFail(Action action, boolean useCache)
577
578
*/
578
579
void sendMultiAction (Map <ServerName , MultiAction > actionsByServer , int numAttempt ,
579
580
List <Action > actionsForReplicaThread , boolean reuseThread ) {
580
- boolean clearServerCache = true ;
581
581
// Run the last item on the same thread if we are already on a send thread.
582
582
// We hope most of the time it will be the only item, so we can cut down on threads.
583
583
int actionsRemaining = actionsByServer .size ();
@@ -613,15 +613,14 @@ void sendMultiAction(Map<ServerName, MultiAction> actionsByServer, int numAttemp
613
613
LOG .warn ("id=" + asyncProcess .id + ", task rejected by pool. Unexpected." + " Server="
614
614
+ server .getServerName (), t );
615
615
// Do not update cache if exception is from failing to submit action to thread pool
616
- clearServerCache = false ;
617
616
} else {
618
617
// see #HBASE-14359 for more details
619
618
LOG .warn ("Caught unexpected exception/error: " , t );
620
619
}
621
620
asyncProcess .decTaskCounters (multiAction .getRegions (), server );
622
621
// We're likely to fail again, but this will increment the attempt counter,
623
622
// so it will finish.
624
- receiveGlobalFailure (multiAction , server , numAttempt , t , clearServerCache );
623
+ receiveGlobalFailure (multiAction , server , numAttempt , t );
625
624
}
626
625
}
627
626
}
@@ -771,13 +770,24 @@ private void failAll(MultiAction actions, ServerName server, int numAttempt,
771
770
* @param t the throwable (if any) that caused the resubmit
772
771
*/
773
772
private void receiveGlobalFailure (MultiAction rsActions , ServerName server , int numAttempt ,
774
- Throwable t , boolean clearServerCache ) {
773
+ Throwable t ) {
775
774
errorsByServer .reportServerError (server );
776
775
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
+ }
777
783
778
784
// Do not update cache if exception is from failing to submit action to thread pool
779
785
if (clearServerCache ) {
780
786
cleanServerCache (server , t );
787
+
788
+ if (LOG .isTraceEnabled ()) {
789
+ LOG .trace ("Cleared meta cache for server {} due to global failure {}" , server , t );
790
+ }
781
791
}
782
792
783
793
int failed = 0 ;
@@ -786,12 +796,8 @@ private void receiveGlobalFailure(MultiAction rsActions, ServerName server, int
786
796
for (Map .Entry <byte [], List <Action >> e : rsActions .actions .entrySet ()) {
787
797
byte [] regionName = e .getKey ();
788
798
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
792
799
if (clearServerCache ) {
793
- updateCachedLocations (server , regionName , row ,
794
- ClientExceptionsUtil .isMetaClearingException (t ) ? null : t );
800
+ updateCachedLocations (server , regionName , row , t );
795
801
}
796
802
for (Action action : e .getValue ()) {
797
803
Retry retry =
0 commit comments