You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a corner case where sort is failing on nested field after this PR #7453. When nested field is date and have filter in nest field has now() function call.
OpenSearch prevents SortFields' initialization in such cases more then one time.
This is very corner scenario but I added integ tests for that as we did have any integ test.
As a mitigation, I am pssing already initialized SortAndFormats in ContextIndexSearcher in this PR. In fact I also made change to invoke that if clause only if SearchContext contains searchAfter,
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "could not read the current timestamp"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "test_sort_nested_date2",
"node": "WT1VH4gyTVGVZyi_tNMO-Q",
"reason": {
"type": "parse_exception",
"reason": "could not read the current timestamp",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "features that prevent cachability are disabled on this context"
}
}
}
]
},
"status": 400
}
Server side traces are corelated with canMatchSearchAfter where we are trying to initialize SortAndFormats again to get MinMax values.
[2023-10-21T12:21:59,877][DEBUG][o.o.a.s.TransportSearchAction] [bc908df47a785e9192f108cf1282c4e4] All shards failed for phase: [query]
OpenSearchParseException[could not read the current timestamp]; nested: IllegalArgumentException[features that prevent cachability are disabled on this context];
at org.opensearch.common.time.JavaDateMathParser.parse(JavaDateMathParser.java:83)
at org.opensearch.index.mapper.DateFieldMapper$DateFieldType.parseToLong(DateFieldMapper.java:510)
at org.opensearch.index.mapper.DateFieldMapper$DateFieldType.lambda$dateRangeQuery$1(DateFieldMapper.java:464)
at org.opensearch.index.mapper.DateFieldMapper$DateFieldType.handleNow(DateFieldMapper.java:493)
at org.opensearch.index.mapper.DateFieldMapper$DateFieldType.dateRangeQuery(DateFieldMapper.java:459)
at org.opensearch.index.mapper.DateFieldMapper$DateFieldType.rangeQuery(DateFieldMapper.java:434)
at org.opensearch.index.query.RangeQueryBuilder.doToQuery(RangeQueryBuilder.java:527)
at org.opensearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:117)
at org.opensearch.index.query.BoolQueryBuilder.addBooleanClauses(BoolQueryBuilder.java:346)
at org.opensearch.index.query.BoolQueryBuilder.doToQuery(BoolQueryBuilder.java:329)
at org.opensearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:117)
at org.opensearch.search.sort.SortBuilder.resolveNestedQuery(SortBuilder.java:245)
at org.opensearch.search.sort.SortBuilder.resolveNested(SortBuilder.java:203)
at org.opensearch.search.sort.FieldSortBuilder.nested(FieldSortBuilder.java:588)
at org.opensearch.search.sort.FieldSortBuilder.build(FieldSortBuilder.java:411)
at org.opensearch.search.sort.SortBuilder.buildSort(SortBuilder.java:166)
at org.opensearch.search.sort.FieldSortBuilder.getMinMaxOrNullInternal(FieldSortBuilder.java:631)
at org.opensearch.search.sort.FieldSortBuilder.getMinMaxOrNullForSegment(FieldSortBuilder.java:626)
at org.opensearch.search.internal.ContextIndexSearcher.canMatchSearchAfter(ContextIndexSearcher.java:499)
at org.opensearch.search.internal.ContextIndexSearcher.canMatch(ContextIndexSearcher.java:491)
at org.opensearch.search.internal.ContextIndexSearcher.searchLeaf(ContextIndexSearcher.java:309)
at org.opensearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:295)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:551)
at org.opensearch.search.query.QueryPhase.searchWithCollector(QueryPhase.java:341)
at org.opensearch.search.query.QueryPhase$DefaultQueryPhaseSearcher.searchWithCollector(QueryPhase.java:419)
at org.opensearch.search.query.QueryPhase$DefaultQueryPhaseSearcher.searchWith(QueryPhase.java:408)
at org.opensearch.search.query.QueryPhase.executeInternal(QueryPhase.java:263)
at org.opensearch.search.query.QueryPhase.execute(QueryPhase.java:150)
at org.opensearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:527)
at org.opensearch.search.SearchService.executeQueryPhase(SearchService.java:591)
at org.opensearch.search.SearchService$2.lambda$onResponse$0(SearchService.java:560)
at org.opensearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:73)
at org.opensearch.action.ActionRunnable$2.doRun(ActionRunnable.java:88)
at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52)
at org.opensearch.threadpool.TaskAwareRunnable.doRun(TaskAwareRunnable.java:78)
at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52)
at org.opensearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:59)
at org.opensearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:815)
at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalArgumentException: features that prevent cachability are disabled on this context
at org.opensearch.index.query.QueryShardContext.failIfFrozen(QueryShardContext.java:521)
at org.opensearch.index.query.QueryShardContext.nowInMillis(QueryShardContext.java:555)
at org.opensearch.index.mapper.DateFieldMapper$DateFieldType.lambda$handleNow$2(DateFieldMapper.java:491)
at org.opensearch.common.time.JavaDateMathParser.parse(JavaDateMathParser.java:81)
... 41 more
Host/Environment (please complete the following information):
OS: [All]
Version [>=2.8]
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Description
There is a corner case where sort is failing on nested field after this PR #7453. When nested field is date and have
filter
in nest field hasnow()
function call.OpenSearch prevents SortFields' initialization in such cases more then one time.
This is very corner scenario but I added integ tests for that as we did have any integ test.
As a mitigation, I am pssing already initialized
SortAndFormats
in ContextIndexSearcher in this PR. In fact I also made change to invoke that if clause only if SearchContext contains searchAfter,How to repro the issue
This search query failes with below Exception,
Server side traces are corelated with canMatchSearchAfter where we are trying to initialize SortAndFormats again to get MinMax values.
Host/Environment (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: