Using Transport Client getting no hits but elastic log has CircuitBreakingException

I am using Java API to talk to Elasticsearch version 5.5.3. My queries were getting no hits. Only by looking at the elastic search logs found that it reached the memory limits while sorting. How is this exception lost or not thrown to the Java client? How do I ensure to get this exception on the Java client? Using a REST client, I can get the exception every time.

Here is the stack trace and I set the field data limit to a really small number to reproduce this issue.

oorg.elasticsearch.transport.RemoteTransportException: [localhost][127.0.0.1:9300][indices:data/read/search[phase/query]]
Caused by: org.elasticsearch.search.query.QueryPhaseExecutionException: Query Failed [Failed to execute main query]
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:414) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:108) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:248) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:263) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:330) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:327) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:644) [elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638) [elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.5.3.jar:5.5.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_162]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_162]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_162]
Caused by: org.elasticsearch.ElasticsearchException: java.util.concurrent.ExecutionException: CircuitBreakingException[[fielddata] Data too large, data for [name] would be [1085047/1mb], which is larger than the limit of [1048576/1mb]]
at org.elasticsearch.index.fielddata.plain.AbstractIndexFieldData.load(AbstractIndexFieldData.java:74) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource$1.getSortedDocValues(BytesRefFieldComparatorSource.java:92) ~[elasticsearch-5.5.3.jar:5.5.3]
at org.apache.lucene.search.FieldComparator$TermOrdValComparator.getLeafComparator(FieldComparator.java:767) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
at org.apache.lucene.search.FieldValueHitQueue.getComparators(FieldValueHitQueue.java:180) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
at org.apache.lucene.search.TopFieldCollector$SimpleFieldCollector.getLeafCollector(TopFieldCollector.java:100) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]

Update: Scratching my head on this because I was able to hit this every time a week ago. After trying a few different limits, I was able to reproduce this sometimes. It looks like if the required memory and limit memory is very close, then you can hit this.

Caused by: java.util.concurrent.ExecutionException: CircuitBreakingException[[fielddata] Data too large, data for [name] would be [386118/377kb], which is larger than the limit of [358400/350kb]]

However, in cases when the exception is thrown to the client, log also following which is absent in above case.

[2019-08-05T18:50:55,923][DEBUG][o.e.a.s.TransportSearchAction] [localhost] All shards failed for phase: [query]
org.elasticsearch.ElasticsearchException: java.util.concurrent.ExecutionException: CircuitBreakingException[[fielddata] Data too large, data for [name] would be [367561/358.9kb], which is larger than the limit of [1024/1kb]]
at org.elasticsearch.index.fielddata.plain.AbstractIndexFieldData.load(AbstractIndexFieldData.java:74) ~[elasticsearch-5.5.3.jar:5.5.3]

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