# Update\_by\_query crashing w/large scroll\_size

**URL:** <https://discuss.elastic.co/t/update-by-query-crashing-w-large-scroll-size/182291>\
**Category:** Elasticsearch\
**Created:** [May 22, 2019, 5:18pm UTC](https://discuss.elastic.co/t/update-by-query-crashing-w-large-scroll-size/182291 "2019-05-22T17:18:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bobby\_Buten](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bobby_buten/32/46653_2.png) [@Bobby\_Buten](https://discuss.elastic.co/u/Bobby_Buten)\
**Post date:** [May 22, 2019, 5:18pm UTC](https://discuss.elastic.co/t/update-by-query-crashing-w-large-scroll-size/182291/1 "2019-05-22T17:18:21Z")

</div>

I have the following issue with update\_by\_query, it crashes when my scroll\_size is large

1. Using Elasticsearch 5.5.3
2. My index has 1 shard
3. I use this \_update\_by\_query, I'm trying to add a username to \_licensed\_by

```auto
POST /my_index/_update_by_query?conflicts=proceed 
{
  "script": {
    "inline": "ctx._source._licensed_by.add(params.username)",
    "params": {
      "username": "test1"
    },
    "lang": "painless"
  }
}

```

If I run this where scroll\_size=100, it works  
If I run this where scroll\_size=500, it usually works  
If I run this where scroll\_size=1000 (the default), it fails

The error that is returned is:

```
{
"error": {
    "root_cause": [
        {
            "type": "search_context_missing_exception",
            "reason": "No search context found for id [81]"
        }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
        {
            "shard": -1,
            "index": null,
            "reason": {
                "type": "search_context_missing_exception",
                "reason": "No search context found for id [81]"
            }
        }
    ],
    "caused_by": {
        "type": "search_context_missing_exception",
        "reason": "No search context found for id [81]"
    }
},
"status": 404
}

```

Here are the errors in the Elasticsearch logs:

```
2019-05-21T18:27:52.109840745Z org.elasticsearch.search.SearchContextMissingException: No search context found for id [82]
2019-05-21T18:27:52.109847142Z at org.elasticsearch.search.SearchService.findContext(SearchService.java:443) ~[elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.109859304Z at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:379) ~[elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.109864878Z at org.elasticsearch.action.search.SearchTransportService$10.messageReceived(SearchTransportService.java:373) ~[elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.109869594Z at org.elasticsearch.action.search.SearchTransportService$10.messageReceived(SearchTransportService.java:370) ~[elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.109900496Z at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.109906483Z at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:644) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.109918010Z at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.109924004Z at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.109928824Z at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_141]
2019-05-21T18:27:52.109933573Z at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_141]
2019-05-21T18:27:52.109938089Z at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
2019-05-21T18:27:52.110191968Z [2019-05-21T18:27:52,110][TRACE][o.e.t.T.tracer] [dev-app-server] [17064][indices:data/read/search[phase/query+fetch/scroll]] received response from [{dev-app-server}{O1ElqbrtR2OcFlaygS3ziw}{xl5lK9a4TC6ofSZ1-dzkkg}{172.25.0.2}{172.25.0.2:9300}]
2019-05-21T18:27:52.111560699Z [2019-05-21T18:27:52,110][WARN][o.e.i.r.TransportUpdateByQueryAction] [dev-app-server] giving up on search because it failed with a non-retryable exception
2019-05-21T18:27:52.111574089Z org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed
2019-05-21T18:27:52.111579537Z at org.elasticsearch.action.search.SearchScrollAsyncAction.onShardFailure(SearchScrollAsyncAction.java:213) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111584561Z at org.elasticsearch.action.search.SearchScrollAsyncAction$1.onFailure(SearchScrollAsyncAction.java:141) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111589409Z at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:51) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111594349Z at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1067) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111599361Z at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1171) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111604231Z at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1149) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111617980Z at org.elasticsearch.transport.TransportService$7.onFailure(TransportService.java:655) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111623361Z at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.onFailure(ThreadContext.java:623) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111628210Z at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39) [elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111632949Z at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_141]
2019-05-21T18:27:52.111637431Z at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_141]
2019-05-21T18:27:52.111641975Z at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
2019-05-21T18:27:52.111652031Z Caused by: org.elasticsearch.transport.RemoteTransportException: [dev-app-server][172.25.0.2:9300][indices:data/read/search[phase/query+fetch/scroll]]
2019-05-21T18:27:52.111657336Z Caused by: org.elasticsearch.search.SearchContextMissingException: No search context found for id [82]
2019-05-21T18:27:52.111662827Z at org.elasticsearch.search.SearchService.findContext(SearchService.java:443) ~[elasticsearch-5.5.3.jar:5.5.3]
2019-05-21T18:27:52.111667565Z at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:379) ~[elasticsearch-5.5.3.jar:5.5.3]
Truncated due to size limitation

```

Any thoughts on this? What might be causing update\_by\_query to fail? What are all shards failing? What more can I do to troubleshoot?

---

<div class="post-metadata">

**Author:** ![RyanCrace](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryancrace/32/47463_2.png) [@RyanCrace](https://discuss.elastic.co/u/RyanCrace)\
**Post date:** [June 4, 2019, 1:24pm UTC](https://discuss.elastic.co/t/update-by-query-crashing-w-large-scroll-size/182291/2 "2019-06-04T13:24:01Z")

</div>

> [@Bobby\_Buten](#):
>
> update\_by\_query

I'm having a similar issue with update\_by\_query. What's the deal with this turd?

---

<div class="post-metadata">

**Author:** ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)\
**Post date:** [June 7, 2019, 1:11pm UTC](https://discuss.elastic.co/t/update-by-query-crashing-w-large-scroll-size/182291/3 "2019-06-07T13:11:26Z")

</div>

Hi @Bobby_Buten,

one possible reason for this could be if writing the updates into the index is slow. If writing 1000 documents take more than 5 minutes (which sounds very slow), the scroll query will time out. If you have DEBUG logging enabled, you should see a message saying something like: `freeing search context...` in the log file on the node holding the shard copy doing the query.

If this is the case, I think your investigation should center around why writing is slow.

---

<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:** [July 5, 2019, 1:11pm UTC](https://discuss.elastic.co/t/update-by-query-crashing-w-large-scroll-size/182291/4 "2019-07-05T13:11:33Z")

</div>

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