Backgroud.
A scrum team would like to see the sum of hours estimated in Sub-tasks in the Backlog. The grey oval should contain Total Remaining Estimate. For this I created the custom field Total Remaining Estimate to be used in the configuration of the scrum board. The new custom field is populated by a scripted field that calculates the sum of remaining estimates in the Task and its Sub-tasks. This works very well.
Problem.
When work is logged in a Sub-task the Total Remaining Estimate has to be recalculated. Since the Parent is not updated it is not reindexed. I wrote a Scriptrunner listener to trigger the reindex. All fields are updated nicely, except for the number in the grey oval. It is only updated if I do a project reindex or the Task is updated, e.g. change the Description. I presume the updated triggers a reindex. When I update the Task the change in the grey oval is instant.
Is the problem with my script or is there some other process needed for the Scrum board to get the correct values.
Script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.index.IssueIndexingService
def issue = event.issue
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
issueIndexingService.reIndex(issue)
log.warn("*** Reindex issue: ${issue.getKey()}, ${issue.getIssueType().getName()}")
if (issue.getIssueType().getName() == "Sub-task") {
issueIndexingService.reIndex(issue.getParentObject())
log.warn("*** Reindex parent: ${issue.getParentObject().getKey()}, ${issue.getParentObject().getIssueType().getName()}")
}
As far as I know, you can't achieve that with listeners due to the race condition. When the subtask fires the event, your listener is triggered and the code runs immediately, however at that time subtask's indexing has not been completed yet. After all listener codes run, the subtask is indexed. So, you need to run your code after a while.
I can suggest defining an escalation service for subtasks and reindexing their parents accordingly.
Hello @Tuncay Senturk
I do not understand why there would be a race condition. The listener is triggered when the Sub-task is updated, Issue Update event or Work Logged On Issue event. All data in the Sub-task should be available for the Parent when it is re-indexed.
In this I presume that the events are sent after the Sub-task is re-indexed, as in a transition.
I tried to remove the re-indexing of the Sub-task in the Listener and only trigger the re-index of the Parent. That did not work.
I then wrote a small script in the Scriptrunner Script Console to trigger a re-index of the Parent. It works nicely. This might confirm that there is a race condition with the listener.
I will look in to the Escalation Service.
Thank you for your response
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had similar problems with post functions. You know the last step of post functions is the reindexing, but when the event listener (issue_updated event) is triggered the indexing may not be finished. Probably, it is same with your condition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.