Scriptrunner deadlocking problem with SQL Server

I am attempting to to clone an issue as part of a workflow post-function using Scriptrunner (v4.3.16) on Jira Software (v7.1.1), running against MS SQL Server 2008. I have hit a problem with database connections going crazy, bringing down Jira. This looks to be the issue reported in

At some point while developing the script, it worked fine. Then I added more logic to set particular custom field values on the new issue, and it broke. I'm not exactly sure when it broke though. 

While I investigate the database level workaround described on JAC, can anyone advise on any particular functions I should avoid in my script to get round the problem?

This is my code from additional issue actions:

import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.label.LabelManager
//Don't clone links
checkLink = {link -> false};
//Don't clone attachments
checkAttachment = {attachment -> false};
//Get the XXX field and put XXX1 in it. XXX is a multi-select field
//I'm fairly sure this part worked fine
def xxx = customFieldManager.getCustomFieldObjects(issue).find { == 'XXX'};
def xxxfieldconfig = xxx.getRelevantConfig(issue)
def xxxoption = ComponentAccessor.optionsManager.getOptions(xxxfieldconfig)?.find { it.toString() == 'XXX1' }
issue.setCustomFieldValue(xxx, [xxxoption]);
//Get the YYY field and put "YYY1" in it - YYY is a select (single) field
def yyy = customFieldManager.getCustomFieldObjects(issue).find { == 'YYY'};
def yyyfieldconfig = yyy.getRelevantConfig(issue)
def yyyoption = ComponentAccessor.optionsManager.getOptions(yyyfieldconfig)?.find { it.toString() ==  'YYY1' }
issue.setCustomFieldValue(yyy, yyyoption);
//Get the ZZZ status field and clear it - ZZZ is a select (single) field
def zzz = customFieldManager.getCustomFieldObjects(issue).find { == 'ZZZ'};
issue.setCustomFieldValue(zzz, null);
//Put AAA in the affects version
Version version = ComponentAccessor.getVersionManager().getVersion(issue.getProjectId(), 'AAA');
//Stick "CLONE" on the front of the summary
issue.summary = '[CLONE] -' + sourceIssue.summary
//Have to do this after issue creation for some reason
doAfterCreate = {
//Put BBB label on the issue
    def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
    LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
    def bbblabel = 'BBB'
UserMessageUtil.success('TEST MESSAGE')

Thanks in advance


2 answers

Hi Neil, 

You script seems fine to me. Actually my question is in which step is your post function and also it's order among the other post functions. 

regards, Thanos

Hi Thanos

It's a completely bespoke workflow, with statuses Open, Review, Release, Testing and Closed. The transitions are fairly flexible, but the typical path of an issue is Open > Review > Open > Release > Testing > Closed. 

The clone post-function is on the Open > Release transition.

I've remove the clone function now, but i'm fairly sure it was in the default position (i.e. first) compared to the existing post-functions. So it would have been:

  1. Scriptrunner workflow function - Clones an issue and links
  2. Set issue status to the linked status...
  3. Add a comment to an issue if one is entered...
  4. Update change history...
  5. Re-index....
  6. Fire a "Generic Event"....

Hi Thanos. Did the information I provided above give any clues as to what the problem might be?

Following up my own post...

Would I avoid this problem if, instead of scripting the clone as part of the workflow transition, I instead did it as a Scripted Listener?

(Don't have a test environment available right now, and don't want to try it out and bring down Jira again)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

135 views 0 6
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