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

Creating comments using CommentManager without dispatching an event resulting in comments without an entity version

XMLWordPrintable

      Issue Summary

      Creating comments using CommentManager without dispatching an event resulting in comments without an entity version
      This is reproducible on Data Center: yes

      Steps to Reproduce

      1. Create a comment using this method. Set dispatchEvent to false.
        • Example code
          import com.atlassian.jira.component.ComponentAccessor
          import com.atlassian.jira.util.json.JSONObject
          
          final boolean dispatchEvent = false
          def issueManager = ComponentAccessor.getIssueManager()
          def commentManager = ComponentAccessor.getCommentManager()
          def issue = issueManager.getIssueObject("TASK-1")
          
          commentManager.create(issue, "JIRAUSER10000", "This is a comment created using JAVA API dispatchEvent = false", dispatchEvent)
          
      2. Verify if the comment is created successfully by browsing the issue.
      3. Check the atlassian-jira.log for any warning messages about the new comment.

      Expected Results

      • The comment is created successfully with a row inserted into the jiraaction database table for the comment and a corresponding row in the comment_version table

      Actual Results

      The comment is created successfully. However, the below exception may be seen repetitively in the atlasian-jira.log file:

      2024-06-07 11:26:10,949+0200 NodeReindexServiceThread:thread-0 WARN      [c.a.j.issue.index.DefaultIssueIndexer] COMMENT with id=5253545 should have a version by now
      

      The SQL query below checks for comments without a version in the database. The comments added with the example above show up in the SQL result.

      select * from jiraaction WHERE actiontype = 'comment'
      AND id not in (select comment_id from comment_version);
      

      Despite without an entity version, this doesn’t affect the index search functionality.

      Workaround

      • Reindexing the comments using Java API reIndexComments
      • Manually inserting a row into the comment_version table. Example row:
        comment_id|parent_issue_id|update_time                  |index_version|deleted|
        ----------+---------------+-----------------------------+-------------+-------+
             10003|          10110|2024-05-29 15:27:07.094 +0200|            1|N      |
        

        The value of comment_id and parent_issue_id can be retrieved from the jiraaction table using the previous query to identify the "version-less comments".
        update_time is usually the current time.
        index_version should be 1 (as a workaround for this bug).
        deleted is N.

              Unassigned Unassigned
              michin Michelle Chin (Inactive)
              Votes:
              9 Vote for this issue
              Watchers:
              13 Start watching this issue

                Created:
                Updated: