# Not all search threads are being used

**URL:** <https://discuss.elastic.co/t/not-all-search-threads-are-being-used/164769>\
**Category:** Elasticsearch\
**Created:** [January 18, 2019, 10:16am UTC](https://discuss.elastic.co/t/not-all-search-threads-are-being-used/164769 "2019-01-18T10:16:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwistrom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jwistrom/32/41798_2.png) [@jwistrom](https://discuss.elastic.co/u/jwistrom)\
**Post date:** [January 18, 2019, 10:16am UTC](https://discuss.elastic.co/t/not-all-search-threads-are-being-used/164769/1 "2019-01-18T10:16:32Z")

</div>

Hi  
I am experiencing EsRejectedExecutionException looking like this:

```auto
Caused by: org.elasticsearch.common.util.concurrent.EsRejectedExecutionException: rejected execution of 
org.elasticsearch.common.util.concurrent.TimedRunnable@6115ff55 on 
QueueResizingEsThreadPoolExecutor[name = thu-match-es1/search, queue capacity = 1000, min queue 
capacity = 1000, max queue capacity = 1000, frame size = 2000, targeted response rate = 1s, task execution 
EWMA = 10.6ms, adjustment amount = 50, 
org.elasticsearch.common.util.concurrent.QueueResizingEsThreadPoolExecutor@4401085f[Running, pool 
size = 35, active threads = 12, queued tasks = 1000, completed tasks = 31173285]]

```

My question is: Why do I get a rejected exception when not all available threads (35) are being utilized? According to the stack trace only 12 threads are active. Or have I misread the stack trace?

Regards  
Johan

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [January 18, 2019, 3:20pm UTC](https://discuss.elastic.co/t/not-all-search-threads-are-being-used/164769/2 "2019-01-18T15:20:58Z")

</div>

> [@jwistrom](#):
>
> Or have I misread the stack trace?

Without seeing it, it's impossible to say. Can you share more information?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [January 18, 2019, 3:26pm UTC](https://discuss.elastic.co/t/not-all-search-threads-are-being-used/164769/3 "2019-01-18T15:26:21Z")

</div>

Oh hang on, I see 🙂

```auto
pool size = 35, active threads = 12, queued tasks = 1000

```

The rejection is because the queue is full, not because there are no more threads. I am looking further into what these numbers mean.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [January 18, 2019, 3:35pm UTC](https://discuss.elastic.co/t/not-all-search-threads-are-being-used/164769/4 "2019-01-18T15:35:57Z")

</div>

It seems that the `active threads` number is only approximate, and the way that threads add and remove tasks to/from the pool means that there can be tasks on the queue without all the threads in the pool being active. Here is a post that looks related:

> <https://stackoverflow.com/questions/22996529/rejectedexecutionexception-free-threads-but-full-queue>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 15, 2019, 3:35pm UTC](https://discuss.elastic.co/t/not-all-search-threads-are-being-used/164769/5 "2019-02-15T15:35:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
