Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Scriptrunner delete subtasks showing indexing errors after upgrading from jira Server 7.x to 8.13.3.

We recently upgraded our Jira Server instance from 7.2.7 with Scriptrunner 5.4.28, and are now using Jira Server 8.13.3 with Scriptrunner 6.27.0.

I have a scripted post-function which deletes all subtasks of the current issue. This post function performed without any problems in the old instance. Since upgrading, it still works, but now it displays an indexing error.

com.atlassian.jira.index.IndexingFailureException: Indexing completed with 1 errors

The number of errors matches the number of subtasks it deleted. (1 subtask, 1 error. 5 subtasks, 5 errors.) There is a HUGE wall of log text following this line, which I will not bother to paste here.

The code I've been using for the post-function is:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
// for JIRA v6.*
def user = ComponentAccessor.getJiraAuthenticationContext().user.directoryUser
// for JIRA v7.*
// def user = ComponentAccessor.getJiraAuthenticationContext().user
def issueManager = ComponentAccessor.getIssueManager()
// will return a Collection<Issue> with all the subtasks of the current issue
def subTasksList = issue.getSubTaskObjects()
for (subTask in subTasksList) {
    // add a condition here if you DO NOT want to delete all the sub-tasks
    issueManager.deleteIssue(user, subTask, EventDispatchOption.ISSUE_DELETED, false)

Are my errors showing up because I'm in a newer version of Jira, or because I'm using a newer version of Scriptrunner, or both?

Is there a newer version of this code that I can use which will properly perform the delete without the errors?

1 answer

0 votes

It might be helpful to see the first 5-10 lines of the stack trace.

But I know that to get the current user, I use the following:

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

This also works (but groovy lets you omit the get keywords and that's my preference):

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

The "getUser()" method is still available but is flagged as deprecated. 

The deleteIssue() method expects an ApplicationUser and your current code is returning a com.atlassian.crowd.embedded.api.User. So that might be the issue. 

I was really hopeful that your suggestion would work, but unfortunately no. Here's what my current code looks like. Still getting the same results: successful transition, but error message.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def issueManager = ComponentAccessor.issueManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

// Get a list of the current issue's subtasks
def subtasks = issue.getSubTaskObjects()

// Loop through all the subtasks and delete them
subtasks.each {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)

Can you include the first 10 lines of the errors message (or so).

That should give us some hints.

Here are the first 15 lines of the warning message. There are 287 lines total.

com.atlassian.jira.index.IndexingFailureException: Indexing completed with 5 errors
at com.atlassian.jira.index.AccumulatingResultBuilder$CompositeResult.await( [classes/:?]
at com.atlassian.jira.issue.index.DefaultIndexManager.obtain( [classes/:?]
at com.atlassian.jira.issue.index.DefaultIndexManager.await( [classes/:?]
at com.atlassian.jira.issue.index.DefaultIndexManager.executeWithIndexLock( [classes/:?]
at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexIssues( [classes/:?]
at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexIssues( [classes/:?]
at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexIssues( [classes/:?]
at com.atlassian.jira.issue.index.DefaultIndexManager.release( [classes/:?]
at sun.reflect.GeneratedMethodAccessor3407.invoke(Unknown Source) [?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke( [?:1.8.0_275]
at java.lang.reflect.Method.invoke( [?:1.8.0_275]
at com.atlassian.jira.config.component.SwitchingInvocationHandler.invoke( [classes/:?]
at com.sun.proxy.$Proxy17.release(Unknown Source) [?:?]
at com.atlassian.jira.workflow.OSWorkflowManager.enableIndexingForThisThread( [classes/:?]

Try to use IssueService instead of IssueManager. It is better at managing the indexing.

def validationResult = issueService.validateDelete(currentUser,
   issueSevice.delete(currentUser, validationResult, EventDispatchOption.ISSUE_DELETED, false)

Another option might be to manually de-index the subtask.

Sorry... I have nothing more to suggest.

I'm not convinced these errors are linked to the post function script.

I'd try a full locked reindex.

Hi @Montana Fox , have you found a solution to this issue?

Thank you

YES! They finally provided an updated script!

Here is the support issue they created for the problem: SRJIRA-5636 

And here is the new code they posted: Deleting all subtasks of an issue 

I have tested this new script and it works perfectly.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events