Performance problems when sorting by custom field
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
The result of searches take long time to complete when sorting by custom field and JIRA instance may run into frequent GCs.
Thread dumps contain com.atlassian.jira.issue.search.parameters.lucene.sort.DocumentSortComparatorSource$InternalFieldComparator which has a refence to a huge com.atlassian.jira.issue.Issue array.:
"http-bio-8090-exec-24" daemon prio=5 tid=7fdb10959800 nid=0x11a0f7000 runnable [11a0ed000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
...
at com.atlassian.jira.issue.fields.CustomFieldImpl$CustomFieldIssueSortComparator.compare(CustomFieldImpl.java:1974)
at com.atlassian.jira.issue.search.parameters.lucene.sort.DefaultIssueSortComparator.compare(DefaultIssueSortComparator.java:37)
at com.atlassian.jira.issue.search.parameters.lucene.sort.DocumentSortComparatorSource$InternalFieldComparator.compareBottom(DocumentSortComparatorSource.java:89)
at org.apache.lucene.search.TopFieldCollector$MultiComparatorNonScoringCollector.collect(TopFieldCollector.java:404)
at org.apache.lucene.search.IndexSearcher.searchWithFilter(IndexSearcher.java:575)
Cause
This issue is caused by a know bug: JRASERVER-33365 - Issue Search has performance problems when sorting by custom field Labels
Workaround
- Remove the sorting by custom field from the search filters;
Watch the bug report for further updates.