执行命令update-by-query报错“Trying to create too many scroll contexts”
问题现象
云搜索服务的Elasticsearch集群执行命令update-by-query,出现报错“Trying to create too many scroll contexts.” ,具体报错信息如下:
{"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]. ......
原因分析
当集群每调用一次scroll的创建接口,都会新建一个scroll使用的context,当scroll contexts的数目达到预定值时,将无法继续创建scroll。
处理步骤
GET /_nodes/stats/indices/search
当数目达到最大值时,可以通过以下两种方式解决。
- 方式一:删除无用的scroll,释放scroll contexts的存储空间。
DELETE /_search/scroll { "scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="}
- 方式二:调整“search.max_open_scroll_context”的值,增加scroll contexts的存储空间。
PUT /_cluster/settings { "persistent" : { "search.max_open_scroll_context": 2012345678 }, "transient": { "search.max_open_scroll_context": 2012345678 } }