Reindexing Jira Server / Data Center causes a Nullpointer Error
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
Jira throws a NullPointerException while executing operations that depend on Indexing.
The following appears in the atlassian-jira.log
:
1
2
3
4
5
Caused by: java.lang.NullPointerException
at com.atlassian.greenhopper.manager.issuelink.EpicLinkManagerImpl.getEpic(EpicLinkManagerImpl.java:101)
at com.atlassian.greenhopper.customfield.epiclink.EpicLinkCFType.getValueFromIssue(EpicLinkCFType.java:77)
at com.atlassian.jira.issue.fields.CustomFieldImpl.getValue(CustomFieldImpl.java:381)
at com.atlassian.greenhopper.customfield.epiclink.EpicLinkCustomFieldIndexer.addIndex(EpicLinkCustomFieldIndexer.java:41)
Or you might see:
1
2
3
4
5
6
7
8
9
java.lang.NullPointerException
at com.atlassian.jira.issue.index.indexers.impl.SubTaskIndexer.addIndex(SubTaskIndexer.java:47)
at com.atlassian.jira.issue.index.indexers.FieldIndexer.addIndex(FieldIndexer.java:114)
at com.atlassian.jira.issue.index.indexers.FieldIndexerWithStats.addIndex(FieldIndexerWithStats.java:57)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory$Builder.add(DefaultIssueDocumentFactory.java:331)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory$Builder.addAll(DefaultIssueDocumentFactory.java:307)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory.getDocument(DefaultIssueDocumentFactory.java:127)
at com.atlassian.jira.issue.index.DefaultIssueDocumentFactory.lambda$createDocuments$1(DefaultIssueDocumentFactory.java:112)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
Cause
The cause may vary but a few known causes are:
Re-indexing following the addition of a 'custom field' when a user is using GreenHopper.
If two issues are somehow linked with each other using an issuelinktype which doesn't exist anymore.
When an Epic link source is not an Epic, although this is less common.
Resolution
Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
1. Run the integrity checker: Using the Database Integrity Checker
2. Try to Re-index Jira again.
3. If re-indexing (also startup reindex or catch-up) still fails, then continue on with the next steps.
Please run the following queries on the Jira DB:
3.1 To check if an issue source doesn't exist anymore:
1
SELECT * FROM issuelink WHERE SOURCE NOT IN (SELECT ID FROM jiraissue);
3.2 To check if an issue type doesn't exist anymore:
1
SELECT * FROM issuelink WHERE linktype NOT IN (SELECT id FROM issuelinktype);
3.3 To check if an Epic link source is not an Epic:
1
2
3
4
5
6
7
SELECT *
FROM issuelink l
JOIN issuelinktype ilt on ilt.id=l.linktype
JOIN jiraissue i on l.source=i.id
JOIN issuetype it on it.id=i.issuetype
WHERE ilt.linkname='Epic-Story Link'
AND it.pname<>'Epic'
4. If any of the previous queries returns a result, then:
Shutdown Jira
Execute the following query on the DB
If the first query (3.1) returns results:
1
DELETE FROM issuelink WHERE SOURCE NOT IN (SELECT ID FROM jiraissue);
If the second query (3.2) returns results:
1
DELETE FROM issuelink WHERE linktype NOT IN (SELECT id FROM issuelinktype);
If the third query (3.3) returns results
1
2
3
4
5
6
7
8
DELETE FROM issuelink WHERE id in (
SELECT l.id
FROM issuelink l
JOIN issuelinktype ilt on ilt.id=l.linktype
JOIN jiraissue i on l.source=i.id
JOIN issuetype it on it.id=i.issuetype
WHERE ilt.linkname='Epic-Story Link'
AND it.pname<>'Epic' )
Restart Jira
Manually perform a re-indexing
5. If re-indexing still fails, then:
Run the command
1
select * from jiraissue where issuetype is null;
If this returns any rows, then please find an appropriate issuetype for the issue key returned in the previous query. For this we run:
1
select * from issuetype;
Once the id of the issue type if identified, run the below sql:
1
update jiraissue set issuetype = <<id found from the above query>> where id = <<jira issue id found in the first query>>
Was this helpful?