Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-3442

Intermittent IllegalMonitorStateException seen while releaseing IndexNode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.0.23, 1.2.8, 1.3.7, 1.4
    • lucene
    • None

    Description

      At times following exception seen. On this system the index got corrupted because backing index files got deleted from the system and hence index is not accessible.

      21.09.2015 09:26:36.764 *ERROR* [FelixStartLevel] com.adobe.granite.repository.impl.SlingRepositoryManager start: Uncaught Throwable trying to access Repository, calling stopRepository()
      java.lang.IllegalMonitorStateException: attempt to unlock read lock, not locked by current thread
              at java.util.concurrent.locks.ReentrantReadWriteLock$Sync.unmatchedUnlockException(ReentrantReadWriteLock.java:444)
              at java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryReleaseShared(ReentrantReadWriteLock.java:428)
              at java.util.concurrent.locks.AbstractQueuedSynchronizer.releaseShared(AbstractQueuedSynchronizer.java:1341)
              at java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.unlock(ReentrantReadWriteLock.java:881)
              at org.apache.jackrabbit.oak.plugins.index.lucene.IndexNode.release(IndexNode.java:121)
              at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.getPlans(LucenePropertyIndex.java:212)
              at org.apache.jackrabbit.oak.query.QueryImpl.getBestSelectorExecutionPlan(QueryImpl.java:847)
              at org.apache.jackrabbit.oak.query.QueryImpl.getBestSelectorExecutionPlan(QueryImpl.java:793)
              at org.apache.jackrabbit.oak.query.ast.SelectorImpl.prepare(SelectorImpl.java:283)
              at org.apache.jackrabbit.oak.query.QueryImpl.prepare(QueryImpl.java:568)
              at org.apache.jackrabbit.oak.query.QueryEngineImpl.executeQuery(QueryEngineImpl.java:183)
              at org.apache.jackrabbit.oak.security.user.UserProvider.getAuthorizableByPrincipal(UserProvider.java:234)
              at org.apache.jackrabbit.oak.security.user.UserManagerImpl.getAuthorizable(UserManagerImpl.java:116)
              at org.apache.jackrabbit.oak.security.principal.PrincipalProviderImpl.getAuthorizable(PrincipalProviderImpl.java:140)
              at org.apache.jackrabbit.oak.security.principal.PrincipalProviderImpl.getPrincipal(PrincipalProviderImpl.java:69)
              at org.apache.jackrabbit.oak.spi.security.principal.CompositePrincipalProvider.getPrincipal(CompositePrincipalProvider.java:50)
              at org.apache.jackrabbit.oak.spi.security.principal.PrincipalManagerImpl.getPrincipal(PrincipalManagerImpl.java:47)
              at com.adobe.granite.repository.impl.SlingRepositoryManager.setupPermissions(SlingRepositoryManager.java:997)
              at com.adobe.granite.repository.impl.SlingRepositoryManager.createRepository(SlingRepositoryManager.java:420)
              at com.adobe.granite.repository.impl.SlingRepositoryManager.acquireRepository(SlingRepositoryManager.java:290)
              at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.start(AbstractSlingRepositoryManager.java:304)
              at com.adobe.granite.repository.impl.SlingRepositoryManager.activate(SlingRepositoryManager.java:267)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:483)
              at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:222)
              at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)
              at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:615)
              at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:499)
              at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:295)
              at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:302)
              at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:113)
              at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:832)
              at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:799)
              at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:724)
              at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:927)
              at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:891)
              at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1492)
              at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1413)
              at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:1222)
              at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:1158)
              at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1444)
              at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:987)
              at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)
              at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)
              at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4547)
              at org.apache.felix.framework.Felix.registerService(Felix.java:3521)
              at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)
              at org.apache.sling.commons.threads.impl.Activator.start(Activator.java:55)
              at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
              at org.apache.felix.framework.Felix.activateBundle(Felix.java:2223)
              at org.apache.felix.framework.Felix.startBundle(Felix.java:2141)
              at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1368)
              at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
              at java.lang.Thread.run(Thread.java:745)
      

      Above exception happens at

      for (String path : indexPaths) {
                  try {
                      indexNode = tracker.acquireIndexNode(path);
      
                      if (indexNode != null) {
                          IndexPlan plan = new IndexPlanner(indexNode, path, filter, sortOrder).getPlan();
                          if (plan != null) {
                              plans.add(plan);
                          }
                      }
                  } finally {
                      if (indexNode != null) {
                          indexNode.release();
                      }
                  }
              }
      

      It has been ensured that if indexNode is initialized then it has been acquired. So only way for such an exception to happen is that in a loop of say 2 paths indexNode got initialized for Loop 1 and then while acquiring in Loop 2 the indexNode still refers to old released value and that would cause the exception. The fix should be simply to null the variable once released

      Attachments

        Activity

          People

            chetanm Chetan Mehrotra
            chetanm Chetan Mehrotra
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: