How to remove from Jira lucene index, issues that have been deleted in the database, but still present in index.

Still need help?

The Atlassian Community is here for you.

Ask the community



This article applies to Jira Server and Data Center

Problem

In Jira instances with high load and frequent issue deletes, Jira indexes can at times suffer from a positive index drift where the lucene indexes have issues that are not in the database anymore. This can result in erroneous search results and wrong reports in gadgets. It can also manifest itself as "This issue can no longer be opened" when trying to view an issue. This has been documented as part of  JRASERVER-68642 - Getting issue details... STATUS

Workaround

For Jira versions 9.12.0, 9.11.1, 9.4.11 or 8.20.27 (or later), call the heal endpoint as described in: How to use Jira's index analyzer to fix index inconsistencies

The workaround steps are as follows. The index analyzer mentioned below is available from Jira 8.5 version onwards.

  1. Run the index analyzer using the rest endpoint <nodeurl>/rest/indexanalyzer/1/state?maxResults=100 for one node after another.
  2. Get the json response generated, copied to a file such as indexorphans_node1.log.
  3. Install json parser Jq and run the below command to get a list of index orphans, to check it's working.

    cat indexorphans_node1.log | jq -r ".|.indexOrphans[].issueId"
  4. Check the indexOrphansCount property towards the end of the file (the command below retrieves this value). If the count is over 100, it will be necessary to go back to step 2 with a higher number for the maxResults parameter, or perform the procedure in batches.
    (info) If the number of orphaned issues is high across several nodes, it might be more viable to run a full reindex operation.

    jq '.indexOrphansCount' indexorphans_node1.log
  5. Copy attached file  deindexIssue.jsp to <JIRA_INSTALL_DIR>/atlassian-jira folder. The file will be reachable from the browser at <YOUR_JIRA_BASE_URL>/deindexIssue.jsp. Please log in as an administrator on the same browser before accessing the page, so that the JSP page will reuse the cookies for authorization.
  6. Then the following command can be run to de-index all the issues that have been deleted from the database but still exist in the index

    for var in $(cat indexorphans_node1.log | jq -r ".|.indexOrphans[].issueId"); do curl -D- -u user:pass -H "Content-Type: application/json" <YOUR_JIRA_NODE_URL>/deindexIssue.jsp?issueId=$var; done
  • Alternatively, you can access the page directly with the issue Id to de-index a specific issue alone by accessing the following page on your browser

    <YOUR_JIRA_NODE_URL>/deindexIssue.jsp?issueId=<issueid>


Descriptionde-index issue
ProductJIRA

Last modified on Mar 18, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.