jira groovy creation subtasks

I try to create 2 subtasks in groovy worflow postfunction.

The same groovy script leads to different results on 2 JIRA instances (the same version 6.3)

On JIRA1 - it's fine.

On JIRA2: it's hanging up.I got error as the result.

Actually subtask1 is created fine, but while creation of subtask2 it's hanging on

IssueService.IssueResult createResult = issueService.create(currentUser, validationResult);

and can't perform it

as I see it cannot get the next key in project

 

mysql admin shows that "UPDATE project .." is performing

java processes

 

   java.lang.Thread.State: WAITING (parking)

    at sun.misc.Unsafe.park(Native Method)

    - parking to wait for  <0x00000004d2b80630> (a java.util.concurrent.FutureTask)

    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)

    at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:425)

    at java.util.concurrent.FutureTask.get(FutureTask.java:187)

    at com.atlassian.jira.project.DefaultProjectManager$NextIdGenerator.getNextId(DefaultProjectManager.java:911)

 

and as result

java.util.concurrent.ExecutionException: com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while updating: [GenericEntity:Project][id,10532]

 

so seems transaction isolation level on JIRA1 and jira2 are not the same - but I'm not familiar to it at all

could you help please to find out how to fix it on jira2?

 

Thanks in advance.

5 answers

0 vote

Is it the same DBMS in both cases?

different instances of mysql 5.6

0 vote

Searching the web I can only see this problem in relation to mysql, although older versions of jira. Have you asked Atlassian support? Do you get this problem only when programatically creating issues? Can you post the full script?

I haven't asked Atlassian yet - it looks like the reason is obvious - but I can't see it unfortunatelly

yes, I've bumped the problem in groovy only (when programatically creating issues)

mutableIssue = issue;

//here we take list of users from custom field

for (ApplicationUser executor : executors) {
        Object assignee = executor.getName();

        IssueService issueService = ComponentAccessor.getIssueService();
        IssueInputParameters params = issueService.newIssueInputParameters();
        params.setProjectId(mutableIssue.getProjectId());
        params.setIssueTypeId(issueType.getId());
        params.setSummary(mutableIssue.getSummary());
        params.setReporterId(currentUser.name);
        params.setAssigneeId(assignee);
        params.setDescription(mutableIssue.getDescription());


  
        IssueService.CreateValidationResult validationResult = issueService.validateSubTaskCreate(currentUser, mutableIssue.getId(), params);
    
        if (validationResult.isValid()) {
            IssueService.IssueResult createResult = issueService.create(currentUser, validationResult);
            if (createResult.isValid()) {
                MutableIssue newSubtask = createResult.getIssue();

                ComponentAccessor.getSubTaskManager().createSubTaskIssueLink(mutableIssue, newSubtask, currentUser);
            } else {
                println("Creating sub-task failed. Parent issue: " + mutableIssue.getKey());
    
            }
        } else {
            println("Validation creating sub-task failed. Parent issue: " + mutableIssue.getKey());
        }
}

Cannot see an issue there... Is the configuration of both mysql instances the same, eg storage engine? Any other differences between the two jira instances? Is the failing one a test instance, in which case you could try a different DBMS to isolate the problem?

as I know for the moment it's due to the trigger on jiraissue table that setup pkey field value:

delimiter |
CREATE TRIGGER `create_issue_set_pkey` BEFORE INSERT ON jiraissue

FOR EACH ROW
BEGIN

set NEW.pkey = CONCAT(
  (select max(project.pkey) from project where project.id = NEW.project),
  '-',
  NEW.issuenum);
END

 

seems it somehow locks update of counter in project table while creation of 2 ок more issues in grrovy

trigger... is this something you added? I'm not that familiar with mysql, is it what is used instead of sequences in other systems?

yes, it's added to remain filling on pkey field https://answers.atlassian.com/questions/222348/jira-6.1-the-issue-keys-have-disappeared-in-the-database actually this trigger works while insert into jiraissue table and it generates pkey value

I'm not sure I understand... so it's a trigger you added? If so, does the subtask creation work if you disable/remove that trigger?

yes, I added this trigger. And subtasks are created if I drop trigger.

So, seems I have to decide to does trigger impact.

Thanks for your help.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

70 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you