Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D4D73E2BF for ; Thu, 29 Nov 2012 11:19:01 +0000 (UTC) Received: (qmail 71460 invoked by uid 500); 29 Nov 2012 11:19:01 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 71290 invoked by uid 500); 29 Nov 2012 11:19:00 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 71033 invoked by uid 99); 29 Nov 2012 11:18:58 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Nov 2012 11:18:58 +0000 Date: Thu, 29 Nov 2012 11:18:58 +0000 (UTC) From: "Guillaume Sauthier (JIRA)" To: dev@felix.apache.org Message-ID: <1909351254.39525.1354187938729.JavaMail.jiratomcat@arcas> In-Reply-To: <280803615.33827.1354124106082.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (FELIX-3789) Deadlock due to synchronization on INSTANCE_NAME MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FELIX-3789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506406#comment-13506406 ] Guillaume Sauthier commented on FELIX-3789: ------------------------------------------- As far as I understand the issue, there is 1 thread creating a component instance (from the iPOJO extender), it takes a lock when creating a handler instance. And there is another Thread (is StartupSequencer a class of yours ?) that register a service that ends up starting a component instance that in turn creates and start a new PrimitiveComponentType that also wants to create a Handler instance (from the same handler type). Here is the dead lock. As a workaround, is it possible to move the PrimitiveComponentType startup outside of the @Validate method? If possible, does this solve the issue? > Deadlock due to synchronization on INSTANCE_NAME > ------------------------------------------------ > > Key: FELIX-3789 > URL: https://issues.apache.org/jira/browse/FELIX-3789 > Project: Felix > Issue Type: Bug > Components: iPOJO > Affects Versions: ipojo-core-1.8.4 > Reporter: Sebastien GRIMARD > > iPojo sometimes locks up during component instanciation in our application. > After analysis, the lockup occurs since the fix in FELIX-3548 was applied. > The problem is that createComponentInstance in the class IPojoFactory is pseudo-recursive (through a call to getHandler), that is it can call recursively itself on a different factory instance. > Since createComponentInstance synchronizes itself on the factory first (local lock) and on INSTANCE_NAME second (global lock), sometimes it will try to call createComponentInstance on a different factory while holding the global lock and while another threads holds that factory's local lock and is trying to acquire the global lock (I hope what I wrote makes sense). > Stack trace of the problem : > Daemon Thread [Thread-1] (Suspended) > owns: ComponentFactory (id=5717) > owns: ArrayList (id=5708) <============== > owns: HandlerManagerFactory (id=5718) > waiting for: HandlerManagerFactory (id=5709) <============== > HandlerManagerFactory(IPojoFactory).createComponentInstance(Dictionary, > ServiceContext) line: 258 > ComponentFactory(IPojoFactory).getHandler(IPojoFactory$RequiredHandler, > ServiceContext) line: 830 > ComponentFactory(IPojoFactory).createComponentInstance(Dictionary, > ServiceContext) line: 306 > ComponentFactory(IPojoFactory).createComponentInstance(Dictionary) > line: 239 > InstanceCreator$ManagedInstance.create(IPojoFactory) line: 343 > InstanceCreator.onValidation(IPojoFactory) line: 202 > InstanceCreator.stateChanged(Factory, int) line: 243 > ComponentFactory(IPojoFactory).computeFactoryState() line: 766 > ComponentFactory.addedService(ServiceReference) line: 414 > Tracker$Tracked.trackAdding(ServiceReference) line: 725 > Tracker$Tracked.track(ServiceReference) line: 686 > Tracker$Tracked.serviceChanged(ServiceEvent) line: 642 > FilteredServiceListener.serviceChanged(ServiceEvent) line: 107 > BundleContextImpl.dispatchEvent(Object, Object, int, Object) line: 861 > EventManager.dispatchEvent(Set, EventDispatcher, int, Object) line: > 230 > ListenerQueue.dispatchEventSynchronous(int, Object) line: 148 > ServiceRegistry.publishServiceEventPrivileged(ServiceEvent) line: 819 > ServiceRegistry.publishServiceEvent(ServiceEvent) line: 771 > ServiceRegistrationImpl.register(Dictionary) line: 130 > ServiceRegistry.registerService(BundleContextImpl, String[], Object, > Dictionary) line: 214 > BundleContextImpl.registerService(String[], Object, Dictionary) line: > 433 > HandlerManagerFactory(IPojoFactory).start() line: 613 > Extender.createAbstractFactory(Bundle, Element) line: 520 > Extender.parse(Bundle, String) line: 301 > Extender.startManagementFor(Bundle) line: 237 > Extender.access$600(Extender, Bundle) line: 52 > Extender$CreatorThread.run() line: 769 > Thread.run() line: 662 > Daemon Thread [Thread-7] (Suspended) > owns: HandlerManagerFactory (id=5709) <============== > owns: ComponentFactory (id=5710) > owns: Tracker (id=5711) > owns: Dependency[] (id=5712) > waiting for: ArrayList (id=5708) <============== > HandlerManagerFactory(IPojoFactory).createComponentInstance(Dictionary, > ServiceContext) line: 283 > ComponentFactory(IPojoFactory).getHandler(IPojoFactory$RequiredHandler, > ServiceContext) line: 830 > ComponentFactory(IPojoFactory).computeDescription() line: 721 > ComponentFactory(IPojoFactory).computeFactoryState() line: 757 > ComponentFactory.addedService(ServiceReference) line: 414 > Tracker$Tracked.trackAdding(ServiceReference) line: 725 > Tracker$Tracked.trackInitialServices() line: 610 > Tracker.open() line: 210 > ComponentFactory.starting() line: 262 > ComponentFactory(IPojoFactory).start() line: 605 > PrimitiveComponentType.createFactory() line: 441 > PrimitiveComponentType.initializeFactory() line: 198 > PrimitiveComponentType.getFactory() line: 171 > PrimitiveComponentType(ComponentType).ensureFactory() line: 185 > PrimitiveComponentType(ComponentType).ensureAndGetFactory() line: 177 > PrimitiveComponentType(ComponentType).createInstance() line: 79 > COI_Starter.__M_coiBuildler(COI_ConfigLoader) line: 176 > COI_Starter.coiBuildler(COI_ConfigLoader) line: not available > COI_Starter.__M_startOSGI() line: 97 > COI_Starter.startOSGI() line: not available > NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] > NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 > DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 > Method.invoke(Object, Object...) line: 597 > Callback.call(Object[]) line: 233 > Callback.call() line: 193 > LifecycleCallback.call() line: 86 > LifecycleCallbackHandler.__M_stateChanged(int) line: 162 > LifecycleCallbackHandler.stateChanged(int) line: not available > InstanceManager.setState(int) line: 535 > InstanceManager.stateChanged(ComponentInstance, int) line: 1401 > HandlerManager(InstanceManager).setState(int) line: 560 > HandlerManager.stateChanged(ComponentInstance, int) line: 239 > DependencyHandler(Handler).setValidity(boolean) line: 174 > DependencyHandler.__M_checkContext() line: 186 > DependencyHandler.checkContext() line: not available > DependencyHandler.__M_validate(DependencyModel) line: 149 > DependencyHandler.validate(DependencyModel) line: not available > Dependency(DependencyModel).validate() line: 642 > Dependency(DependencyModel).computeDependencyState() line: 310 > Dependency(DependencyModel).manageArrival(ServiceReference) line: 399 > Dependency(DependencyModel).addedService(ServiceReference) line: 335 > Tracker$Tracked.trackAdding(ServiceReference) line: 725 > Tracker$Tracked.track(ServiceReference) line: 686 > Tracker$Tracked.serviceChanged(ServiceEvent) line: 647 > FilteredServiceListener.serviceChanged(ServiceEvent) line: 107 > BundleContextImpl.dispatchEvent(Object, Object, int, Object) line: 861 > EventManager.dispatchEvent(Set, EventDispatcher, int, Object) line: > 230 > ListenerQueue.dispatchEventSynchronous(int, Object) line: 148 > ServiceRegistry.publishServiceEventPrivileged(ServiceEvent) line: 819 > ServiceRegistry.publishServiceEvent(ServiceEvent) line: 771 > ServiceRegistrationImpl.register(Dictionary) line: 130 > ServiceRegistry.registerService(BundleContextImpl, String[], Object, > Dictionary) line: 214 > BundleContextImpl.registerService(String[], Object, Dictionary) line: > 433 > BundleContextImpl.registerService(String, Object, Dictionary) line: > 451 > IPojoContext.registerService(String, Object, Dictionary) line: 404 > StartupSequencerImpl$SequenceThread.launchStartupPhase(StartupPhase) > line: 309 > StartupSequencerImpl$SequenceThread.runStartup() line: 389 > StartupSequencerImpl$SequenceThread.run() line: 262 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira