Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Deadlock with Lazy Activation on Felix
Deadlock with Lazy Activation on Felix [message #656747] Mon, 28 February 2011 07:44
Chetan Mising name is currently offline Chetan Mising name
Messages: 4
Registered: February 2011
Junior Member
While using Blueprint Gemini on Felix I was getting deadlock when using Lazy activation.

Found one Java-level deadlock:
=============================
"SpringOsgiExtenderThread-3":
  waiting to lock monitor 0x1c51ecec (object 0x093139c0, a java.lang.Object),
  which is held by "FelixStartLevel"
"FelixStartLevel":
  waiting to lock monitor 0x1c51e18c (object 0x09313e58, a java.util.concurrent.
ConcurrentHashMap),
  which is held by "SpringOsgiExtenderThread-3"

Java stack information for the threads listed above:
===================================================
"SpringOsgiExtenderThread-3":
        at org.eclipse.gemini.blueprint.service.exporter.support.internal.support.LazyTargetResolver.getBean(LazyTargetResolver.java:77)
        - waiting to lock <0x093139c0> (a java.lang.Object)
        at org.eclipse.gemini.blueprint.service.exporter.support.internal.support.LazyTargetResolver.getBeanIfPossible(LazyTargetResolver.java:66)
        at org.eclipse.gemini.blueprint.service.exporter.support.internal.support.LazyTargetResolver.notifyIfPossible(LazyTargetResolver.java:110)
        at org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean.registerService(OsgiServiceFactoryBean.java:348)
        at org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean$Executor.registerService(OsgiServiceFactoryBean.java:98)
        at org.eclipse.gemini.blueprint.service.exporter.support.internal.controller.ExporterController.registerService(ExporterController.java:38)
        at org.eclipse.gemini.blueprint.service.dependency.internal.DefaultMandatoryDependencyManager.startExporter(DefaultMandatoryDependencyManager.java:331)
        at org.eclipse.gemini.blueprint.service.dependency.internal.DefaultMandatoryDependencyManager.checkIfExporterShouldStart(DefaultMandatoryDependencyManager.java:269)
        at org.eclipse.gemini.blueprint.service.dependency.internal.DefaultMandatoryDependencyManager.discoverDependentImporterFor(DefaultMandatoryDependencyManager.java:260)
        - locked <0x093139f0> (a org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean)
        at org.eclipse.gemini.blueprint.service.dependency.internal.DefaultMandatoryDependencyManager.addServiceExporter(DefaultMandatoryDependencyManager.java:190)
        at org.eclipse.gemini.blueprint.service.dependency.internal.MandatoryDependencyBeanPostProcessor.postProcessAfterInitialization(MandatoryDependencyBeanPostProcessor.java:43)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1418)        
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        - locked <0x09313e58> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
        - locked <0x09313e98> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
        at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
        - locked <0x09313f80> (a java.lang.Object)
        at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
        at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
        at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
        at java.lang.Thread.run(Thread.java:619)
"FelixStartLevel":
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:181)
        - waiting to lock <0x09313e58> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:166)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.eclipse.gemini.blueprint.service.exporter.support.internal.support.LazyTargetResolver.getBean(LazyTargetResolver.java:78)
        - locked <0x093139c0> (a java.lang.Object)
        at org.eclipse.gemini.blueprint.service.exporter.support.internal.support.PublishingServiceFactory.getService(PublishingServiceFactory.java:90)
        at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:310)
        at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:221)
        at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:297)
        at org.apache.felix.framework.Felix.getService(Felix.java:3007)        
        at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:329)
        at org.osgi.util.tracker.ServiceTracker.addingService(ServiceTracker.java:442)
        at org.apache.felix.http.whiteboard.internal.tracker.AbstractTracker.addingService(AbstractTracker.java:35)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
        at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:184)
        at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:339)
        at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:273)
        at org.apache.felix.http.whiteboard.internal.WhiteboardActivator.addTracker(WhiteboardActivator.java:56)
        at org.apache.felix.http.whiteboard.internal.WhiteboardActivator.doStart(WhiteboardActivator.java:47)
        at org.apache.felix.http.base.internal.AbstractActivator.start(AbstractActivator.java:41)
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1827)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1744)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1148)
        at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
        at java.lang.Thread.run(Thread.java:619)




The situation which caused this is as follows. A Blueprint Bundle has Servlet Filter configured and uses the Blueprint config to register this Filter in the OSGi ServiceRegistry (SR). The SpringOsgiExtenderThread-3 is the thread used by Spring extender to create the Spring factory for this bundle. At the same time Felix main thread was starting the Felix Whiteboard service (part of HTTP support) which registers a ServiceTracker for tracking Filter object. This tracker at time of initialization looks for Filter instance.

Now what happens is that Spring has created the

Now there are 2 threads in action

SpringOsgiExtenderThread-3 - It is creating the ApplicationContext and AbstractDelegatedExecutionApplicationContext.startRefresh. As it is doing all the steps it reaches the stage where the Services are registered in the SR. So the code reaches the OsgiServiceFactoryBean.afterPropertiesSet and it has now registerd the Service in registerService. Note the LazyTargetResolver does not have the target set as the Bean is having lazy activation. At this moment the service has been registered and hence visible to service tracker

FelixStartLevel - Here the ServiceTracker detects that a Filter is registered and tries to obtain the refrence. This causes it to ask for a Bean instance when the Bean factory initialization has not yet completed and hence causes a deadlock.

I am not sure where the fault lies i.e. on Spring side where the object is being published into the OSGi ServiceRegsitry and hence visible to other component while the factory itself has not complete initialization or somewhere else. For now I have done away with the Lazy activation and so far have not seen the deadlock issue occurring again.

Should this be considered as a bug in Gemini's processing?
Previous Topic:Gemini Blueprint 1.0.0.M1 Managed service factory
Next Topic:Minimum eclipse version for gemini
Goto Forum:
  


Current Time: Wed Aug 27 13:15:13 EDT 2014

Powered by FUDForum. Page generated in 0.01930 seconds