Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-13141

Performance degradation in permissions cache

    XMLWordPrintable

Details

    Description

      Issue Summary

      After upgrade to Bitbucket 7.12 - 7.18, there is an intermittent performance degradation in looking up group permissions. This causes the first permissions lookup to take longer than expected.

      In the example issue triggering this bug, the issue was noticed loading the dashboard. Profiler logs show that the time spent was finding recently accessed repositories for the user (RepositoryAccessDao.findRecentRepositories):

      2022-02-09 10:40:51,571 | http-nio-7990-exec-3 | @NAPGQVx640x115722x0 | admin | 18bqbg7
      [39427.2ms] - "GET /dashboard HTTP/1.1"
       [38870.7ms] - Page com.atlassian.bitbucket.user.RecentlyAccessedRepositoriesService.findByCurrentUser(Permission,PageRequest)
        [38870.6ms] - Page com.atlassian.stash.internal.user.RepositoryAccessDao.findRecentRepositories(int,PageRequest,Predicate)
         [1.4ms] - Iterable com.atlassian.stash.internal.user.InternalUserService.getGroupsByUser(String)
         [1068.0ms] [count: 31, avg: 34.5ms] - Page com.atlassian.stash.internal.user.EffectivePermissionDao.findByGroup(String,PageRequest)
       [5.9ms] - Page com.atlassian.bitbucket.dashboard.DashboardService.suggestPullRequests(SuggestPullRequestsRequest)
      
      

      This is related to fixed bug BSERV-13056, which follows a similar pattern.

      Steps to Reproduce

      1. Create 55k repositories.
      2. Assign group with admin privilege to each repository.

      Expected Results

      A runtime of a few hundred milliseconds or, at most, a second, resulting in a fast loading UI:

      2022-02-09 15:59:37,289 | http-nio-7990-exec-5 | @CCMM57x959x54x0 | admin | 1kq6332
      [1395.4ms] - "GET /dashboard HTTP/1.1"
       [1079.4ms] - Page com.atlassian.bitbucket.user.RecentlyAccessedRepositoriesService.findByCurrentUser(Permission,PageRequest)
        [1079.4ms] - Page com.atlassian.stash.internal.user.RepositoryAccessDao.findRecentRepositories(int,PageRequest,Predicate)
         [1.8ms] - Iterable com.atlassian.stash.internal.user.InternalUserService.getGroupsByUser(String)
         [911.6ms] [count: 31, avg: 29.4ms] - Page com.atlassian.stash.internal.user.EffectivePermissionDao.findByGroup(String,PageRequest)
       [24.6ms] - Page com.atlassian.bitbucket.dashboard.DashboardService.suggestPullRequests(SuggestPullRequestsRequest)
        [24.6ms] - void com.atlassian.stash.internal.repository.RepositoryActivityDao.findRecentPushesForUser(int,Date,SatiableConsumer)
      

      Actual Results

      A runtime in the tens of thousands, resulting in 30 seconds or longer in waiting for application response.

      2022-02-09 10:40:51,571 | http-nio-7990-exec-3 | @NAPGQVx640x115722x0 | admin | 18bqbg7
      [39427.2ms] - "GET /dashboard HTTP/1.1"
       [38870.7ms] - Page com.atlassian.bitbucket.user.RecentlyAccessedRepositoriesService.findByCurrentUser(Permission,PageRequest)
        [38870.6ms] - Page com.atlassian.stash.internal.user.RepositoryAccessDao.findRecentRepositories(int,PageRequest,Predicate)
         [1.4ms] - Iterable com.atlassian.stash.internal.user.InternalUserService.getGroupsByUser(String)
         [1068.0ms] [count: 31, avg: 34.5ms] - Page com.atlassian.stash.internal.user.EffectivePermissionDao.findByGroup(String,PageRequest)
       [5.9ms] - Page com.atlassian.bitbucket.dashboard.DashboardService.suggestPullRequests(SuggestPullRequestsRequest)
      
      

      Workaround

      • The issue can be worked around by restricting the number of repositories a group has explicit permissions to. One of the ways to do this is to roll up a group's permissions from the repository to the project level.

      Attachments

        Issue Links

          Activity

            People

              ckochovski@atlassian.com Christopher Kochovski
              mwilliams@atlassian.com Mark A.
              Votes:
              5 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: