Help Center/ Cloud Search Service/ Troubleshooting/ Functions/ Error Message "Trying to create too many scroll contexts" Is Displayed When the update-by-query Command Is Executed
Updated on 2024-11-20 GMT+08:00

Error Message "Trying to create too many scroll contexts" Is Displayed 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

Run the following command to check the value of open_contexts (the number of scroll contexts):
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": 2012345678
    	},
    
    	"transient": {
    		"search.max_open_scroll_context": 2012345678
    	}
    }