Duplicate workflow drafts results in 500 errors when editing an affected workflow

Symptoms

When creating a draft workflow (invoking the Edit mode of a workflow which has a duplicated draft), a stack trace containing a message like this following is returned to the web browser:

java.lang.IllegalStateException: There are more than one draft workflows associated with the workflow named 'Workflow Name'

Cause

It's not certain how to reproduce this or what exactly causes the duplication of the drafts.

There's some hints on the cause being around concurrent uses of the workflows' editing feature. However, a test recently performed on our side returned no more than some {{404}} errors when two people were editing the same workflow.

The below bug was raised to our development and product management teams to study possible ways to resolve this.

JRA-40009 - Prevent JIRA from creating duplicate draft workflows Resolved

Diagnosis

Run the below query to find out whether you have duplicated drafts or not and also what workflows are affected by this.

SELECT
    COUNT(*) AS    "# of Drafts",
    parentname AS "Workflow",
    MAX(id) AS "Duplicate"
FROM
    jiradraftworkflows
GROUP BY
    parentname
HAVING
    count(*) > 1;

Workaround

Run the below query to delete the duplicated drafts.

Always backup your data before performing any modifications to the database.

DELETE FROM jiradraftworkflows WHERE id IN (
    SELECT max(id) FROM jiradraftworkflows GROUP BY parentname HAVING count(*) > 1);

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport