Hi,
I try to start a full background reindex on a JIRA 6.0.8 system via a groovy listener (via Script Runner plugin).
Here are the relevant parts of the source.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.index.IssueIndexManager import com.atlassian.jira.task.context.Context import com.atlassian.jira.util.index.Contexts IssueIndexManager issueIndexManager = ComponentAccessor.getIssueIndexManager() Long millis = 0 try { Context context = Contexts.percentageLogger(issueIndexManager,log) millis = issueIndexManager.reIndexAllIssuesInBackground(context) } catch (Exception e) { e.printStackTrace() log.error "Reindexing failed: ${e.message}" } finally { log.info "Reindex time in ms: $millis" }
The service fails with a NPE.
java.lang.NullPointerException at com.atlassian.jira.issue.index.DefaultIndexManager.doBackgroundReindex(DefaultIndexManager.java:797) at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexAll(DefaultIndexManager.java:320) at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexAllIssuesInBackground(DefaultIndexManager.java:367) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.atlassian.util.profiling.object.ObjectProfiler.profiledInvoke(ObjectProfiler.java:83) at com.atlassian.jira.config.component.SwitchingInvocationHandler.invoke(SwitchingInvocationHandler.java:28) at $Proxy156.reIndexAllIssuesInBackground(Unknown Source) at com.atlassian.jira.util.index.IndexLifecycleManager$reIndexAllIssuesInBackground.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at eventim.services.Script126.runService(Script126.groovy:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1054) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884) at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:149) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$2.invokeMethod(GroovyScriptEngineImpl.java:299) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145) at eventim.services.Script126.run(Script126.groovy:55) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:315) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:103) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:212) at com.onresolve.jira.groovy.GroovyRunner.runFile(GroovyRunner.java:102) at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:62) at com.onresolve.jira.groovy.GroovyService.run(GroovyService.java:53) at com.atlassian.jira.service.JiraServiceContainerImpl.run(JiraServiceContainerImpl.java:61) at com.atlassian.jira.service.ServiceRunner.execute(ServiceRunner.java:48) at org.quartz.core.JobRunShell.run(JobRunShell.java:195) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
Does anyone know how to successfully start a background reindex?
Thanks,
Henning
Community moderators have prevented the ability to post new answers.
I now get all issue IDs from the database via SQL and than reindex each issue through a "normal" issueIndexManager.reIndex(issue) call. Because this is really slow (6000 issues ~ 15 minutes on our server), I only select issues created or changed in the last n days.
So the NPE comes from this:
cfuller@crf:~/src/atlassian/jira [master]$ git show atlassian_jira_6_0_8:jira-components/jira-core/src/main/java/com/atlassian/jira/issue/index/DefaultIndexManager.java | awk 'NR >= 795 && NR < 800 {print}' { TaskDescriptor<Object> currentTaskDescriptor = taskManager.getLiveTask(new IndexTaskContext()); if (currentTaskDescriptor.isCancelled()) { throw new InterruptedException();
The indexing code isn't really built with the expectation that they might be triggered externally. This method may be reachable through the API, but to use it you have to break out of the API into dangerous jira-core territory.
If you bring yourself up to a newer version of JIRA (anything since 6.1.4), there is a REST resource you can use to trigger this, instead. Docs are here: https://docs.atlassian.com/jira/REST/6.1.4/#d2e2989
Failing that, the only way to make this work is to bring in jira-core and fiddle with the task manager directly (it wants a BackgroundIndexTaskContext).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In other words, this should almost certainly be marked
@Internal
and treated with caution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am experiencing similar issues while trying to do Background Indexing via a Jira Service. We are using Jira 5.2.11. Any updates???
java.lang.NullPointerException at com.atlassian.jira.issue.index.DefaultIndexManager.doBackgroundReindex(DefaultIndexManager.java:797) at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexAll(DefaultIndexManager.java:320) at com.atlassian.jira.issue.index.DefaultIndexManager.reIndexAllIssuesInBackground(DefaultIndexManager.java:367)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anyone any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@henning: are you using the right 'Contexts' class reference ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's the one you can see in the code. I'm not sure if this is the right one. Which one should be used?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
com.atlassian.jira.task.context.Contexts
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, thanks, I changed it to the correct import and changed the generating line to
Context context = Contexts.percentageLogger(issueIndexManager,log,'Re-indexing is {0}% complete. Current index: {1}')
But unfortunately the error stays the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.