# Method code too large error in Elasticsearch logs

**URL:** <https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540>\
**Category:** Elasticsearch\
**Created:** [July 13, 2021, 12:55pm UTC](https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540 "2021-07-13T12:55:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikolaj\_K](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolaj_k/32/80310_2.png) [@Nikolaj\_K](https://discuss.elastic.co/u/Nikolaj_K)\
**Post date:** [July 13, 2021, 12:55pm UTC](https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540/1 "2021-07-13T12:55:36Z")

</div>

Hello,

I am investigation performance issues of Elasticsearch cluster and in the logs of the cluster I keep finding the following error:

```auto
nested: NotSerializableExceptionWrapper[runtime_exception: Method code too large!];
	at org.elasticsearch.search.SearchService.parseSource(SearchService.java:873)
	at org.elasticsearch.search.SearchService.createContext(SearchService.java:667)
	at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:633)
	at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:377)
	at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:368)
	at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:365)
	at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77)
	at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.doRun(MessageChannelHandler.java:293)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

```

So I was wondering what this error could be caused by and if it could indicate why there are performance issues?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 13, 2021, 1:46pm UTC](https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540/2 "2021-07-13T13:46:56Z")

</div>

Hey,

can you share more information? What Elasticsearch version is this, what JVM version are you running?

Can you trigger this manually? Also, can you provide the full stack trace from the node where this occured? That would be awesome!

--Alex

---

<div class="post-metadata">

**Author:** ![Nikolaj\_K](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolaj_k/32/80310_2.png) [@Nikolaj\_K](https://discuss.elastic.co/u/Nikolaj_K)\
**Post date:** [July 13, 2021, 2:21pm UTC](https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540/3 "2021-07-13T14:21:57Z")

</div>

Yes, sure. It is Elasticsearch version 2.4.6 and it is OpenJDK version 1.8.0\_191.

I am not sure if it is possible to trigger it manually and it is the full stack trace in my question.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 13, 2021, 2:52pm UTC](https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540/4 "2021-07-13T14:52:02Z")

</div>

That is a four year old version, which has seen three new major versions in between, so it is definetely not supported anymore. Any possibility for upgrading in sight?

I'd be a little surprised if that is all the loglines in question, as the first line states, that this was a nested throw (unless that exception occured many times over in the running JVM).

Are you using long scripts in your queries? Apart from that I don't have too much other ideas and given the age of your version I don't think debugging further makes a ton of sense as I don't remember a lot of the nasty details from a long time ago...

---

<div class="post-metadata">

**Author:** ![Nikolaj\_K](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolaj_k/32/80310_2.png) [@Nikolaj\_K](https://discuss.elastic.co/u/Nikolaj_K)\
**Post date:** [July 13, 2021, 3:12pm UTC](https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540/5 "2021-07-13T15:12:02Z")

</div>

I am not sure if there is possibility of upgrading in sight.

Yes there are very long scripts in the queries, could it cause the issue?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 14, 2021, 8:29am UTC](https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540/6 "2021-07-14T08:29:59Z")

</div>

Yes, that is my only working assumption, as scripts get compiled to code and might produce bytecode that is hitting the above limitation.

---

<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:** [August 11, 2021, 8:30am UTC](https://discuss.elastic.co/t/method-code-too-large-error-in-elasticsearch-logs/278540/7 "2021-08-11T08:30:46Z")

</div>

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