Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-6542

MapEntries' concurrent session access broken

    XMLWordPrintableJSON

Details

    Description

      MapEntries uses a shared session. To avoid concurrent access it uses a Lock (ReentrantLock) "initializing". With SLING-6131 (to be precise here) the order in which the lock is applied relative to refreshing however was inverted: the refresh used to be after the lock, with this change however it is now before. Which means that you can have a concurrent access to refresh and other session operations.

      The following stacktrace illustrates a concurrent access:

      • thread 1:
                at org.apache.sling.jcr.resource.internal.helper.jcr.JcrItemResourceFactory.getItemOrNull(JcrItemResourceFactory.java:184)
                at org.apache.sling.jcr.resource.internal.helper.jcr.JcrItemResourceFactory.createResource(JcrItemResourceFactory.java:96)
                at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.getResource(JcrResourceProvider.java:300)
                at org.apache.sling.resourceresolver.impl.providers.stateful.AuthenticatedResourceProvider.getResource(AuthenticatedResourceProvider.java:135)
                at org.apache.sling.resourceresolver.impl.helper.ResourceResolverControl.getResource(ResourceResolverControl.java:224)
                at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getAbsoluteResourceInternal(ResourceResolverImpl.java:1066)
                at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getResourceInternal(ResourceResolverImpl.java:687)
                at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getResource(ResourceResolverImpl.java:641)
                at org.apache.sling.resourceresolver.impl.mapping.MapEntries.addResource(MapEntries.java:270)
                at org.apache.sling.resourceresolver.impl.mapping.MapEntries.onChange(MapEntries.java:718)
                at org.apache.sling.resourceresolver.impl.observation.BasicObservationReporter.reportChanges(BasicObservationReporter.java:210)
                at org.apache.sling.jcr.resource.internal.JcrResourceListener.onEvent(JcrResourceListener.java:155)
        
      • thread 2:
                at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate$WarningLock.lock(SessionDelegate.java:759)
                at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate$WarningLock.lock(SessionDelegate.java:773)
                at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performVoid(SessionDelegate.java:269)
                at org.apache.jackrabbit.oak.jcr.session.SessionImpl.refresh(SessionImpl.java:432)
                at com.adobe.granite.repository.impl.CRX3SessionImpl.refresh(CRX3SessionImpl.java:213)
                at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.refresh(JcrResourceProvider.java:516)
                at org.apache.sling.resourceresolver.impl.providers.stateful.AuthenticatedResourceProvider.refresh(AuthenticatedResourceProvider.java:89)
                at org.apache.sling.resourceresolver.impl.helper.ResourceResolverControl.refresh(ResourceResolverControl.java:155)
                at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.refresh(ResourceResolverImpl.java:1340)
                at org.apache.sling.resourceresolver.impl.mapping.MapEntries.refreshResolverIfNecessary(MapEntries.java:636)
                at org.apache.sling.resourceresolver.impl.mapping.MapEntries.addResource(MapEntries.java:266)
                at org.apache.sling.resourceresolver.impl.mapping.MapEntries.onChange(MapEntries.java:718)
                at org.apache.sling.resourceresolver.impl.observation.BasicObservationReporter.reportChanges(BasicObservationReporter.java:210)
                at org.apache.sling.jcr.resource.internal.JcrResourceListener.onEvent(JcrResourceListener.java:155)
        

      Attachments

        1. SLING-6542.patch
          2 kB
          Stefan Egli

        Issue Links

          Activity

            People

              stefanegli Stefan Egli
              stefanegli Stefan Egli
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: