Scriptrunner deadlocking problem with SQL Server

Neil Arrowsmith
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.
May 4, 2017

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

0 votes
Neil Arrowsmith
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.
June 8, 2017

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)

0 votes
Thanos Batagiannis _Adaptavist_
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.
May 10, 2017

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

Neil Arrowsmith
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.
May 11, 2017

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"....
Neil Arrowsmith
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.
July 11, 2017

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

Suggest an answer

Log in or Sign up to answer