How to lock the JIRA and Re-index using Jelly Script


Currently i use Jelly script for Background Re-indexing on a scheduled weekly specified time basis, due to huge production data. We get timeout error and Indexing file gets corrupted. Instead i would like to use if there is any other method to lock the JIRA and do re-index using Jelly script.

I didnt find any information in attlassian forum Question & Answers section.

The below error gets during Re-indexing in production.

Wait attempt timed out - waited 30000 milliseconds

com.atlassian.jira.issue.index.IndexException: Wait attempt timed out - waited 30000 milliseconds

2013-09-12 21:40:15,383 StreamsCompletionService::thread-8065 WARN xeccfmm 1300x1345808x1 14obz24 /plugins/servlet/streams [atlassian.jira.index.DefaultIndexEngine] Tried to reopen the IndexReader, but it threw AlreadyClosedException. Opening a fresh IndexReader.


2013-09-12 22:03:06,149 IssueIndexer:thread-9 ERROR anonymous JIRAJelly [issue.customfields.impl.AbstractSingleFieldType] More than one value stored for custom field id 'customfield_10270' for issue 'GCTDOCCUSMOD-763'. Values [11167, 11167]

2013-09-12 22:03:57,181 IssueIndexer:thread-3 ERROR anonymous JIRAJelly [issue.customfields.impl.AbstractSingleFieldType] More than one value stored for custom field id 'customfield_12198' for issue 'CTDLM-21334'. Values [17272, 17272]

We got " More than one value stored for custom field id'" error back for few custom field.


Please let me know, how to solve this error and is there any method i can implement in Jelly script to lock the Jira and Re-index.

Thanks & Regards,

Note - The same script i use in UAT and Sandbox and its working fine without any issues, due to data is less compared to PROD.

2 answers

2 votes
Pedro Cora Atlassian Team Sep 16, 2013

I'm not sure how's your script built, but you can try this:

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log">
<jira:Login username="myuseradmin" password="mypassword">
        <log:warn>** Reindexing Jira **</log:warn>
        <!-- Grab an instance of ComponentManager -->
        <core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>
        <!-- Get the IssueIndexManager from ComponentManager -->
        <core:invoke on="${componentManager}" method="getIndexManager" var="issueIndexManager" />
        <!-- Invkoke reIndexAll method in IssueManager -->
        <core:invoke on="${issueIndexManager}" method="reIndexAll" var="indexTime">
        <log:warn>** Reindex time: ${indexTime} milisseconds. **</log:warn>

Hi Pedro,

Thank you for your quick response.

I am also using the same method for background re-indexing. Please refer my below code.

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:j="jelly:core" xmlns:email="jelly:email" xmlns:log="jelly:log">
<jira:Login username="test" password="test"/>
<j:set var="myName" value="Daily Reindex"/>
<j:set var="dayweek" value="4"/>
<j:set var="hoursofday" value="2"/>
<j:invokeStatic className="java.util.Calendar" method="getInstance" var="rightNow"/>
<j:getStatic className="java.util.Calendar" field="DAY_OF_WEEK" var="DAYWEEK"/>
<j:getStatic className="java.util.Calendar" field="HOUR_OF_DAY" var="hoursday"/>
<log:INFO trim="true"> day : ${rightNow.get(DAYWEEK)}</log:INFO>
<log:INFO trim="true"> hour : ${rightNow.get(hoursday)}</log:INFO>
<j:if test="${dayweek == rightNow.get(DAYWEEK)}">
<log:INFO trim="true">test</log:INFO>
<j:if test="${hoursofday == rightNow.get(hoursday)}">
<log:INFO trim="true">test1</log:INFO>
<log:INFO trim="true">test2</log:INFO>
<j:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>
<j:invoke on="${componentManager}" method="getIndexManager" var="indexManager"/>
<log:INFO trim="true"> ${myName}: Reindex : ${indexManager}</log:INFO>
<j:invoke on="${indexManager}" method="reIndexAll" var="millis"/>
<log:INFO trim="true"> ${myName}: Reindex time in ms: ${millis}</log:INFO>
<log:INFO trim="true"> ${myName}: Reindex time in minutes: ${(((millis/1000)/60) % 100)}</log:INFO>
<email:email server="" from=""
to="" subject="JIRA Reindexing completed in PROD">


Total Milliseconds : ${millis}

JIRA Reindexing Successfully Completed in PROD Total Minutes : (${(((millis/1000)/60) % 100)})




Please provide me the method to lock the Jira and do the Re-index, because when i use the above code in PROD, sometimes its getting timeout error mentioned in my first post, coz of that Indexing fiel gets corrupted. So we have to do the manual re-indexing to correct Indexing file corrupted issue, during the manual re-indexing its taking morethan 2 hours of time to complete. users are not able to access the JIRA.

That's the reason i would like to know, if there is any method to lock the JIRA and do the Rebuild Re-index.

Please provide your thoughts on this!



Can anyone throw some light on this?

Hi Ravichandran,

I'm new to jelly script , we want to write Jelly script for Background Re-indexing on a scheduled weekly specified time basis. We have just 200 users and when we do re-indexing manually ,it will take only 1 mnts.

i would like to ask you that if i use above you pasted code as it is , will it work correctly or do i need made any changes (except user and password) ?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,718 views 17 21
Read article

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