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

Many branch permissions cause push slowdowns

    XMLWordPrintable

Details

    Description

      The speed of push operations for a given repository in stash is inversely related to the number of branch permissions for that repository. This is because the ref being updated in the push is resolved (in our case, to a git hash) repeatedly, once for each branch in the branch permissions list. My organization is running Stash 3.11.2 where we are observing this problem and I was able to find the bug in the source code of Stash 3.10.2.

      The offending code lives in stash-parent/plugins/branch-permissions/src/main/java/com/atlassian/stash/internal/repository/ref/restriction/RestrictionEnforcer.java

      Specifically, the getMatches function:

      private Multimap<RefChange, RefRestriction> getMatches(Repository repository, Iterable<RefChange> refChanges, Iterable<RefRestriction> restrictions) {
              Multimap<RefChange, RefRestriction> result = ArrayListMultimap.create();
              for (RefChange refChange : refChanges) {
                  for (RefRestriction restriction : restrictions) {
                      Ref ref = refService.resolveRef(repository, refChange.getRefId());
                      if (ref == null) {
                          // The ref service cannot resolve not yet existing refs
                          ref = new SimpleRef(refChange.getRefId(), refChange.getFromHash());
                      }
                      if (restriction.getMatcher().matches(ref)) {
                          result.put(refChange, restriction);
                      }
                  }
              }
      
              return result;
          }

      It seems the call to resolveRef should only happen once per RefChange, not for each RefRestriction. In the log I attached you can see that each call to resolveRef takes at least half a second and that this happens over 100 times during a push. My organization has 100+ restricted branches using the branch permission mechanism for the repository in question. This bug is causing massive push slowdowns (sometimes in excess of 2 minutes) and we're hoping this can get resolved quickly.

      Attachments

        Activity

          People

            Unassigned Unassigned
            9472f696f743 John Gunnison
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: