# ES Server high CPU on CloseableThreadLocal

**URL:** https://discuss.elastic.co/t/es-server-high-cpu-on-closeablethreadlocal/108455
**Category:** Elasticsearch
**Created:** [November 20, 2017, 8:22pm UTC](https://discuss.elastic.co/t/es-server-high-cpu-on-closeablethreadlocal/108455 "2017-11-20T20:22:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![shaharmor](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@shaharmor](https://discuss.elastic.co/u/shaharmor)
#### Post date: [November 20, 2017, 8:22pm UTC](https://discuss.elastic.co/t/es-server-high-cpu-on-closeablethreadlocal/108455/1 "2017-11-20T20:22:30Z")

</div>

Hi,

I have 2 servers out of 3 that have high constant CPU usage due to this hot thread:

```auto
83.8% (419.2ms out of 500ms) cpu usage by thread 'elasticsearch[elasticsearch-003][flush][T#5]'
     6/10 snapshots sharing following 10 elements
       org.apache.lucene.util.CloseableThreadLocal.set(CloseableThreadLocal.java:97)
       org.elasticsearch.common.util.concurrent.ThreadContext$ContextThreadLocal.set(ThreadContext.java:509)
       org.elasticsearch.common.util.concurrent.ThreadContext.lambda$stashContext$0(ThreadContext.java:109)
       org.elasticsearch.common.util.concurrent.ThreadContext$$Lambda$1477/1354584016.close(Unknown Source)
       org.elasticsearch.common.util.concurrent.ThreadContext$StoredContext.restore(ThreadContext.java:348)
       org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.onAfter(ThreadContext.java:616)
       org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:41)
       java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       java.lang.Thread.run(Thread.java:748)
     2/10 snapshots sharing following 10 elements
       org.apache.lucene.util.CloseableThreadLocal.set(CloseableThreadLocal.java:97)
       org.elasticsearch.common.util.concurrent.ThreadContext$ContextThreadLocal.set(ThreadContext.java:511)
       org.elasticsearch.common.util.concurrent.ThreadContext.lambda$newStoredContext$2(ThreadContext.java:135)
       org.elasticsearch.common.util.concurrent.ThreadContext$$Lambda$1476/657820185.close(Unknown Source)
       org.elasticsearch.common.util.concurrent.ThreadContext$StoredContext.restore(ThreadContext.java:348)
       org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:636)
       org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
       java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       java.lang.Thread.run(Thread.java:748)
     2/10 snapshots sharing following 8 elements
       org.apache.lucene.util.CloseableThreadLocal.set(CloseableThreadLocal.java:97)
       org.elasticsearch.common.util.concurrent.ThreadContext$ContextThreadLocal.set(ThreadContext.java:511)
       org.elasticsearch.common.util.concurrent.ThreadContext.stashContext(ThreadContext.java:108)
       org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:634)
       org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
       java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       java.lang.Thread.run(Thread.java:748)

```

Which i think is caused by a bug.  
Btw I'm using the azure-plugin.  
ES 6.0.0-GA

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [November 21, 2017, 1:53pm UTC](https://discuss.elastic.co/t/es-server-high-cpu-on-closeablethreadlocal/108455/2 "2017-11-21T13:53:19Z")

</div>

Can you tell us more about your workload? Are you heavily indexing, searching or reindexing on this cluster maybe?

---

<div class="post-metadata">

### Author: ![shaharmor](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@shaharmor](https://discuss.elastic.co/u/shaharmor)
#### Post date: [November 21, 2017, 2:05pm UTC](https://discuss.elastic.co/t/es-server-high-cpu-on-closeablethreadlocal/108455/3 "2017-11-21T14:05:39Z")

</div>

It was after an upgrade to 6.0.0GA from 6.0.0-rc1.

Those specific servers don't have any real time indexing to them. Every 30 minutes they get a bulk update of some docs and thats it.

Searching is really low, a few requests a minute

---

<div class="post-metadata">

### Author: ![shaharmor](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@shaharmor](https://discuss.elastic.co/u/shaharmor)
#### Post date: [November 21, 2017, 2:05pm UTC](https://discuss.elastic.co/t/es-server-high-cpu-on-closeablethreadlocal/108455/4 "2017-11-21T14:05:51Z")

</div>

Btw, restarting the machines fixed it

---

<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: [December 19, 2017, 2:05pm UTC](https://discuss.elastic.co/t/es-server-high-cpu-on-closeablethreadlocal/108455/5 "2017-12-19T14:05:54Z")

</div>

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