Hello everyone,
We have developed a script that we use as a Reindex Service that runs every minute.
How can we run it in an isolated thread, so Jira does not go down, in case of any problem with reindexing. Can you help me, please?
Thanks in advance.
Regards,
Almu
Ok, while the principle of "index in another thread" is a good abstract idea, your question scares me.
Why are you doing this?
Indexing is not something you should ever have to think about in Jira. Questions starting with "I want to index" are almost always posted by people who are trying to do really bad things in Jira (inadvertently, as they don't understand the internals, and are trying to do something in a way they haven't realised is totally wrong)
Hi Nic,
I have inherited this Jira Server, and someone created a groovy script that runs as a Service in Jira, every minute. I do not know why this was done. In your opinion, do I have to delete this service because Jira does reindexing automatically when needed?
Thx & BR,
Almu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Before you delete it, you really should find out why they did this.
My best guess is they were hiding a massive problem that they've created elsewhere.
You may only be able to identify that by stopping it running, and seeing what goes wrong!
But in the long run, yes, absolutely, you need rid of this completely, it's a very poor practice and totally unneccessary.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Moses Thomas and @Nic Brough -Adaptavist-
I would like to use this API call specified on this doc to re-index jira server through linux terminal.
Just one question, i am getting "authentication failure" when i try and get this working. I just use root without any password, so how would i run this?
curl -u root:password -X POST $JIRAURL/rest/api/2/reindex?type=FOREGROUND
Kind regards,
--Bibin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@bibin.koshy You cannot not use linux user to authenticate login to Jira, user must be admin user in Jira. use a dedicated user with admin rights in Jira.
Best regards,
Mo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is "root" a valid admin user in Jira?
(Standard advice here though - do NOT do this automatically, you should not need to do it)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted]In my opinion it is not a good idea to run indexing every minute, why because in case you have a large JIRA instance , this will drastically reduce JIRA performance. my advice to you is to perform indexing like once a day in your production ( lets say at night when less user are accessing Jira)
Even better run a background indexing see REST API documentation https://confluence.atlassian.com/jirakb/how-to-trigger-re-indexing-using-rest-request-via-curl-command-663617587.html, you can add it in your script in the case where you use linux/unixlike server and use cron tab in linux/Unixlike servers to define when reindexing should be triggered automatically.
Best!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Moses Thomas,
I have inherited this Jira Server, and someone created a groovy script that runs as a Service in Jira. Look:
Reindex Service com.onresolve.jira.groovy.GroovyService
input-file: /mnt/nas/jira/ReindexService.groovy
Schedule 0 0/1 * 1/1 * ? *
I am not sure whether the best option is to delete this service or schedule it in this way
0 59 23 * * *
What is your opinion, please?
Thx & BR,
ALmu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted] I will suggest you schedule is daily.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted],
Will it be possible for you to share the groovy script with me? We have a similar need to write a re-index service that we plan to run every week. I will be much obliged.
Thanks,
Rajat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajat
Here you are
cat ReindexService.groovy
def usuario = "adminuser"
def filter_id = "10327"
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.issue.search.*
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.index.IndexException
import com.atlassian.jira.ManagerFactory
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Category
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.util.ImportUtils
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.ManagerFactory
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.ComponentManager
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.index.*;
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
String jqlSearch = " filter="+ filter_id;
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
ComponentManager componentManager = ComponentManager.getInstance()
CommentManager commentManager = ComponentAccessor.getCommentManager()
IssueManager issueManager = ComponentAccessor.getIssueManager();
UserUtil userUtil = ComponentAccessor.getUserUtil()
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def userManager = ComponentAccessor.getUserManager()
def user2 = userManager.getUserByName(usuario)
Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug "START Reindex filter Service"
def String adminUserName = usuario
def String nagComment = ""
SearchService.ParseResult parseResult = searchService.parseQuery(user2, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(user2, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
def issues = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
log.debug "Entro... size:" + issues.size();
for ( issue in issues ){
def issueobtained = issueManager.getIssueObject(issue.getKey());
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
issueIndexingService.reIndex(issueobtained);
}
log.debug "FINISH Reindex filter Service"
} else {
log.debug("Invalid JQL: " + jqlSearch);
}
Cheers,
Almu
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.