How to fix duplicate issue keys in Jira
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
There are two or more issues with the same key, which isn't expected by Jira and leads to a multitude of errors when searching issues, loading Dashboards or Roadmap Plans.
Environment
All versions of Jira Core 7.x and 8.x.
Solution
Please make sure to back up your database before performing any changes.
The query below should list all duplicate issues and their respective internal IDs:
1
2
3
4
5
select p.id as "Project ID", p.pkey as "Project Key", a.issuenum as "Issue Num", a.id as "Issue A ID", b.id as "Issue B ID"
from jiraissue a
join jiraissue b on a.issuenum = b.issuenum and a.project = b.project and a.id < b.id
join project p on a.project = p.id
where a.id is not null;
Stop Jira (all Datacenter nodes) and perform the following update for each of the entries above, replacing <Project ID>
and <Issue B ID>
accordingly:
1
update jiraissue set issuenum = (select (max(issuenum) + 1) from jiraissue where project = <Project ID>) where id = <Issue B ID>;
Start Jira and perform a full lock & reindex in one of the nodes. If running Jira Server, you may start a background reindex.
Was this helpful?