Duplicate tasks appearing in My Tasks or Task Reports

Still need help?

The Atlassian Community is here for you.

Ask the community

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.

postgres
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";
mysql, Oracle, MSSQL
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.

postgres
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")));
oracle, mssql
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)))
mysql
 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));

Last modified on Oct 12, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.