项目场景:
springboot中使用ES7查询一个月内的数据量趋势时出错。在开发线上正常,演示线时出现异常
问题描述
项目在演示线环境的时候,出现查询异常
异常信息如下:
c
org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=circuit_breaking_exception, reason=[parent] Data too large, data for [<http_request>] would be [31741946644/29.5gb], which is larger than the limit of [31621696716/29.4gb], real usage: [31741945664/29.5gb], new bytes reserved: [980/980b], usages [request=0/0b, fielddata=896932/875.9kb, in_flight_requests=980/980b, model_inference=0/0b, accounting=89070922/84.9mb]]
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:187)
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1911)
at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1888)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1645)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1602)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1572)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:1088)
原因分析:
原因:ES默认的缓存设置是缓存区是只进不出的,一当缓存区不够时,就会抛出异常
解决方案:
API方式设置,无需重启ES
PUT _cluster/settings
{
"persistent" : {
"indices.breaker.fielddata.limit" : "40%"
}
}设置elasticsearch.yml文件,然后重启ES
indices.memory.index_buffer_size: 30%
indices.recovery.max_bytes_per_sec: 30mb
indices.fielddata.cache.size: 30%
indices.breaker.fielddata.limit: 40%
indices.breaker.request.limit: 40%
indices.breaker.total.use_real_memory: false
indices.breaker.total.limit: 70%
配置完后,重新查询,正常