Post function running over wrong issue
*This issue has moved*
This issue has been moved permanently to Adaptavist's Product Support JIRA instance.
All existing users of this instance should have the same username on our Product Support instance. However, you will very likely need to click on the
Can't access your account link in order to reset to a new password.
We have a fairly long-running post-function script (45-60 seconds) that uses the IssueManager to create many sub-tasks. When a second scripts starts before the first finishes, the script runs twice over the first issue that fired the post function. For instance, assume issues FOO-1 and FOO-2 were transitioned one after another, we see the logs showing the post function running twice on FOO-1. It looks like the new version introduced ScriptEngine caching, so is it possible that the because the ScriptEngine would run the same script it is not getting the correct arguments?
On another note, using version 1.6 of the plugin, overlapping runs of this script lock the system whereby users can browse but not create issues. The new version appears to run scripts sequentially, where the previous version allowed multiple scripts to run simultaneously. It seems likely that the scripts running over the same issue caused the sequential processing, but whether intentional or serendipitous the sequential processing avoids the deadlock problem.
If you just took a reference to issue as in my first comment, and referred to that in your script, you would have no problems I think. If you use issue, because it's in the binding, it can be changed halfway through execution.
The method I thought would work to fix this doesn't, so I'm going to drop a line to the groovy dev forum.
Attached are the scripts that create the problem. To give you some background, the CreateSubTasks script runs over a multi-checkbox field and creates as many as 1 sub-task per value. Most of the script is logic and setup, until it gets down to these three lines:
def Class iHelperCls = this.class.classLoader.parseClass(new File("@jira.scripts.home@/groovy/IssueHelper.groovy"));
def iHelper = iHelperCls.newInstance();
def newTasks = iHelper.createIssues(tasksToCreate, currentUserObj, issueMgr);
Inside the attached IssueHelper class you'll see the use of the IssueManager.createIssue() function that seems to be where the script stalls out.
If you have any time to investigate the issue or just look over the scripts for glaring problems, we would appreciate it.
Don't bother with the attached jar (I've deleted it now anyway). I need to create a different Binding for each eval... rather than putting the inputs in the scriptengine context. Should be a simple enough change.
i will post the script tomorrow early. We have been able to eliminate our locking issue by putting a queue in front of the scripengine.eval only allowing one script to run at a time. Will also try attached jar and let you know
The issue is that a changed binding can affect the value of a variable in a script that's halfway through execution. I wouldn't notice this because all my scripts use "def Issue myIssue = issue" at the beginning, ie I take a reference to the issue that is in transition.
I know what the fix is but not sure when I can release this. In the meantime I've unreleased version 1.6.1.
Hope you have not been deluged with mail btw. My earlier comment re being able to browse issues but not create still stands... sounds like an issue with the script not the plugin.