@@ -679,20 +679,24 @@ private void indexInvalidation(Collection<String> tokenIds, ActionListener<Token
679
679
}
680
680
}
681
681
}
682
- if (retryTokenDocIds .isEmpty () == false ) {
683
- if (backoff .hasNext ()) {
684
- logger .debug ("failed to invalidate [{}] tokens out of [{}], retrying to invalidate these too" ,
685
- retryTokenDocIds .size (), tokenIds .size ());
686
- final TokensInvalidationResult incompleteResult = new TokensInvalidationResult (invalidated ,
682
+ if (retryTokenDocIds .isEmpty () == false && backoff .hasNext ()) {
683
+ logger .debug ("failed to invalidate [{}] tokens out of [{}], retrying to invalidate these too" ,
684
+ retryTokenDocIds .size (), tokenIds .size ());
685
+ final TokensInvalidationResult incompleteResult = new TokensInvalidationResult (invalidated ,
687
686
previouslyInvalidated , failedRequestResponses );
688
- final Runnable retryWithContextRunnable = client .threadPool ().getThreadContext ().preserveContext (
687
+ final Runnable retryWithContextRunnable = client .threadPool ().getThreadContext ().preserveContext (
689
688
() -> indexInvalidation (retryTokenDocIds , listener , backoff , srcPrefix , incompleteResult ));
690
- client .threadPool ().schedule (retryWithContextRunnable , backoff .next (), GENERIC );
691
- } else {
689
+ client .threadPool ().schedule (retryWithContextRunnable , backoff .next (), GENERIC );
690
+ } else {
691
+ if (retryTokenDocIds .isEmpty () == false ) {
692
692
logger .warn ("failed to invalidate [{}] tokens out of [{}] after all retries" , retryTokenDocIds .size (),
693
693
tokenIds .size ());
694
+ for (String retryTokenDocId : retryTokenDocIds ) {
695
+ failedRequestResponses .add (
696
+ new ElasticsearchException ("Error invalidating [{}] with doc id [{}] after retries exhausted" ,
697
+ srcPrefix , retryTokenDocId ));
698
+ }
694
699
}
695
- } else {
696
700
final TokensInvalidationResult result = new TokensInvalidationResult (invalidated , previouslyInvalidated ,
697
701
failedRequestResponses );
698
702
listener .onResponse (result );
0 commit comments