Adding a user to a role is slow for projects with many user role assignments in a different role

XMLWordPrintable

    • 10.03
    • 3
    • Severity 3 - Minor
    • 0

      Issue Summary

      This issue is very similar to JRASERVER-78797, but instead of the time to add users to a role increase as that role increases in members, the time is increased when a different role has many members.
      This is not a regression, but a related issue.

      The problem reported here tends to be less severe than JRASERVER-78797 as the problem doens't happen to the largest roles, so the number of role updates should be much smaller. Also, this can be typically managed by using groups, avoiding the bug.

      Steps to Reproduce

      1. Install a vanilla instance of Jira Service Management Data Center (JSM DC) on version 10.3.7
        • The instance should have 2 or more nodes to trigger the bug.
      2. Create a sample Business (Core) project.
      3. Run the following script.
        JIRA_BASE_URL=https://myjira.com
        JIRA_ADMIN_USRNAME=myusername
        JIRA_ADMIN_PWD=mypassword
        
        USERNAME_PREFIX=sampleuser
        PROJECT_KEY=SCRUM1
        
        for i in $(seq 1 1000); do
          new_username=${USERNAME_PREFIX}${i}
          new_password=${USERNAME_PREFIX}${i}
          new_email="${USERNAME_PREFIX}${i}@user.com"
          new_displayname=${USERNAME_PREFIX}${i}
        
          USER_KEY=$(curl -s -k -L -XPOST \
           -H 'Content-Type: application/json' \
           -u ${JIRA_ADMIN_USRNAME}:${JIRA_ADMIN_PWD} \
           ${JIRA_BASE_URL}'/rest/api/latest/user' \
           -d '{"name": "'${new_username}'","password": "'${new_password}'","emailAddress": "'${new_email}'","displayName": "'${new_displayname}'","applicationKeys": ["jira-software"]}' | jq -r '.key')
        
          echo ${USER_KEY}
        
          time curl -s -o /dev/null ${JIRA_BASE_URL}'/rest/projectconfig/latest/roles/'${PROJECT_KEY}'/10002' -X POST \
          -u ${JIRA_ADMIN_USRNAME}:${JIRA_ADMIN_PWD} \
          -H 'Content-Type: application/json' \
          --data-raw '{"groups":[],"users":["'${USER_KEY}'"]}'
        done
        
        • This script will sequentially create a user record and then add it to a project role.
        • Note the time doesn't increase and is mostly constant, which is expected.
        • Then add a user to a different role. Notice it takes much longer.
      4. Create a sample ITSM project.
      5. Run the following script.
        JIRA_BASE_URL=https://myjira.com
        PROJECT_KEY=ITSM1
        
        for i in $(seq 1 2000); do
        time curl -s \
          ${JIRA_BASE_URL}'/rest/servicedesk/1/pages/people/customers/pagination/'${PROJECT_KEY}'/invite' \
          -X POST \
          -H 'Authorization: Bearer PAT-key' \
          -H 'Accept: application/json, text/plain, */*' \
          -H 'Content-Type: application/json' \
          --data-raw '{"emails":["customer'${i}'@customer.net"]}'
        done
        
        • This script will sequentially create add a customer to the project.
        • Note the time doesn't increase and is mostly constant, which is expected.
        • Then add a user to a different role, such as Administrator. Notice this operation takes much longer.

      Expected Results

      Adding users to any role takes about the same amount of time.

      Actual Results

      Adding users to a project that contains a role with several thousands of users added individually takes a long time, unless we're adding them to the role that has the most users.

      Workaround

      Use group memberships to add users to the roles, instead of adding users individually. This bug manifests only when the role associations in the project are changed, so while it can take longer to add a group as well, adding/removing users to the group doesn't trigger the bug.

            Assignee:
            Unassigned
            Reporter:
            Allan Gandelman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: