Performance problems by slow population of ActiveUsersCountForLicenseCache
Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.
Problem
JIRA may experience performance problems caused by slow population of ActiveUsersCountForLicenseCache.
The following appears in the atlassian-jira.log
java.lang.RuntimeException: ActiveUsersCountForLicenseCache refresh took over 60 seconds. This operation takes too long and it may affect JIRA performance and stability. Please see https://confluence.atlassian.com/display/JIRAKB/KB-JRASERVER-64384-docs for details.
at com.atlassian.jira.application.DefaultApplicationRoleManager.synchronizeActiveUsersCountCache(DefaultApplicationRoleManager.java:231)
at com.atlassian.jira.application.DefaultApplicationRoleManager.isRoleLimitExceeded(DefaultApplicationRoleManager.java:406)
at com.atlassian.jira.application.DefaultApplicationRoleManager.isAnyRoleLimitExceeded(DefaultApplicationRoleManager.java:395)
at com.atlassian.jira.plugin.webpanel.notification.IsAnyApplicationRoleUserLimitExceeded.shouldDisplay(IsAnyApplicationRoleUserLimitExceeded.java:23)
at com.atlassian.plugin.web.conditions.AndCompositeCondition.shouldDisplay(AndCompositeCondition.java:14)
at com.atlassian.plugin.web.conditions.AndCompositeCondition.shouldDisplay(AndCompositeCondition.java:14)
at com.atlassian.plugin.web.DefaultWebInterfaceManager.filterFragmentsByCondition(DefaultWebInterfaceManager.java:154)
at com.atlassian.plugin.web.DefaultWebInterfaceManager.getDisplayableWebPanelDescriptors(DefaultWebInterfaceManager.java:117)
at com.atlassian.jira.plugin.navigation.BannerRenderer.writeBanners(BannerRenderer.java:44)
at org.apache.jsp.decorators.admin_jsp._jspService(admin_jsp.java:436)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
...
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.atlassian.jira.application.DefaultApplicationRoleManager$DelegatingSettableFutureTask.get(DefaultApplicationRoleManager.java:277)
at com.atlassian.jira.application.DefaultApplicationRoleManager$DelegatingSettableFutureTask.get(DefaultApplicationRoleManager.java:257)
at com.atlassian.jira.application.DefaultApplicationRoleManager.synchronizeActiveUsersCountCache(DefaultApplicationRoleManager.java:226)
... 196 more
Diagnosis
Environment
- JIRA with large number of users (5000+) and/or groups.
Cause
JIRA maintains a cache of number of users that have access to applications (this is managed on Applications > Applications Access page). Those values need to be recalculated for every operation that impacts users' membership in groups (that includes adding, syncing and rearranging User Directories). Calculation is happening in a separate thread usually named default-application-role-manager-cache-refresh-0. If for some reason this calculation will take too long the above exception will be thrown by different threads that need to access ActiveUsersCountForLicenseCache. Time needed to perform calculation is dependent on number of user, number of groups and number of relations between users and groups as well as between groups if nested groups are enabled. This includes users and groups that are not configured to have access to JIRA.
See related:
Workaround
- Reduce number of users and groups. E.g. if JIRA is configured to synchronise users with remote LDAP directory User Object Filter and Group Object Filter can be used to synchronise only relevant users and groups.
- If you see many errors in short period of time, check operations that impact users' membership: reduce Directory Sync frequency, check REST API integrations
- If issue persist, contact Atlassian Support and mention this KB.