Description
Application on which the deadlock is seen is using PoolingHttpClientConnectionManager for managing http connections for HttpClient. There is a timer job which keeps executing HTTP requests on external urls, which is using this PoolingHttpClientConnectionManager.
Sometimes while shutting down this application a deadlock is seen. Stack trace below.
Thread 1
Monitor
Owns Monitor Lock on com/ibm/ws/runtime/component/ApplicationMgrImpl@0x0000000700B17A58
Waiting for Monitor Lock on org/apache/http/pool/AbstractConnPool$2@0x0000000709E27898
Java Stack
at org/apache/http/pool/AbstractConnPool$2.cancel(AbstractConnPool.java:206) at org/apache/http/pool/RouteSpecificPool.shutdown(RouteSpecificPool.java:155) at org/apache/http/pool/AbstractConnPool.shutdown(AbstractConnPool.java:152) at org/apache/http/impl/conn/PoolingHttpClientConnectionManager.shutdown(PoolingHttpClientConnectionManager.java:396) at org/apache/http/impl/client/HttpClientBuilder$2.close(HttpClientBuilder.java:1225) at org/apache/http/impl/client/InternalHttpClient.close(InternalHttpClient.java:201) at com/test/monitor/HttpClientFactory.safeClose(HttpClientFactory.java:89) at com/test/monitor/HttpClientFactory.close(HttpClientFactory.java:83) at sun/reflect/NativeMethodAccessorImpl.invoke0(Native Method) at sun/reflect/NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76(Compiled Code)) at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43(Compiled Code)) at java/lang/reflect/Method.invoke(Method.java:607(Compiled Code)) at org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366) at org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeDestroyMethods(InitDestroyAnnotationBeanPostProcessor.java:325) at org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.postProcessBeforeDestruction(InitDestroyAnnotationBeanPostProcessor.java:154) at org/springframework/beans/factory/support/DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) at org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) at org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) at org/springframework/beans/factory/support/DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) at org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) at org/springframework/beans/factory/support/DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) at org/springframework/context/support/AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033) at org/springframework/context/support/AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009) at org/springframework/context/support/AbstractApplicationContext.close(AbstractApplicationContext.java:961) at org/springframework/web/context/ContextLoader.closeWebApplicationContext(ContextLoader.java:581) at org/springframework/web/context/ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116) at com/ibm/ws/webcontainer/webapp/WebApp.notifyServletContextDestroyed(WebApp.java:1741) at com/ibm/ws/webcontainer/webapp/WebApp.destroy(WebApp.java:3085) at com/ibm/ws/webcontainer/webapp/WebAppImpl.destroy(WebAppImpl.java:1291) at com/ibm/ws/container/AbstractContainer.destroy(AbstractContainer.java:75) at com/ibm/ws/webcontainer/webapp/WebGroup.destroy(WebGroup.java:228) at com/ibm/ws/webcontainer/webapp/WebGroup.removeWebApplication(WebGroup.java:269) at com/ibm/ws/webcontainer/VirtualHost.removeWebApplication(VirtualHost.java:296) at com/ibm/ws/webcontainer/VirtualHostImpl.removeWebApplication(VirtualHostImpl.java:211) at com/ibm/ws/webcontainer/WSWebContainer.removeWebApplication(WSWebContainer.java:820) at com/ibm/ws/webcontainer/component/WebContainerImpl.uninstall(WebContainerImpl.java:458) at com/ibm/ws/webcontainer/component/WebContainerImpl.stop(WebContainerImpl.java:729) at com/ibm/ws/runtime/component/ApplicationMgrImpl.stop(ApplicationMgrImpl.java:1216) at com/ibm/ws/runtime/component/DeployedApplicationImpl.fireDeployedObjectStop(DeployedApplicationImpl.java:1375) at com/ibm/ws/runtime/component/DeployedModuleImpl.stop(DeployedModuleImpl.java:671) at com/ibm/ws/runtime/component/DeployedApplicationImpl.stop(DeployedApplicationImpl.java:1149) at com/ibm/ws/runtime/component/ApplicationMgrImpl.stopApplication(ApplicationMgrImpl.java:950) at com/ibm/ws/runtime/component/ApplicationMgrImpl.stopApplicationImpl(ApplicationMgrImpl.java:1479) at com/ibm/ws/runtime/component/ApplicationMgrImpl.stop(ApplicationMgrImpl.java:2221) at com/ibm/ws/runtime/component/CompositionUnitMgrImpl.stop(CompositionUnitMgrImpl.java:502) at com/ibm/ws/runtime/component/CompositionUnitImpl.stop(CompositionUnitImpl.java:141) at com/ibm/ws/runtime/component/CompositionUnitMgrImpl$2.run(CompositionUnitMgrImpl.java:805) at com/ibm/ws/security/auth/ContextManagerImpl.runAs(ContextManagerImpl.java:5474(Compiled Code)) at com/ibm/ws/security/auth/ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5600(Compiled Code)) at com/ibm/ws/security/core/SecurityContext.runAsSystem(SecurityContext.java:255(Compiled Code)) at com/ibm/ws/runtime/component/CompositionUnitMgrImpl.stopCompositionUnit(CompositionUnitMgrImpl.java:840) at com/ibm/ws/runtime/component/CompositionUnitMgrImpl.stopCompositionUnit(CompositionUnitMgrImpl.java:746) at com/ibm/ws/runtime/component/ApplicationMgrImpl.stopApplication(ApplicationMgrImpl.java:1457) at sun/reflect/NativeMethodAccessorImpl.invoke0(Native Method) at sun/reflect/NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76(Compiled Code)) at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43(Compiled Code)) at java/lang/reflect/Method.invoke(Method.java:607(Compiled Code)) at sun/reflect/misc/Trampoline.invoke(MethodUtil.java:75) at sun/reflect/GeneratedMethodAccessor146.invoke(Bytecode PC:40) at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43(Compiled Code)) at java/lang/reflect/Method.invoke(Method.java:607(Compiled Code)) at sun/reflect/misc/MethodUtil.invoke(MethodUtil.java:279) at javax/management/modelmbean/RequiredModelMBean$4.run(RequiredModelMBean.java:1245) at java/security/AccessController.doPrivileged(AccessController.java:300) at java/security/ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at javax/management/modelmbean/RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1239) at javax/management/modelmbean/RequiredModelMBean.invoke(RequiredModelMBean.java:1077) at com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com/sun/jmx/mbeanserver/JmxMBeanServer.invoke(JmxMBeanServer.java:801) at com/ibm/ws/management/AdminServiceImpl$1.run(AdminServiceImpl.java:1335) at com/ibm/ws/security/util/AccessController.doPrivileged(AccessController.java:118(Compiled Code)) at com/ibm/ws/management/AdminServiceImpl.invoke(AdminServiceImpl.java:1228) at com/ibm/ws/management/connector/AdminServiceDelegator.invoke(AdminServiceDelegator.java:181) at com/ibm/ws/management/connector/ipc/CallRouter.route(CallRouter.java:247(Compiled Code)) at com/ibm/ws/management/connector/ipc/IPCConnectorInboundLink.doWork(IPCConnectorInboundLink.java:360(Compiled Code)) at com/ibm/ws/management/connector/ipc/IPCConnectorInboundLink$IPCConnectorReadCallback.complete(IPCConnectorInboundLink.java:602(Compiled Code)) at com/ibm/ws/ssl/channel/impl/SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784(Compiled Code)) at com/ibm/ws/tcp/channel/impl/AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175(Compiled Code)) at com/ibm/io/async/AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217(Compiled Code)) at com/ibm/io/async/AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161(Compiled Code)) at com/ibm/io/async/AsyncFuture.completed(AsyncFuture.java:138(Compiled Code)) at com/ibm/io/async/ResultHandler.complete(ResultHandler.java:204(Compiled Code)) at com/ibm/io/async/ResultHandler.runEventProcessingLoop(ResultHandler.java:775(Compiled Code)) at com/ibm/io/async/ResultHandler$2.run(ResultHandler.java:905(Compiled Code)) at com/ibm/ws/util/ThreadPool$Worker.run(ThreadPool.java:1862(Compiled Code))
Thread 2
Monitor
Owns Monitor Lock on org/apache/http/pool/AbstractConnPool$2@0x0000000709E27898
Java Stack
at sun/misc/Unsafe.park(Native Method) at java/util/concurrent/locks/LockSupport.park(LockSupport.java:186(Compiled Code)) at java/util/concurrent/locks/AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834(Compiled Code)) at java/util/concurrent/locks/AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867(Compiled Code)) at java/util/concurrent/locks/AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2047) at org/apache/http/pool/AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:377) at org/apache/http/pool/AbstractConnPool.access$200(AbstractConnPool.java:67) at org/apache/http/pool/AbstractConnPool$2.get(AbstractConnPool.java:243) at org/apache/http/pool/AbstractConnPool$2.get(AbstractConnPool.java:191) at org/apache/http/impl/conn/PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:282) at org/apache/http/impl/conn/PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:269) at org/apache/http/impl/execchain/MainClientExec.execute(MainClientExec.java:191) at org/apache/http/impl/execchain/ProtocolExec.execute(ProtocolExec.java:185) at org/apache/http/impl/execchain/RedirectExec.execute(RedirectExec.java:111) at org/apache/http/impl/client/InternalHttpClient.doExecute(InternalHttpClient.java:185) at org/apache/http/impl/client/CloseableHttpClient.execute(CloseableHttpClient.java:83) at org/apache/http/impl/client/CloseableHttpClient.execute(CloseableHttpClient.java:108) at org/apache/http/impl/client/CloseableHttpClient.execute(CloseableHttpClient.java:56) at com/test/monitor/HttpResourceMonitor.executeHttpGETRequest(HttpResourceMonitor.java:59) at com/test/monitor/HttpResourceMonitor.doMonitor(HttpResourceMonitor.java:47) at com/test/monitor/GenericResourceMonitor.monitor(GenericResourceMonitor.java:34) at sun/reflect/NativeMethodAccessorImpl.invoke0(Native Method) at sun/reflect/NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76(Compiled Code)) at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43(Compiled Code)) at java/lang/reflect/Method.invoke(Method.java:607(Compiled Code)) at org/springframework/scheduling/support/ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) at org/springframework/scheduling/support/DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at org/springframework/scheduling/concurrent/ReschedulingRunnable.run(ReschedulingRunnable.java:81) at java/util/concurrent/Executors$RunnableAdapter.call(Executors.java:471) at java/util/concurrent/FutureTask$Sync.innerRun(FutureTask.java:334) at java/util/concurrent/FutureTask.run(FutureTask.java:166) at java/util/concurrent/ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) at java/util/concurrent/ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) 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:781)