Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-16438

Fix startup and shutdown when Redis is enabled

    Details

      Description

      At startup, the WorkManager service is called first when the applicationStarted event is sent, whereas it needs Redis configuration to be loaded. This error is raised:

      ERROR [localhost-startStop-1] [org.nuxeo.runtime.model.impl.RegistrationInfoImpl] Component notification of application started failed.
      java.lang.RuntimeException: Failed to initialize repository 'default': java.lang.NullPointerException
      	at org.nuxeo.ecm.core.repository.RepositoryService.initializeRepository(RepositoryService.java:151)
      	at org.nuxeo.ecm.core.repository.RepositoryService.applicationStarted(RepositoryService.java:102)
      	at org.nuxeo.runtime.model.impl.RegistrationInfoImpl.notifyApplicationStarted(RegistrationInfoImpl.java:334)
      	at org.nuxeo.runtime.osgi.OSGiRuntimeService.notifyComponentsOnStarted(OSGiRuntimeService.java:494)
      	at org.nuxeo.runtime.osgi.OSGiRuntimeService.fireApplicationStarted(OSGiRuntimeService.java:532)
      	at org.nuxeo.runtime.osgi.OSGiRuntimeService.frameworkEvent(OSGiRuntimeService.java:542)
      	at org.nuxeo.osgi.OSGiAdapter.fireFrameworkEvent(OSGiAdapter.java:238)
      	at org.nuxeo.osgi.application.loader.FrameworkLoader.doStart(FrameworkLoader.java:232)
      	at org.nuxeo.osgi.application.loader.FrameworkLoader.start(FrameworkLoader.java:112)
      	at org.nuxeo.runtime.deployment.NuxeoStarter.start(NuxeoStarter.java:121)
      	at org.nuxeo.runtime.deployment.NuxeoStarter.contextInitialized(NuxeoStarter.java:89)
      	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
      	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
      	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
      	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
      	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
      	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1861)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: org.nuxeo.ecm.core.api.ClientException: java.lang.NullPointerException
      	at org.nuxeo.ecm.core.api.UnrestrictedSessionRunner.runUnrestricted(UnrestrictedSessionRunner.java:158)
      	at org.nuxeo.ecm.core.repository.RepositoryService.initializeRepository(RepositoryService.java:144)
      	... 23 more
      Caused by: java.lang.NullPointerException
      	at org.nuxeo.ecm.core.work.WorkManagerImpl.isQueuingEnabled(WorkManagerImpl.java:235)
      	at org.nuxeo.ecm.core.work.WorkManagerImpl.schedule(WorkManagerImpl.java:774)
      	at org.nuxeo.ecm.core.work.WorkManagerImpl.schedule(WorkManagerImpl.java:757)
      	at org.nuxeo.ecm.core.event.impl.AsyncEventExecutor.run(AsyncEventExecutor.java:77)
      	at org.nuxeo.ecm.core.event.impl.EventServiceImpl.fireEventBundle(EventServiceImpl.java:338)
      	at org.nuxeo.ecm.core.event.impl.EventServiceImpl.handleTxCommited(EventServiceImpl.java:507)
      	at org.nuxeo.ecm.core.event.impl.EventServiceImpl.recordEvent(EventServiceImpl.java:477)
      	at org.nuxeo.ecm.core.event.impl.EventServiceImpl.fireEvent(EventServiceImpl.java:282)
      	at org.nuxeo.ecm.core.api.AbstractSession.notifyEvent(AbstractSession.java:277)
      	at org.nuxeo.ecm.core.api.AbstractSession.save(AbstractSession.java:1603)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.nuxeo.ecm.core.api.TransactionalCoreSessionWrapper.invoke(TransactionalCoreSessionWrapper.java:131)
      	at com.sun.proxy.$Proxy57.save(Unknown Source)
      	at org.nuxeo.ecm.core.api.UnrestrictedSessionRunner.runUnrestricted(UnrestrictedSessionRunner.java:154)
      	... 24 more
      

      So RedisComponent should have a lower applicationStarted order.

      At shutdown, the RedisComponent is called first whereas the WorkManager is still active. Many errors like this one are thrown:

      ERROR [WorkManagerImpl] Uncaught error on thread Nuxeo-Work-elasticSearchIndexing-69
      redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
      	at redis.clients.util.Pool.getResource(Pool.java:42)
      	at org.nuxeo.ecm.core.redis.RedisPoolExecutor.execute(RedisPoolExecutor.java:29)
      	at org.nuxeo.ecm.core.redis.contribs.RedisWorkQueuing.removeScheduledWork(RedisWorkQueuing.java:794)
      	at org.nuxeo.ecm.core.redis.contribs.RedisBlockingQueue.pollElement(RedisBlockingQueue.java:102)
      	at org.nuxeo.ecm.core.work.NuxeoBlockingQueue.poll(NuxeoBlockingQueue.java:125)
      	at org.nuxeo.ecm.core.redis.contribs.RedisBlockingQueue.poll(RedisBlockingQueue.java:76)
      	at org.nuxeo.ecm.core.redis.contribs.RedisBlockingQueue.take(RedisBlockingQueue.java:58)
      	at org.nuxeo.ecm.core.redis.contribs.RedisBlockingQueue.take(RedisBlockingQueue.java:37)
      	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.IllegalStateException: Pool not open
      	at org.apache.commons.pool2.impl.BaseGenericObjectPool.assertOpen(BaseGenericObjectPool.java:605)
      	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:405)
      	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:360)
      	at redis.clients.util.Pool.getResource(Pool.java:40)
      	... 11 more
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  PagerDuty

                  Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.