IndexingFailureException thrown during reindex of Jira server
Symptoms
Running re-indexing will lead to an error similar to the following, shown in the JIRA UI:
com.atlassian.jira.index.IndexingFailureException: Indexing completed with 2 errors
at com.atlassian.jira.index.AccumulatingResultBuilder$CompositeResult.await(AccumulatingResultBuilder.java:147)
at com.atlassian.jira.issue.index.DefaultIndexManager.doIndexIssuesInBatchMode(DefaultIndexManager.java:877)
at com.atlassian.jira.issue.index.DefaultIndexManager.doStopTheWorldReindex(DefaultIndexManager.java:844)
Disabling JIRA Agile and running full re-indexing will allow the re-indexing to complete without the above error. However, enabling JIRA Agile back again will have the same error.
- As of 7.0 JIRA Agile is now known as JIRA Software
The following appears in the atlassian-jira.log
:
2014-06-11 19:08:51,399 IssueIndexer:thread-5 WARN admin 1148x497x1 xxxxx 127.0.0.1 /secure/admin/IndexReIndex.jspa [jira.issue.index.DefaultIssueDocumentFactory] Error indexing issue ABC-90: Dropping 'customfield_11530'
java.lang.RuntimeException: Expected exactly one rank for 11530 / 21202 but found 2
at com.atlassian.greenhopper.manager.lexorank.LexoRankDaoImpl.findByFieldAndIssueId(LexoRankDaoImpl.java:271)
at com.atlassian.greenhopper.service.lexorank.LexoRankOperation.rankInitially(LexoRankOperation.java:141)
at com.atlassian.greenhopper.service.lexorank.LexoRankOperation.execute(LexoRankOperation.java:106)
at com.atlassian.greenhopper.service.lexorank.LexoRankService.performRankOperation(LexoRankService.java:210)
at com.atlassian.greenhopper.service.lexorank.LexoRankService.getRankOrRankInitially(LexoRankService.java:130)
at com.atlassian.greenhopper.customfield.lexorank.LexoRankCFType.getValueFromIssue(LexoRankCFType.java:122)
at com.atlassian.greenhopper.customfield.lexorank.LexoRankCFType.getValueFromIssue(LexoRankCFType.java:30)
at com.atlassian.jira.issue.fields.CustomFieldImpl.getValue(CustomFieldImpl.java:416)
Or in newer versions of JIRA
2016-12-08 14:36:51,495 JiraTaskExectionThread-1 WARN anonymous [c.a.j.issue.index.DefaultIssueDocumentFactory] Error indexing issue CRM-761: Dropping 'customfield_12230'
com.atlassian.greenhopper.manager.lexorank.LexoRankIntegrityException: Expected exactly one rank row for issue[id=44214] for rank field[id=12230], but found 2 rows
at com.atlassian.greenhopper.manager.lexorank.LexoRankDaoImpl.findByFieldAndIssueId(LexoRankDaoImpl.java:234)
at com.atlassian.greenhopper.service.lexorank.LexoRankOperation.rankInitially(LexoRankOperation.java:147)
at com.atlassian.greenhopper.service.lexorank.LexoRankOperation.execute(LexoRankOperation.java:112)
at com.atlassian.greenhopper.manager.lexorank.LexoRankManagerImpl.performRankOperation(LexoRankManagerImpl.java:286)
at com.atlassian.greenhopper.manager.lexorank.LexoRankManagerImpl.getRankOrRankInitially(LexoRankManagerImpl.java:86)
at com.atlassian.greenhopper.customfield.lexorank.LexoRankCFType.getValueFromIssue(LexoRankCFType.java:121)
at com.atlassian.greenhopper.customfield.lexorank.LexoRankCFType.getValueFromIssue(LexoRankCFType.java:29)
at com.atlassian.jira.issue.fields.ImmutableCustomField.getValue(ImmutableCustomField.java:349)
Diagnosis
You can run the following SQL query to verify if there are duplicate ISSUE_ID values in the AO_60DB71_LEXORANK table.
SELECT "ISSUE_ID" FROM "AO_60DB71_LEXORANK" WHERE "FIELD_ID" = <Rank Custom Field ID> GROUP BY "ISSUE_ID" HAVING count("ISSUE_ID") > 1;
The <Rank Custom Field ID>
value can be identified in the error message - e.g. in the error message above, the error refers to customfield_11530, so the Rank Custom Field ID is 11530
Cause
There are duplicate ISSUE_ID values in AO_60DB71_LEXORANK table for one Rank custom field.
Workaround
The following changes are irreversible. Please ensure that the JIRA database backup is taken before proceeding to the resolution steps. It is also recommended that JIRA is taken out of service before starting the database backup.
After completing the resolution steps described below, please check the JIRA instance and the GreenHopper configuration including user tests before bringing JIRA online. For e.g.
- Do all the boards show up correctly
- Are all the earlier sprints intact
- Are the Story Points, Epic, Ranking and Business Value are correct in issues by doing a random check
- Are the Sprint Reports and Burn-down charts intact (both Classic boards and Rapid boards)
- Shutdown JIRA
- Identify the duplicated ISSUE_ID using the query during Diagnosis step above.
Retrieve the ID of the duplicate ISSUE_ID
select "ID","ISSUE_ID" from "AO_60DB71_LEXORANK" where "ISSUE_ID"=<insert result of diagnosis query>;
The ISSUE_ID value can be found from the stack trace or Diagnosis step.
Delete the duplicate ID using query similar to the following
delete from "AO_60DB71_LEXORANK" where "ID"= <insert result of select statement of above>;
ID of
select "ID","ISSUE_ID" from "AO_60DB71_LEXORANK" where "ISSUE_ID"=<duplicateissueidresult>;
the above is the ID of the duplicated ISSUE_ID
- Restart JIRA
- Re-index JIRA