[ 
http://issues.apache.org/jira/browse/HIVEMIND-104?page=comments#action_61824 ]
     
Knut Wannheden commented on HIVEMIND-104:
-----------------------------------------

The lock seems to occur because the first thread is locking the 
RegistryInfrastructureImpl object (it calls the synchronized cleanupThread() 
method) while the second thread is locking the PooledServiceModel object (with 
the synchronized getServiceImplementationForCurrentThread() method).  Each 
thread is now waiting for the other to release the lock on the respective 
object.

I think this situation can arise when two threads are using the same pooled 
service, where one thread (in this case the first thread) just got done using 
the service and the other thread is requesting an instance of the service with 
the pool being depleted.  The first thread is politely cleaning up after itself 
by calling RegistryImpl#cleanupThread(), which will lock the 
RegistryInfrastructureImpl object, while the second thread is locking the 
PooledServiceModel object while adding a new CSI to the pool.  The construction 
of the new CSI could possibly require a lock of the RegistryInfrastructureImpl 
object, which leads to the deadlock.

In your case the construction of the CSI requires a lock on the 
RegistryInfrastructureImpl because there is a dependency injection using the 
"service" translator.

I don't know how to best solve this, but I hope this analysis is useful.

> Thread Deadlock
> ---------------
>
>          Key: HIVEMIND-104
>          URL: http://issues.apache.org/jira/browse/HIVEMIND-104
>      Project: HiveMind
>         Type: Bug
>   Components: framework
>     Versions: 1.1
>  Environment: HiveMind 1.1-alpha-3
>     Reporter: Howard M. Lewis Ship

>
> Occasionally my Tapestry applications seem to lock up.  Just happened when I 
> was in the debugger and I was able to pause and see what the contention is.
> Thread [http-8080-Processor25] (Suspended)
>       
> PooledServiceModel.returnServiceToPool(PooledServiceModel$PooledService) 
> line: 213
>       
> PooledServiceModel.unbindPooledServiceFromCurrentThread(PooledServiceModel$PooledService)
>  line: 248
>       PooledServiceModel.access$100(PooledServiceModel, 
> PooledServiceModel$PooledService) line: 38
>       PooledServiceModel$PooledService.threadDidCleanup() line: 96
>       ThreadEventNotifierImpl.fireThreadCleanup() line: 75
>       $ThreadEventNotifier_102f0461661.fireThreadCleanup() line: not available
>       RegistryInfrastructureImpl.cleanupThread() line: 420
>       RegistryImpl.cleanupThread() line: 86
>       ApplicationPortlet.render(RenderRequest, RenderResponse) line: 165
>       PortletApplicationHandler.render_aroundBody8(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: 226
>       
> PortletApplicationHandler.render_aroundBody9$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletFilterAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 458
>       
> PortletApplicationHandler.render_aroundBody10(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: not available
>       
> PortletApplicationHandler.render_aroundBody11$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletContentAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 340
>       
> PortletApplicationHandler.render_aroundBody12(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: not available
>       
> PortletApplicationHandler.render_aroundBody13$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletCacheAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 172
>       
> PortletApplicationHandler.render_aroundBody14(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: not available
>       
> PortletApplicationHandler.render_aroundBody15$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletSecurityAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 738
>       
> PortletApplicationHandler.render_aroundBody16(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: not available
>       
> PortletApplicationHandler.render_aroundBody17$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletMonitorAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 628
>       PortletApplicationHandler.process(ServletContext, HttpServletRequest, 
> HttpServletResponse, Input, Output, PortletWindowInternal, boolean) line: 226
>       ServletWrapper.service(HttpServletRequest, HttpServletResponse) line: 70
>       ServletWrapper(HttpServlet).service(ServletRequest, ServletResponse) 
> line: 802
>       ApplicationFilterChain.internalDoFilter(ServletRequest, 
> ServletResponse) line: 237
>       ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 
> 157
>       ApplicationDispatcher.invoke(ServletRequest, ServletResponse) line: 704
>       ApplicationDispatcher.doInclude(ServletRequest, ServletResponse) line: 
> 590
>       ApplicationDispatcher.include(ServletRequest, ServletResponse) line: 510
>       PortletContainerDispatcher.dispatch(HttpServletRequest, 
> HttpServletResponse, String) line: 370
>       PortletContainerDispatcher.process(HttpServletRequest, 
> HttpServletResponse, Input, boolean) line: 310
>       PortletContainerDispatcher.render(HttpServletRequest, 
> HttpServletResponse, RenderInput) line: 271
>       PortletContainerServiceImpl.render(HttpServletRequest, 
> HttpServletResponse, RenderInput) line: 144
>       PortletRenderer.encodeChildren(FacesContext, UIComponent) line: 100
>       UIPortlet(UIComponentBase).encodeChildren(FacesContext) line: 693
>       ContainerRowRenderer.renderViewMode(FacesContext, UIContainer) line: 40
>       ContainerRowRenderer(ContainerRenderer).encodeChildren(FacesContext, 
> UIComponent) line: 34
>       UIContainer(UIComponentBase).encodeChildren(FacesContext) line: 693
>       PortalRenderer(HtmlBasicRenderer).renderChildren(FacesContext, 
> UIComponent) line: 63
>       PortalRenderer.encodeChildren(FacesContext, UIComponent) line: 58
>       UIPortal(UIComponentBase).encodeChildren(FacesContext) line: 693
>       ExoPortalViewHandler.renderView(FacesContext, UIViewRoot) line: 63
>       RenderResponsePhase.execute(FacesContext) line: 87
>       LifecycleImpl.phase(PhaseId, Phase, FacesContext) line: 200
>       LifecycleImpl.render(FacesContext) line: 117
>       FacesServlet.service(ServletRequest, ServletResponse) line: 198
>       ApplicationFilterChain.internalDoFilter(ServletRequest, 
> ServletResponse) line: 237
>       ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 
> 157
>       PrivateRequestFilter.doFilter(ServletRequest, ServletResponse, 
> FilterChain) line: 82
>       ApplicationFilterChain.internalDoFilter(ServletRequest, 
> ServletResponse) line: 186
>       ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 
> 157
>       StandardWrapperValve.invoke(Request, Response, ValveContext) line: 214
>       StandardValveContext.invokeNext(Request, Response) line: 104
>       StandardPipeline.invoke(Request, Response) line: 520
>       StandardContextValve.invokeInternal(Wrapper, Request, Response) line: 
> 198
>       StandardContextValve.invoke(Request, Response, ValveContext) line: 152
>       StandardValveContext.invokeNext(Request, Response) line: 104
>       FormAuthenticator(AuthenticatorBase).invoke(Request, Response, 
> ValveContext) line: 540
>       StandardValveContext.invokeNext(Request, Response) line: 102
>       StandardPipeline.invoke(Request, Response) line: 520
>       StandardHostValve.invoke(Request, Response, ValveContext) line: 137
>       StandardValveContext.invokeNext(Request, Response) line: 104
>       ErrorReportValve.invoke(Request, Response, ValveContext) line: 117
>       StandardValveContext.invokeNext(Request, Response) line: 102
>       StandardPipeline.invoke(Request, Response) line: 520
>       StandardEngineValve.invoke(Request, Response, ValveContext) line: 109
>       StandardValveContext.invokeNext(Request, Response) line: 104
>       StandardPipeline.invoke(Request, Response) line: 520
>       StandardEngine(ContainerBase).invoke(Request, Response) line: 929
>       CoyoteAdapter.service(Request, Response) line: 160
>       Http11Processor.process(InputStream, OutputStream) line: 799
>       Http11Protocol$Http11ConnectionHandler.processConnection(TcpConnection, 
> Object[]) line: 705
>       TcpWorkerThread.runIt(Object[]) line: 577
>       ThreadPool$ControlRunnable.run() line: 683
>       ThreadWithAttributes(Thread).run() line: 536
>     private synchronized void returnServiceToPool(PooledService pooled)
>     {
>         if (_servicePool == null)  // line 213
>             _servicePool = new ArrayList();
>         _servicePool.add(pooled);
>     }
> and
> Thread [http-8080-Processor22] (Suspended)
>       RegistryInfrastructureImpl.checkShutdown() line: 345
>       RegistryInfrastructureImpl.getServicePoint(String, Module) line: 153
>       RegistryInfrastructureImpl.getService(String, Class, Module) line: 168
>       ModuleImpl.getService(String, Class) line: 97
>       ServiceTranslator.translate(Module, Class, String, Location) line: 40
>       
> BuilderPropertyFacet.getFacetValue(ServiceImplementationFactoryParameters, 
> Class) line: 41
>       BuilderFactoryLogic.wireProperty(Object, BuilderFacet) line: 357
>       BuilderFactoryLogic.setProperties(Object) line: 320
>       BuilderFactoryLogic.createService() line: 77
>       
> BuilderFactory.createCoreServiceImplementation(ServiceImplementationFactoryParameters)
>  line: 42
>       InvokeFactoryServiceConstructor.constructCoreServiceImplementation() 
> line: 84
>       
> PooledServiceModel(AbstractServiceModelImpl).constructCoreServiceImplementation()
>  line: 106
>       PooledServiceModel.constructPooledService() line: 223
>       PooledServiceModel.obtainPooledService() line: 196
>       PooledServiceModel.getServiceImplementationForCurrentThread() line: 180
>       $ApplicationStateManager_102f04616a3._service() line: not available
>       $ApplicationStateManager_102f04616a3.flush() line: not available
>       $ApplicationStateManager_102f04616a4.flush() line: not available
>       BaseEngine(AbstractEngine).service(WebRequest, WebResponse) line: 312
>       InvokeEngineTerminator.service(WebRequest, WebResponse) line: 60
>       RenderRequestServicerToWebRequestServicerBridge.service(RenderRequest, 
> RenderResponse) line: 49
>       ApplicationPortlet.render(RenderRequest, RenderResponse) line: 157
>       PortletApplicationHandler.render_aroundBody8(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: 226
>       
> PortletApplicationHandler.render_aroundBody9$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletFilterAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 458
>       
> PortletApplicationHandler.render_aroundBody10(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: not available
>       
> PortletApplicationHandler.render_aroundBody11$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletContentAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 340
>       
> PortletApplicationHandler.render_aroundBody12(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: not available
>       
> PortletApplicationHandler.render_aroundBody13$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletCacheAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 172
>       
> PortletApplicationHandler.render_aroundBody14(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: not available
>       
> PortletApplicationHandler.render_aroundBody15$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletSecurityAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 738
>       
> PortletApplicationHandler.render_aroundBody16(PortletApplicationHandler, 
> Portlet, RenderRequest, RenderResponse) line: not available
>       
> PortletApplicationHandler.render_aroundBody17$advice(PortletApplicationHandler,
>  Portlet, RenderRequest, RenderResponse, PortletMonitorAspect, Portlet, 
> RenderRequest, RenderResponse, AroundClosure) line: 628
>       PortletApplicationHandler.process(ServletContext, HttpServletRequest, 
> HttpServletResponse, Input, Output, PortletWindowInternal, boolean) line: 226
>       ServletWrapper.service(HttpServletRequest, HttpServletResponse) line: 70
>       ServletWrapper(HttpServlet).service(ServletRequest, ServletResponse) 
> line: 802
>       ApplicationFilterChain.internalDoFilter(ServletRequest, 
> ServletResponse) line: 237
>       ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 
> 157
>       ApplicationDispatcher.invoke(ServletRequest, ServletResponse) line: 704
>       ApplicationDispatcher.doInclude(ServletRequest, ServletResponse) line: 
> 590
>       ApplicationDispatcher.include(ServletRequest, ServletResponse) line: 510
>       PortletContainerDispatcher.dispatch(HttpServletRequest, 
> HttpServletResponse, String) line: 370
>       PortletContainerDispatcher.process(HttpServletRequest, 
> HttpServletResponse, Input, boolean) line: 310
>       PortletContainerDispatcher.render(HttpServletRequest, 
> HttpServletResponse, RenderInput) line: 271
>       PortletContainerServiceImpl.render(HttpServletRequest, 
> HttpServletResponse, RenderInput) line: 144
>       PortletRenderer.encodeChildren(FacesContext, UIComponent) line: 100
>       UIPortlet(UIComponentBase).encodeChildren(FacesContext) line: 693
>       ContainerRowRenderer.renderViewMode(FacesContext, UIContainer) line: 40
>       ContainerRowRenderer(ContainerRenderer).encodeChildren(FacesContext, 
> UIComponent) line: 34
>       UIContainer(UIComponentBase).encodeChildren(FacesContext) line: 693
>       PortalRenderer(HtmlBasicRenderer).renderChildren(FacesContext, 
> UIComponent) line: 63
>       PortalRenderer.encodeChildren(FacesContext, UIComponent) line: 58
>       UIPortal(UIComponentBase).encodeChildren(FacesContext) line: 693
>       ExoPortalViewHandler.renderView(FacesContext, UIViewRoot) line: 63
>       RenderResponsePhase.execute(FacesContext) line: 87
>       LifecycleImpl.phase(PhaseId, Phase, FacesContext) line: 200
>       LifecycleImpl.render(FacesContext) line: 117
>       FacesServlet.service(ServletRequest, ServletResponse) line: 198
>       ApplicationFilterChain.internalDoFilter(ServletRequest, 
> ServletResponse) line: 237
>       ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 
> 157
>       PrivateRequestFilter.doFilter(ServletRequest, ServletResponse, 
> FilterChain) line: 82
>       ApplicationFilterChain.internalDoFilter(ServletRequest, 
> ServletResponse) line: 186
>       ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 
> 157
>       StandardWrapperValve.invoke(Request, Response, ValveContext) line: 214
>       StandardValveContext.invokeNext(Request, Response) line: 104
>       StandardPipeline.invoke(Request, Response) line: 520
>       StandardContextValve.invokeInternal(Wrapper, Request, Response) line: 
> 198
>       StandardContextValve.invoke(Request, Response, ValveContext) line: 152
>       StandardValveContext.invokeNext(Request, Response) line: 104
>       FormAuthenticator(AuthenticatorBase).invoke(Request, Response, 
> ValveContext) line: 540
>       StandardValveContext.invokeNext(Request, Response) line: 102
>       StandardPipeline.invoke(Request, Response) line: 520
>       StandardHostValve.invoke(Request, Response, ValveContext) line: 137
>       StandardValveContext.invokeNext(Request, Response) line: 104
>       ErrorReportValve.invoke(Request, Response, ValveContext) line: 117
>       StandardValveContext.invokeNext(Request, Response) line: 102
>       StandardPipeline.invoke(Request, Response) line: 520
>       StandardEngineValve.invoke(Request, Response, ValveContext) line: 109
>       StandardValveContext.invokeNext(Request, Response) line: 104
>       StandardPipeline.invoke(Request, Response) line: 520
>       StandardEngine(ContainerBase).invoke(Request, Response) line: 929
>       CoyoteAdapter.service(Request, Response) line: 160
>       Http11Processor.process(InputStream, OutputStream) line: 799
>       Http11Protocol$Http11ConnectionHandler.processConnection(TcpConnection, 
> Object[]) line: 705
>       TcpWorkerThread.runIt(Object[]) line: 577
>       ThreadPool$ControlRunnable.run() line: 683
>       ThreadWithAttributes(Thread).run() line: 536
>  private synchronized void checkShutdown()
>     {
>         if (_shutdown)  // Line 345
>             throw new 
> ApplicationRuntimeException(HiveMindMessages.registryShutdown());
>     }
> Are the only threads in the application anywhere near HiveMind. 
> Unfortunately, I was running with JDK 1.4, so I can't use Eclipse's debugger 
> to get at threads and monitors.
> This is something that needs more attention ... and I can't see how they 
> would be conflicting.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to