jira groovy creation subtasks

Alex Kiselev _Itransition_ January 10, 2016

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 votes
Alex Kiselev _Itransition_ January 13, 2016

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

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 14, 2016

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

Alex Kiselev _Itransition_ January 14, 2016

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

Jamie Echlin _ScriptRunner - The Adaptavist Group_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 14, 2016

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?

Alex Kiselev _Itransition_ January 14, 2016

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.

0 votes
Alex Kiselev _Itransition_ January 10, 2016

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());
        }
}
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2016

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?

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2016

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?

0 votes
Alex Kiselev _Itransition_ January 10, 2016

different instances of mysql 5.6

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2016

Is it the same DBMS in both cases?

Suggest an answer

Log in or Sign up to answer