39
39
import org .elasticsearch .common .unit .ByteSizeValue ;
40
40
import org .elasticsearch .common .util .BigArrays ;
41
41
import org .elasticsearch .common .util .CollectionUtils ;
42
+ import org .elasticsearch .common .util .concurrent .AbstractRunnable ;
42
43
import org .elasticsearch .common .util .concurrent .ConcurrentCollections ;
44
+ import org .elasticsearch .common .util .concurrent .EsRejectedExecutionException ;
43
45
import org .elasticsearch .core .Releasable ;
44
46
import org .elasticsearch .core .Releasables ;
45
47
import org .elasticsearch .core .TimeValue ;
@@ -1434,9 +1436,9 @@ public ResponseCollectorService getResponseCollectorService() {
1434
1436
return this .responseCollectorService ;
1435
1437
}
1436
1438
1437
- class Reaper implements Runnable {
1439
+ class Reaper extends AbstractRunnable {
1438
1440
@ Override
1439
- public void run () {
1441
+ protected void doRun () {
1440
1442
assert Transports .assertNotTransportThread ("closing contexts may do IO, e.g. deleting dangling files" )
1441
1443
&& ThreadPool .assertNotScheduleThread ("closing contexts may do IO, e.g. deleting dangling files" );
1442
1444
for (ReaderContext context : activeReaders .values ()) {
@@ -1446,6 +1448,27 @@ public void run() {
1446
1448
}
1447
1449
}
1448
1450
}
1451
+
1452
+ @ Override
1453
+ public void onFailure (Exception e ) {
1454
+ logger .error ("unexpected error when freeing search contexts" , e );
1455
+ assert false : e ;
1456
+ }
1457
+
1458
+ @ Override
1459
+ public void onRejection (Exception e ) {
1460
+ if (e instanceof EsRejectedExecutionException && ((EsRejectedExecutionException ) e ).isExecutorShutdown ()) {
1461
+ logger .debug ("rejected execution when freeing search contexts" );
1462
+ } else {
1463
+ onFailure (e );
1464
+ }
1465
+ }
1466
+
1467
+ @ Override
1468
+ public boolean isForceExecution () {
1469
+ // mustn't reject this task even if the queue is full
1470
+ return true ;
1471
+ }
1449
1472
}
1450
1473
1451
1474
public AliasFilter buildAliasFilter (ClusterState state , String index , Set <String > resolvedExpressions ) {
0 commit comments