Inconsistent paginated API search result while using JQL
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs 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
Summary
In certain situations, Jira might show inconsistent results when searching for tickets using its API that includes duplicates. For example , when using api/2/search and the number of results exceeds 1000 or maxResults variable, it is possible to find duplicate results in page 1 and page 2 or any consecutive page.
The same behavior is also seen when making the search against a data center installation base URL, if the requests for page 1 and page 2 go to different nodes some of the results might appear as duplicates.
Environment
Jira 7,8,9
Diagnosis
The returned issue keys are not unique across the API result pages.
In the case of a data center installation, index replication must be working with no problems and the healthcheck is not failing.
Cause
Jira pulls different pages results if :
The data position shifts: while the request to the search endpoint was running, new data that match the JQL search criteria was added.The data will shift forward or backward on the pages.The behavior can be validated using the updated field to see when tickets were changed. There is an open suggestion to improve this behavior: JRASERVER-69860 - Issues may not be visible when using the REST API and pagination.
Multiple issues have an equal value of the field used for sorting (For example "End date") Jira can't guarantee the order will be preserved among them. Per Lucene docs, when issues are equal on all sorting fields the final order is determined by internal docid, which is an uncontrollable value.
Solution
Add a second sorting criteria to the JQL clause for example , we added id to the clause
ORDER BY "End date",id desc
to keep tickets in order and avoid showing results on different pagesIn a data center installation, it is preferred to use
Dedicated API node or bypass the reverse proxy
Session stickiness cookie, so the load balancer routes all the calls to the same node more details on Load balancer configuration options
Was this helpful?