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

Component delete operation leaves orphaned records in nodeassociation table due to non-atomic writes

      Summary

      Deleting components removes data from component table, but sometimes it doesn't delete corresponding references from nodeassociation table since the operation is not atomic.
      In that case, those records become orphans. Later loading all data related to the issue will lead to the error, since the corresponding component doesn't exist.

      Steps to Reproduce

      There are two separate ways to trigger the problem:

      1. A race condition
        • Trigger component deletion from Jira admin UI
        • Now Jira deletes all related nodeassociation entries, followed by the component itself
        • If a user edits an issue and assigns the component being deleted to it after Jira started deleting nodeassociation entries but before it deleted the component, it will result in an orphaned nodeassociation entry
        • The more issues assigned to the component, the higher the chances are for the problem to occur, as deleting nodeassociation entries will take more time.
      2. A regression introduced by JRASERVER-10507 in Jira 8.1.0
        • Create a component and assign it to an issue
        • Archive the component
        • Delete the component

      Expected Results

      Jira doesn't have unreferenced component data in nodeassociation table.

      Actual Results

      Jira has unreferenced component data in nodeassociation table.

      mysql> select * from nodeassociation where SINK_NODE_ENTITY='Component' and SINK_NODE_ID not in (Select ID from component);
      +----------------+--------------------+--------------+------------------+------------------+----------+
      | SOURCE_NODE_ID | SOURCE_NODE_ENTITY | SINK_NODE_ID | SINK_NODE_ENTITY | ASSOCIATION_TYPE | SEQUENCE |
      +----------------+--------------------+--------------+------------------+------------------+----------+
      |          10038 | Issue              |        10000 | Component        | IssueComponent   |     NULL |
      |          10039 | Issue              |        10002 | Component        | IssueComponent   |     NULL |
      |          13886 | Issue              |        10001 | Component        | IssueComponent   |     NULL |
      |          10356 | Issue              |        10000 | Component        | IssueComponent   |     NULL |
      |          10376 | Issue              |        10002 | Component        | IssueComponent   |     NULL |
      |          10377 | Issue              |        10002 | Component        | IssueComponent   |     NULL |
      ...
      27 rows in set (1.05 sec)
      

      Notes

      • Additionally, in the log file following errors are recorded:
        2008-09-11 14:26:20,785 http-8443-Processor40 ERROR [jira.issue.statistics.ComponentStatisticsMapper] Indexes may be corrupt - unable to retrieve component with id '10211'.
        2008-09-11 14:27:41,830 http-8443-Processor40 ERROR [jira.issue.statistics.ComponentStatisticsMapper] Indexes may be corrupt - unable to retrieve component with id '10000'.
        2008-09-11 14:27:41,830 http-8443-Processor40 ERROR [jira.issue.statistics.ComponentStatisticsMapper] Indexes may be corrupt - unable to retrieve component with id '10001'.
        2008-09-11 14:27:41,830 http-8443-Processor40 ERROR [jira.issue.statistics.ComponentStatisticsMapper] Indexes may be corrupt - unable to retrieve component with id '10002'.
        2008-09-11 14:27:41,830 http-8443-Processor40 ERROR [jira.issue.statistics.ComponentStatisticsMapper] Indexes may be corrupt - unable to retrieve component with id '10027'. 
        
        • Note that the problem is not related to the Lucene Index.
      • We should add an extra check to Integrity Checker that would allow users to find and delete the invalid components. Also, if possible, the delete operation should be improved

      Workaround

      1. Delete the orphaned rows manually:
        delete from nodeassociation where source_node_entity = 'Issue' and sink_node_entity = 'Component' and sink_node_id not in (select id from component);
      1. Reindex Jira (background reindex in Server will do; full lock & reindex in DC). No restart's required.

            [JRASERVER-15750] Component delete operation leaves orphaned records in nodeassociation table due to non-atomic writes

            Paweł Brylowski added a comment - - edited

            Unfortunately, the same issues also exist in DC LTS 9.4.14

            Is it possible to reopen the task?

            Paweł Brylowski added a comment - - edited Unfortunately, the same issues also exist in DC LTS 9.4.14 Is it possible to reopen the task?

            Bhupesh Nagda added a comment - - edited

            9.4.7 is affected

             

            18362 rows

            Bhupesh Nagda added a comment - - edited 9.4.7 is affected   18362 rows

            한혜진 added a comment -

            Hi,

            I am wondering if there will be any problems using the above DB query statement.

            After checking the data, a total of 5,336 cases were extracted.

            If I delete all this data, won't it affect other data?

            Or, if there are no problems with use, would it be better to put the matter on hold?

            한혜진 added a comment - Hi, I am wondering if there will be any problems using the above DB query statement. After checking the data, a total of 5,336 cases were extracted. If I delete all this data, won't it affect other data? Or, if there are no problems with use, would it be better to put the matter on hold?

            Hi, Jira 9.4.6 and this issue still exist.

             select count from nodeassociation where SINK_NODE_ENTITY='Component' and SINK_NODE_ID not in (Select ID from component);
            count
            -------
            6357

            Valiantys Support added a comment - Hi, Jira 9.4.6 and this issue still exist.  select count from nodeassociation where SINK_NODE_ENTITY='Component' and SINK_NODE_ID not in (Select ID from component); count ------- 6357

            Unless it's leftover from before upgrade.

            Tomas Karas added a comment - Unless it's leftover from before upgrade.

            Jira DC 9.4.3, user tier JSW 50k, JSM 9k

            54 rows

            How is this "Fixed" ?

            //Tomas

            Tomas Karas added a comment - Jira DC 9.4.3, user tier JSW 50k, JSM 9k 54 rows How is this "Fixed" ? //Tomas

            Keith added a comment -

            If  people are reporting this in 9.2 it needs to be reopened.

            Created: 10/Oct/2008

            Soon you will have staff as old as this ATOMIC bug
            This also causes entire Jiras to go down rather quickly yet it remains a LOW priority?

            Additionally this https://jira.atlassian.com/browse/JRASERVER-71601 has been gathering impact for 3 years ...

            Keith added a comment - If  people are reporting this in 9.2 it needs to be reopened. Created: 10/Oct/2008 Soon you will have staff as old as this ATOMIC bug This also causes entire Jiras to go down rather quickly yet it remains a LOW priority? Additionally this https://jira.atlassian.com/browse/JRASERVER-71601 has been gathering impact for 3 years ...

            8.20.2 
            386 rows.

            Krzysztof Krajewski added a comment - 8.20.2  386 rows.

            v9.2.0 

            7410 total results

            Sasha Dovbnia added a comment - v9.2.0  7410 total results

            8.20.10    +1

            qinfeng.yang added a comment - 8.20.10    +1

              d180ec5d6467 Ross Jenkins (Inactive)
              bdziedzic Bogdan Dziedzic [Atlassian]
              Affected customers:
              216 This affects my team
              Watchers:
              178 Start watching this issue

                Created:
                Updated:
                Resolved: