Hi Team, I have recently migrated my application from CAS v6.6.2 to v7.0.0 I am facing the issues during the restart. It intermittently gets stuck and we get a deadlock in the thread dump.
We have tried various solution, setting the lazy initialization to false. Creating a filter to revoke all the request during startup, even tried to delay the dispatcher Servlet initialization. but it didn't help. What we suspect is that the combination of @RefreshScope and @Lazy annotation creating issues, which is being widely used in CAS v7.0.0. We came to the above conclusion due to [an issue][1] mentioned in the spring repo. On this bug there is a file attached which also have the exact same deadlock. [RefreshScopeDeadLock.zip](https://github.com/spring-cloud/spring-cloud-commons/files/2097879/RefreshScopeDeadLock.zip). Thread dump stacktrace: ``` Found one Java-level deadlock: ============================= "Thread-10": waiting to lock monitor 0x000000001fec2c78 (object 0x000000076fd80250, a java.lang.String), which is held by "Thread-5" "Thread-5": waiting to lock monitor 0x000000001be39628 (object 0x000000076fd7ba88, a java.util.concurrent.ConcurrentHashMap), which is held by "Thread-10" Java stack information for the threads listed above: =================================================== "Thread-10": at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:380) - waiting to lock <0x000000076fd80250> (a java.lang.String) at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:183) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:350) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) at my.project.name.RefreshScopeDeadLock$FakeSampler$$EnhancerBySpringCGLIB$$212b6f8d.doSomething(<generated>) at my.project.name.RefreshScopeDeadLock$InCreationBean.accessFakesampler(RefreshScopeDeadLock.java:99) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:308) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1694) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$8/556529265.getObject(Unknown Source) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) - locked <0x000000076fd7ba88> (a java.util.concurrent.ConcurrentHashMap) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:224) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1015) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:339) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1107) at my.project.name.RefreshScopeDeadLock.lambda$0(RefreshScopeDeadLock.java:27) at my.project.name.RefreshScopeDeadLock$$Lambda$57/1367937032.run(Unknown Source) at java.lang.Thread.run(Thread.java:748) "Thread-5": at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:185) - waiting to lock <0x000000076fd7ba88> (a java.util.concurrent.ConcurrentHashMap) at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:490) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:427) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:398) at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1276) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:815) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:721) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:470) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:353) at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$59/1420933976.getObject(Unknown Source) at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:382) - locked <0x000000076fd80250> (a java.lang.String) at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:183) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:350) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) at my.project.name.RefreshScopeDeadLock$FakeSampler$$EnhancerBySpringCGLIB$$212b6f8d.doSomething(<generated>) at my.project.name.RefreshScopeDeadLock$AlreadyCreatedBean.accessFakesampler(RefreshScopeDeadLock.java:85) at my.project.name.RefreshScopeDeadLock$$Lambda$56/575935098.run(Unknown Source) at java.lang.Thread.run(Thread.java:748) Found 1 deadlock. ``` Is there any solution to it? [1]: https://github.com/spring-cloud/spring-cloud-commons/issues/383 -- - Website: https://apereo.github.io/cas - Gitter Chatroom: https://gitter.im/apereo/cas - List Guidelines: https://goo.gl/1VRrw7 - Contributions: https://goo.gl/mh7qDG --- You received this message because you are subscribed to the Google Groups "CAS Community" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/a28d3982-0703-4fe1-ad0f-9d838747b23fn%40apereo.org.
