Description
When searching for issues ordered by an SLA’s remaining time, including while viewing queues and filter gadgets, the search occasionally fails with the following error on the server:
java.lang.IllegalArgumentException: com.atlassian.servicedesk.internal.sla.metric.DateTimeRange - the START time of the DateTimeRange (2019-01-31T16:45:56.370Z) must be less than or equal to the STOP time (2019-01-31T16:45:37.941 at com.atlassian.servicedesk.internal.sla.metric.DateTimeRange.<init>(DateTimeRange.java:37) at com.atlassian.servicedesk.internal.sla.searcher.sorter.SlaOrderingCalculationServiceImpl.getRemainingTimeSortingData(SlaOrderingCalculationServiceImpl.java:51) at com.atlassian.servicedesk.internal.sla.searcher.sorter.RemainingTimeSorter.getValueFromLuceneField(RemainingTimeSorter.java:62) at com.atlassian.servicedesk.internal.sla.searcher.sorter.RemainingTimeSorter.getValueFromLuceneField(RemainingTimeSorter.java:27) at com.atlassian.jira.issue.search.parameters.lucene.sort.MappedSortComparator.getComparable(MappedSortComparator.java:179) at com.atlassian.jira.issue.search.parameters.lucene.sort.JiraLuceneFieldFinder.getCustom(JiraLuceneFieldFinder.java:64) at com.atlassian.jira.issue.search.parameters.lucene.sort.MappedSortComparator.getLuceneValues(MappedSortComparator.java:162) at com.atlassian.jira.issue.search.parameters.lucene.sort.MappedSortComparator$HungryValueFinder.getValue(MappedSortComparator.java:221) at com.atlassian.jira.issue.search.parameters.lucene.sort.MappedSortComparator$InternalFieldComparator.getDocumentValue(MappedSortComparator.java:119) at com.atlassian.jira.issue.search.parameters.lucene.sort.MappedSortComparator$InternalFieldComparator.copy(MappedSortComparator.java:95) at org.apache.lucene.search.TopFieldCollector$MultiComparatorNonScoringCollector.collect(TopFieldCollector.java:434) at org.apache.lucene.search.IndexSearcher.searchWithFilter(IndexSearcher.java:572) at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:532) at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:463) at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:433) at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:356) at com.atlassian.jira.index.DelegateSearcher.search(DelegateSearcher.java:142) at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.searchDocuments(LuceneSearchProvider.java:467) at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.runSearch(LuceneSearchProvider.java:449) at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.getHits(LuceneSearchProvider.java:217) at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:340) at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:114) at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:110) ... 2 filtered
Causes
SlaOrderingCalculationService#getRemainingTimeSortingData is called with “data” and “now” arguments such that data.shiftedStartDate > now, which in turn violates the DateTimeRange constructor’s contract.
The exact root cause is uncertain, but one possibility might be the creation of new issues during a long-running search. RemainingTimeSorter calculates the remaining time of each issue using its ongoing cycle’s start time and the current time, and the latter is cached for the duration of the search for deterministic results, making the ongoing cycles of affected issues appear to start in the future.
Workarounds
There are no known workarounds yet, other than retrying the affected searches.