diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-10-07 12:55:58 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-10-07 12:55:58 +0200 |
commit | 2c50eed11652022bf31eab9002277e57e331de23 (patch) | |
tree | 1dbd3da083c099914df28a18e95b7952efea3a57 | |
parent | 03224ae1749a058c88ee926738195ae0d3204322 (diff) |
If execution is rejected, fall back to doing it yourself.
4 files changed, 22 insertions, 6 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java b/container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java index b27efcc13f0..8d07e7c3757 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java +++ b/container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java @@ -56,7 +56,7 @@ public class DefaultContainerThreadpool extends AbstractComponent implements Aut threadPoolMetric); // Prestart needed, if not all threads will be created by the fist N tasks and hence they might also // get the dreaded thread locals initialized even if they will never run. - // That counters what we we want to achieve with the Q that will prefer thread locality. + // That counters what we want to achieve with the Q that will prefer thread locality. executor.prestartAllCoreThreads(); threadpool = new ExecutorServiceWrapper( executor, threadPoolMetric, processTerminator, config.maxThreadExecutionTimeSeconds() * 1000L, diff --git a/container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java b/container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java index a92bf5ec9f7..0a112945682 100644 --- a/container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java +++ b/container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java @@ -100,13 +100,21 @@ public class AsyncExecution { private static <T> Future<T> getFuture(final Callable<T> callable) { FutureTask<T> future = new FutureTask<>(callable); - executorMain.execute(future); + try { + executorMain.execute(future); + } catch (RejectedExecutionException e) { + future.run(); + } return future; } private FutureResponse getFutureResponse(Callable<Response> callable, Request request) { FutureResponse future = new FutureResponse(callable, execution, request); - executorMain.execute(future.delegate()); + try { + executorMain.execute(future.delegate()); + } catch (RejectedExecutionException e) { + future.delegate().run(); + } return future; } diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java index b2f752182bb..a2decd8c42f 100644 --- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java @@ -306,7 +306,7 @@ public class ClusterSearcher extends Searcher { } } - private void processResult(Query query, FutureTask<Result> task, Result mergedResult) { + private static void processResult(Query query, FutureTask<Result> task, Result mergedResult) { try { Result result = task.get(); mergedResult.mergeWith(result); diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/AsyncExecution.java b/container-search/src/main/java/com/yahoo/search/searchchain/AsyncExecution.java index 6dbb6f88653..edd3202d63a 100644 --- a/container-search/src/main/java/com/yahoo/search/searchchain/AsyncExecution.java +++ b/container-search/src/main/java/com/yahoo/search/searchchain/AsyncExecution.java @@ -148,7 +148,11 @@ public class AsyncExecution { private static <T> Future<T> getFuture(Callable<T> callable) { FutureTask<T> future = new FutureTask<>(callable); - getExecutor().execute(future); + try { + getExecutor().execute(future); + } catch (RejectedExecutionException e) { + future.run(); + } return future; } @@ -161,7 +165,11 @@ public class AsyncExecution { private FutureResult getFutureResult(Callable<Result> callable, Query query) { FutureResult future = new FutureResult(callable, execution, query); - getExecutor().execute(future); + try { + getExecutor().execute(future); + } catch (RejectedExecutionException e) { + future.run(); + } return future; } |