How to clear duplicate Issue Links or Issues in Epic 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
As a user, you may be faced with issues that present duplicate issue links where the same issues are listed two or more times for the same association. This can be either within the "Issues in epic" or "Issue Links" area of the Issue view.
It may look like this:

While the root cause can vary and should be investigated separately, this article will show you how to clear them individually or instance-wide to keep only distinct links. Note that the Integrity Checker will not list these as an issue, but since they can impact reports, I've created this content.
To determine if this applies to you, you may run the following SQL query in the Jira database:
1
select count(*),linktype,source,destination from "issuelink" group by linktype,source,destination having count(*) > 1;
Any results on the above indicate you have duplicates.
source
column refers to the issue ID fromjiraissue
table.
If you'd like to query for an individual issue, use the SQL query below where ISSUEID is seen on the bottom-left URL as you hover over the "Edit" button on "Issue View":

1
select count(*),linktype,source,destination from "issuelink" where source='ISSUEID' group by linktype,source,destination having count(*) > 1;
Environment
Tested on 8.13.15 and 8.20.8 but should apply to all versions.
Solution
Option #1 - Manual removal through the UI
If you're seeing this on individual issues, you may manually remove each duplicate link. For issue links you can only remove one of the duplicate but for Issues in Epic it will remove all duplicate and require you to recreate the association.
Option #2 - Removing directly from the database
Always back up your data before performing any modification to the database. If possible, try your modifications on a test server.
Clearing for an individual issue:
Replace ISSUEID with the ID seen on the bottom-left URL as you hover over the "Edit" button on "Issue View":
1
select count(*),linktype,source,destination from issuelink where source='ISSUEID' group by linktype,source,destination having count(*) > 1;
That will confirm that you have duplicates. After that, this command will remove the duplicates:
1
2
delete from issuelink where id in
(select a.id from issuelink a,issuelink b where a.id > b.id and a.source = b.source and a.destination = b.destination and a.linktype = b.linktype) and source ='ISSUEID';
Clearing for the entire instance:
1
select count(*),linktype,source,destination from issuelink group by linktype,source,destination having count(*) > 1;
That will show how many duplicates you have.
The next step will only leave one distinct link for each duplicate pair:
1
2
delete from issuelink where id in
(select a.id from issuelink a,issuelink b where a.id > b.id and a.source = b.source and a.destination = b.destination and a.linktype = b.linktype);
This is not expected to require a restart to take effect and a browser refresh should show the results immediately.
These steps will only remove exact duplicates where the issue link type is the same. Issue link type refers to "blocks", "relates to", etc. The information about being in an Epic is stored in the database as a unique link type which is why this method works for that as well.
Was this helpful?