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 https://jira.atlassian.com/browse/JRASERVER-60928.

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 {it.name == '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 {it.name == '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 {it.name == 'ZZZ'};
issue.setCustomFieldValue(zzz, null);
 
//Put AAA in the affects version
Version version = ComponentAccessor.getVersionManager().getVersion(issue.getProjectId(), 'AAA');
issue.setAffectedVersions([version]);
 
//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'
    labelManager.addLabel(user,issue.id,bbblabel,false)
}
UserMessageUtil.success('TEST MESSAGE')

Thanks in advance

Neil

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?
Thanks

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,121 views 13 19
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot