Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-14877

Deleting a link changes the "updated date" field, but it does not reindex lucene.

      See JRA-7156 for a related issue with creating links.
      This was fixed for link creation but the bug still exists for link deletion.

      After deleting a link, the correct "updated date" is stored in the DB, but the lucene index is not updated.

      The user will see the correct date when viewing an issue, but they will see the old value in lists, searches etc that use the Lucene index.

            [JRASERVER-14877] Deleting a link changes the "updated date" field, but it does not reindex lucene.

            Hi Tibor,

            Thanks for the comment, I think I understand the point you are making now.

            My change does indeed fix the issue as reported here, but you have a separate problem because your plugin is adding Link information to the Lucene Issue index.
            This information is gathered by calling the IssueLinkManager, and your plugin is adding stale information to the Lucene index because the IssueLinkCache is not yet cleared.
            This means that createIssueLink() would also cause the same problem for you at the moment.

            I have raised a separate issue JRA-16199 to manage the caching issue; please use this new issue for further comments.

            Mark Lassau (Inactive) added a comment - Hi Tibor, Thanks for the comment, I think I understand the point you are making now. My change does indeed fix the issue as reported here, but you have a separate problem because your plugin is adding Link information to the Lucene Issue index. This information is gathered by calling the IssueLinkManager, and your plugin is adding stale information to the Lucene index because the IssueLinkCache is not yet cleared. This means that createIssueLink() would also cause the same problem for you at the moment. I have raised a separate issue JRA-16199 to manage the caching issue; please use this new issue for further comments.

            AntonA added a comment -

            Hi Tibor,

            Mark is on holidays now. He will have a look when he returns in mid Jan.

            Cheers,
            Anton

            AntonA added a comment - Hi Tibor, Mark is on holidays now. He will have a look when he returns in mid Jan. Cheers, Anton

            Hi Mark,

            I checked the source code of 3.13.2 and your fix.

            The problem with it is that the reindexing is done prior to clearing the cache. Why is it a problem?
            Because we want to index issue link information and when reindexing is invoked, the old (removed) link is returned from the cache and it is being reindexed.

            Hence it will lead to improper search results when users want to search for linked issues using this Issue Link Searcher plugin.

            My proposal was to clear the issue link cache (at least for the link's source and destination issues) before reindexing. As a last step (see finally clause), the removeIssueLink method clears the complete issue link cache by calling clearCache.

            Clearing the link cache prior to reindexing would not affect indexing performance as by default issue link information is not indexed by Jira.
            However, this solution would eliminate the need to patch JIRA and allow lots of users to search for linked issues by link types.

            I guess it is not possible to convince the dev team of this but I wanted to give it a chance for the sake of those waiting for JRA-3101 to be fixed. The above mentioned free plugin gives them the relief.

            Cheers,
            Tibor

            Tibor Hegyi [META-INF] added a comment - Hi Mark, I checked the source code of 3.13.2 and your fix. The problem with it is that the reindexing is done prior to clearing the cache. Why is it a problem? Because we want to index issue link information and when reindexing is invoked, the old (removed) link is returned from the cache and it is being reindexed. Hence it will lead to improper search results when users want to search for linked issues using this Issue Link Searcher plugin. My proposal was to clear the issue link cache (at least for the link's source and destination issues) before reindexing. As a last step (see finally clause), the removeIssueLink method clears the complete issue link cache by calling clearCache . Clearing the link cache prior to reindexing would not affect indexing performance as by default issue link information is not indexed by Jira. However, this solution would eliminate the need to patch JIRA and allow lots of users to search for linked issues by link types. I guess it is not possible to convince the dev team of this but I wanted to give it a chance for the sake of those waiting for JRA-3101 to be fixed. The above mentioned free plugin gives them the relief. Cheers, Tibor

            Applied fix as noted in the TO-DO and wrote func test to detect regression to old behaviour.

            Mark Lassau (Inactive) added a comment - Applied fix as noted in the TO-DO and wrote func test to detect regression to old behaviour.

            Tibor Hegyi [META-INF] added a comment - - edited

            Thank you for assigning this issue. This means you're keeping an eye on it.

            I'd like to give you some hints. The comment and related code block I referred to above is this:

            if (!issueLinkType.isSystemLinkType())
            {
            	createRemoveIssueLinkChangeItems(issueLink, issueLinkType, remoteUser);
            }
            else
            {
            	// TODO: JRA-14877 This should not be in the else block.
            	reindexLinkedIssues(issueLink);
            }
            

            Please note, that it is not enough to move the call reindexLinkedIssues(issueLink) out of the if-else block but it is also important that the cache is cleared before reindexing the soruce and destination issues.

            Otherwise any issue link searchers (necessary to support search by issue link) would index the old (cached) links including the one that is being removed.

            The patch I made and tested transforms the above to:

            if (!issueLinkType.isSystemLinkType())
            {
            	createRemoveIssueLinkChangeItems(issueLink, issueLinkType, remoteUser);
            }
            
            //clearing cache is necessary before reindexing the issues to prevent indexing the link being removed
            clearCache();
            reindexLinkedIssues(issueLink);
            

            clearCache() is anyway called in the finally of the method.

            I hope I could clarify why it would be great. I anyway publish my plugin and the patch soon to support JIRA 3.13 and earlier versions.

            Thank you,
            Tibor

            Tibor Hegyi [META-INF] added a comment - - edited Thank you for assigning this issue. This means you're keeping an eye on it. I'd like to give you some hints. The comment and related code block I referred to above is this: if (!issueLinkType.isSystemLinkType()) { createRemoveIssueLinkChangeItems(issueLink, issueLinkType, remoteUser); } else { // TODO: JRA-14877 This should not be in the else block. reindexLinkedIssues(issueLink); } Please note, that it is not enough to move the call reindexLinkedIssues(issueLink) out of the if-else block but it is also important that the cache is cleared before reindexing the soruce and destination issues. Otherwise any issue link searchers (necessary to support search by issue link) would index the old (cached) links including the one that is being removed. The patch I made and tested transforms the above to: if (!issueLinkType.isSystemLinkType()) { createRemoveIssueLinkChangeItems(issueLink, issueLinkType, remoteUser); } //clearing cache is necessary before reindexing the issues to prevent indexing the link being removed clearCache(); reindexLinkedIssues(issueLink); clearCache() is anyway called in the finally of the method. I hope I could clarify why it would be great. I anyway publish my plugin and the patch soon to support JIRA 3.13 and earlier versions. Thank you, Tibor

            Tibor Hegyi [META-INF] added a comment - - edited

            Hi,

            I have the source code of JIRA and I found a comment pointing to this issue in the method com.atlassian.jira.issue.link.DefaultIssueLinkManager.removeIssueLink().

            I am building a plugin to fulfill JRA-3101 (currently 94 votes and increasing), but to work around the reindexing problem, I must patch JIRA with the fixed version of com.atlassian.jira.issue.link.DefaultIssueLinkManager.removeIssueLink() . This is not nice.

            If you fixed this issue, you'd immediately make lots of users happy, fulfill about 100 votes because my plugin would not require users to use my patch.

            I think it would be worth considering.

            Cheers,
            Tibor

            PS: The plugin does not have a home page yet but I'll add it in a few days.

            Tibor Hegyi [META-INF] added a comment - - edited Hi, I have the source code of JIRA and I found a comment pointing to this issue in the method com.atlassian.jira.issue.link.DefaultIssueLinkManager.removeIssueLink() . I am building a plugin to fulfill JRA-3101 (currently 94 votes and increasing), but to work around the reindexing problem, I must patch JIRA with the fixed version of com.atlassian.jira.issue.link.DefaultIssueLinkManager.removeIssueLink() . This is not nice. If you fixed this issue, you'd immediately make lots of users happy, fulfill about 100 votes because my plugin would not require users to use my patch. I think it would be worth considering. Cheers, Tibor PS: The plugin does not have a home page yet but I'll add it in a few days.

              mlassau Mark Lassau (Inactive)
              mlassau Mark Lassau (Inactive)
              Affected customers:
              1 This affects my team
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 5h
                  5h