-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
SearchSearch query, autocomplete ...etcSearch query, autocomplete ...etcbugSomething isn't workingSomething isn't working
Description
Describe the bug
When collapsing search results with concurrent segment search enabled, an assertion error shardIndex is already set
is triggered here:
OpenSearch/server/src/main/java/org/opensearch/action/search/SearchPhaseController.java
Line 248 in 8f310f5
assert topDocs.scoreDocs.length == 0 || topDocs.scoreDocs[0].shardIndex == -1 : "shardIndex is already set"; |
, seems that we set the shardIndex twice.
Related component
Search
To Reproduce
- Run OpenSearch in debugging mode
- Enable concurrent segment search and execute search with field collapsing and
PUT abcd_test/_settings
{
"index.search.concurrent_segment_search.mode": "all"
}
GET abcd_test/_search?size=1
{
"query": {
"match": {
"b": "1"
}
},
"collapse": {
"field": "a"
}
}
Then you can see that an assertion error crashes the node
[2025-08-13T16:23:50,319][ERROR][o.o.b.OpenSearchUncaughtExceptionHandler] [node-1] fatal error in thread [opensearch[node-1][search][T#2]], exiting
java.lang.AssertionError: shardIndex is already set
at org.opensearch.action.search.SearchPhaseController.setShardIndex(SearchPhaseController.java:248) ~[classes/:?]
at org.opensearch.action.search.QueryPhaseResultConsumer$PendingMerges.consumeTopDocs(QueryPhaseResultConsumer.java:489) ~[classes/:?]
at org.opensearch.action.search.QueryPhaseResultConsumer.reduce(QueryPhaseResultConsumer.java:150) ~[classes/:?]
at org.opensearch.action.search.FetchSearchPhase.innerRun(FetchSearchPhase.java:136) ~[classes/:?]
at org.opensearch.action.search.FetchSearchPhase$1.doRun(FetchSearchPhase.java:122) ~[classes/:?]
at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52) ~[classes/:?]
at org.opensearch.threadpool.TaskAwareRunnable.doRun(TaskAwareRunnable.java:78) ~[classes/:?]
at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52) ~[classes/:?]
at org.opensearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:59) ~[classes/:?]
at org.opensearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:975) ~[classes/:?]
at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52) ~[classes/:?]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
at java.base/java.lang.Thread.run(Thread.java:1575) [?:?]
Expected behavior
shardIndex
of the topDocs should be set only once.
Additional Details
Host/Environment (please complete the following information):
- Version [3.2 and main branch]
Metadata
Metadata
Assignees
Labels
SearchSearch query, autocomplete ...etcSearch query, autocomplete ...etcbugSomething isn't workingSomething isn't working
Type
Projects
Status
β
Done