"Trying to create too many scroll contexts" Is Returned When the update-by-query Command Is Executed
Symptom
When I run the update-by-query command in an Elasticsearch cluster, the error message "Trying to create too many scroll contexts." is displayed. The specific error information is as follows:
{"error":{"root_cause":[{"type":"exception","reason":"Trying to create too many scroll contexts. Must be less than or equal to: [100000]. This limit can be set by changing the [search.max_open_scroll_context] setting."},{"type":"exception","reason":"Trying to create too many scroll contexts. Must be less than or equal to: [100000]. ...... Possible Causes
Each time a cluster calls the scroll creation API, a scroll context is created. When the number of scroll contexts reaches the preset threshold, no more scrolls can be created.
Procedure
GET /_nodes/stats/indices/search
When the value reaches the upper limiter, use either of the following methods to solve the problem.
- Method 1: Delete unnecessary scrolls to release the storage space of scroll contexts.
DELETE /_search/scroll { "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==" } - Method 2: Change the value of search.max_open_scroll_context to increase the storage space for scroll contexts.
PUT /_cluster/settings { "persistent": { "search.max_open_scroll_context": 50000 }, "transient": { "search.max_open_scroll_context": 50000 } }The value used in this example is for reference only. Set this value based on the actual size of your cluster.