-
Notifications
You must be signed in to change notification settings - Fork 24.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IndexOutOfBoundsException fetch innerhits #93117
Comments
Any updates about this issue? |
Pinging @elastic/es-search (Team:Search) |
Thanks for reporting! It looks from the stack trace as though you're using elasticsearch 8.4.3, not 8.6? This area of the code has seen a lot of changes recently so it's difficult to work out what the error might be. Can you try it on 8.6 and see if you get the same problem, and if so post the stack trace again? |
Sorry for that. i tried different version but the problem is still there in 8.6
|
Thanks, that makes it a lot easier to track down! So I think the issue is that the nested source is not in the shape that we are expecting it. The error is caused by the source processing code trying to extract the 43rd child doc from the root source, but the source itself thinks that it has only one child, hence:
I think it's going to be something to do with the multiple nesting and mix of object and array notation in your example document, but you've given me enough to work out what is going on and I will work on a fix. |
When executing the copy_to mappings on a nested doc, if the location was underneath another nested mapper then the document parser could end up adding a new nested path metadata field for the source to the destination document. This was mostly ignored, but could make calculation of a NestedIdentity incorrect, leading to exceptions when loading the source of a nested document during the fetch phase. This commit moves all of the nested path handling directly into DocumentParserContext.createNestedContext(), which already has some logic to detect if we're in a copy_to context. Fixes #93117
Elasticsearch Version
8.6.0
Installed Plugins
No response
Java Version
bundled
OS Version
docker-image = docker.elastic.co/elasticsearch/elasticsearch:8.6
Problem Description
We are trying to migrate from Elasticsearch 6.7.1 to Elasticsearch 8.6.0.
With the same document we always get IndexOutOfBoundsException while trying to fetch innerhits in Elasticsearch 8.6.0. Everything works fine in Elasticsearch 6.7.1.
Steps to Reproduce
elasticsearch_6.7.1 (1).txt
elasticsearch_8.6.0.txt
Logs (if relevant)
{"@timestamp":"2023-01-20T13:39:21.170Z", "log.level": "WARN", "message":"path: /test/_search, params: {index=test}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[es01][search][T#10]","log.logger":"rest.suppressed","elasticsearch.cluster.uuid":"T3_Kb_fZTOORKN7Bn5jz2g","elasticsearch.node.id":"fESFHfZ-RxuDaPIIKhOoNA","elasticsearch.node.name":"es01","elasticsearch.cluster.name":"es_alex","error.type":"org.elasticsearch.action.search.SearchPhaseExecutionException","error.message":"all shards failed","error.stack_trace":"Failed to execute phase [query], all shards failed; shardFailures {[fESFHfZ-RxuDaPIIKhOoNA][test][0]: org.elasticsearch.transport.RemoteTransportException: [es01][172.27.0.2:9300][indices:data/read/search[phase/query]]\nCaused by: org.elasticsearch.search.fetch.FetchPhaseExecutionException: Fetch Failed [Error running fetch phase for doc [73]]\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.buildSearchHits(FetchPhase.java:181)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:93)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:659)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:634)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.SearchService.lambda$executeQueryPhase$2(SearchService.java:489)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:769)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.base/java.lang.Thread.run(Thread.java:833)\nCaused by: org.elasticsearch.search.fetch.FetchPhaseExecutionException: Fetch Failed [Error running fetch phase for doc [43]]\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.buildSearchHits(FetchPhase.java:181)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:93)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.subphase.InnerHitsPhase.hitExecute(InnerHitsPhase.java:76)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.subphase.InnerHitsPhase$1.process(InnerHitsPhase.java:52)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.buildSearchHits(FetchPhase.java:177)\n\t... 13 more\nCaused by: java.lang.IndexOutOfBoundsException: Index: 43, Size: 1\n\tat java.base/java.util.Collections$SingletonList.get(Collections.java:4959)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.prepareNestedHitContext(FetchPhase.java:466)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.prepareHitContext(FetchPhase.java:312)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.buildSearchHits(FetchPhase.java:165)\n\t... 17 more\n}\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:728)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:418)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:760)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:512)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:349)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.ActionListener$Delegating.onFailure(ActionListener.java:92)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:48)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:642)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.transport.TransportService$UnregisterChildTransportResponseHandler.handleException(TransportService.java:1650)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1390)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1512)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1487)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:50)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.support.ChannelActionListener.onFailure(ChannelActionListener.java:48)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.ActionRunnable.onFailure(ActionRunnable.java:77)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:28)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:769)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.base/java.lang.Thread.run(Thread.java:833)\nCaused by: org.elasticsearch.ElasticsearchException$1: Index: 43, Size: 1\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:638)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:416)\n\t... 20 more\nCaused by: java.lang.IndexOutOfBoundsException: Index: 43, Size: 1\n\tat java.base/java.util.Collections$SingletonList.get(Collections.java:4959)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.prepareNestedHitContext(FetchPhase.java:466)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.prepareHitContext(FetchPhase.java:312)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.buildSearchHits(FetchPhase.java:165)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:93)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.subphase.InnerHitsPhase.hitExecute(InnerHitsPhase.java:76)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.subphase.InnerHitsPhase$1.process(InnerHitsPhase.java:52)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.buildSearchHits(FetchPhase.java:177)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:93)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:659)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:634)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.search.SearchService.lambda$executeQueryPhase$2(SearchService.java:489)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)\n\tat org.elasticsearch.server@8.4.3/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\t... 6 more\n"}
The text was updated successfully, but these errors were encountered: