Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-22538

Improve performance of DefaultSpacePermissionManager.hasPermissionViaGroups

    XMLWordPrintable

Details

    • We collect Confluence feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

    Description

      After a recent local outage (due to high GC from high memory usage under load), I found that many threads were competing to load SpacePermissions from hibernate during DefaultSpacePermissionManager.hasPermissionViaGroups. For example (but hasPermissionViaGroups is the highest line common to most threads):

      "http-9080-6" daemon prio=10 tid=0x0aecf400 nid=0x3605 waiting for monitor entry [0x4105b000]
         java.lang.Thread.State: BLOCKED (on object monitor)
      	at net.sf.hibernate.cache.ReadWriteCache.get(ReadWriteCache.java:69)
      	- waiting to lock <0x54f2a7d0> (a net.sf.hibernate.cache.ReadWriteCache)
      	at com.atlassian.confluence.cache.hibernate.ConfluenceCacheStrategy.get(ConfluenceCacheStrategy.java:52)
      	at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2120)
      	at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1999)
      	at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1961)
      	at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
      	at net.sf.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:108)
      	at net.sf.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:79)
      	at net.sf.hibernate.loader.Loader.list(Loader.java:1045)
      	at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
      	at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1552)
      	at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
      	at com.atlassian.hibernate.HibernateObjectDao$5.doInHibernate(HibernateObjectDao.java:385)
      	at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:370)
      	at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:341)
      	at com.atlassian.hibernate.HibernateObjectDao.findNamedQueryStringParams(HibernateObjectDao.java:352)
      	at com.atlassian.hibernate.HibernateObjectDao.findNamedQuery(HibernateObjectDao.java:272)
      	at com.atlassian.confluence.security.persistence.dao.hibernate.HibernateSpacePermissionDao.findAllGlobalPermissions(HibernateSpacePermissionDao.java:37)
      	at com.atlassian.confluence.security.DefaultSpacePermissionManager.hasPermissionViaGroups(DefaultSpacePermissionManager.java:443)
      	at com.atlassian.confluence.security.DefaultSpacePermissionManager.canUseConfluence(DefaultSpacePermissionManager.java:169)
      	at com.atlassian.confluence.security.CachingSpacePermissionManager.canUseConfluence(CachingSpacePermissionManager.java:228)
      	at com.atlassian.confluence.security.DefaultSpacePermissionManager.hasPermission(DefaultSpacePermissionManager.java:83)
      	at com.atlassian.confluence.security.CachingSpacePermissionManager.hasPermission(CachingSpacePermissionManager.java:212)
      	at com.atlassian.confluence.security.DefaultSpacePermissionManager.hasPermission(DefaultSpacePermissionManager.java:194)
      

      There are numerous ways to fix this but a risk free way is to tighten the queries performed by hasPermissionViaGroups.
      Currently it looks up either all global permissions or all space permissions every time it is called. It actually only needs the permissions for groups and only those for a specific permission type.

      Attachments

        Issue Links

          Activity

            People

              don.willis@atlassian.com Don Willis
              don.willis@atlassian.com Don Willis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: