Duplicate tasks appearing in My Tasks or Task Reports
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
Duplicate tasks entries appear in the 'My Task' tab or in a Task Report Macro on a page.
Navigating to the page that contains the tasks will show the correct number of tasks.
Diagnosis
The following sql query can be run to determine the number of duplicate tasks present on your instance.
It finds duplicate tasks based on matching task id to the content id that the task appears on.
Please Note: This will not find any duplicates where the original task has been deleted from the page and exactly one duplicate remains.
select count(distinct t1."GLOBAL_ID")
from "AO_BAF3AA_AOINLINE_TASK" t2, "AO_BAF3AA_AOINLINE_TASK" t1
where t1."ID" = t2."ID" and t1."CONTENT_ID" = t2."CONTENT_ID" and t1."GLOBAL_ID" < t2."GLOBAL_ID";
select count(distinct t1.GLOBAL_ID)
from AO_BAF3AA_AOINLINE_TASK t2, AO_BAF3AA_AOINLINE_TASK t1
where t1.ID = t2.ID and t1.CONTENT_ID = t2.CONTENT_ID and t1.GLOBAL_ID < t2.GLOBAL_ID;
Cause
Tasks duplicate when a page containing tasks is reordered or another page has been reordered in the same space.
It can also be caused by blog posts with tasks when it contains a link to a page and that linked page is reordered.
For more information, please check the bug reports in:
CONF-33886 - Getting issue details... STATUS
CONFSERVER-58020 - Getting issue details... STATUS
Resolution
Since we will be deleting content from the database, please backup your Confluence database before making modifications as a safety precaution.
This query finds duplicate tasks based on the matching task id to the content id and then deletes the duplicates.
Please Note: This will not delete all duplicates, specifically if the task has been removed from the page, as one copy of the task will remain. A complete implementation is currently underway.
delete from "AO_BAF3AA_AOINLINE_TASK" where "GLOBAL_ID" in (select t1."GLOBAL_ID" from "AO_BAF3AA_AOINLINE_TASK" t1, "AO_BAF3AA_AOINLINE_TASK" t2 where t1."ID" = t2."ID" and t1."CONTENT_ID" = t2."CONTENT_ID" and ((t1."UPDATE_DATE" is null and t2."UPDATE_DATE" is null and t1."GLOBAL_ID" < t2."GLOBAL_ID") or (t1."UPDATE_DATE" is null and t2."UPDATE_DATE" is not null) or (t1."UPDATE_DATE" is not null and t2."UPDATE_DATE" is not null and t1."UPDATE_DATE" < t2."UPDATE_DATE")));
delete from AO_BAF3AA_AOINLINE_TASK where GLOBAL_ID in (select t1.GLOBAL_ID from AO_BAF3AA_AOINLINE_TASK t1, AO_BAF3AA_AOINLINE_TASK t2 where t1.ID = t2.ID and t1.CONTENT_ID = t2.CONTENT_ID and ((t1.UPDATE_DATE is null and t2.UPDATE_DATE is null and t1.GLOBAL_ID < t2.GLOBAL_ID) or (t1.UPDATE_DATE is null and t2.UPDATE_DATE is not null) or (t1.UPDATE_DATE is not null and t2.UPDATE_DATE is not null and t1.UPDATE_DATE < t2.UPDATE_DATE)))
delete t1 from AO_BAF3AA_AOINLINE_TASK t1, AO_BAF3AA_AOINLINE_TASK t2 where t1.ID = t2.ID and t1.CONTENT_ID = t2.CONTENT_ID and ((t1.UPDATE_DATE is null and t2.UPDATE_DATE is null and t1.GLOBAL_ID < t2.GLOBAL_ID) or (t1.UPDATE_DATE is null and t2.UPDATE_DATE is not null) or (t1.UPDATE_DATE is not null and t2.UPDATE_DATE is not null and t1.UPDATE_DATE < t2.UPDATE_DATE));