Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK8下,触发computeIfAbsent的BUG,会造成CPU100% #2294

Closed
xshiyu opened this issue Nov 9, 2021 · 2 comments
Closed

JDK8下,触发computeIfAbsent的BUG,会造成CPU100% #2294

xshiyu opened this issue Nov 9, 2021 · 2 comments
Labels
area/dubbo Tagged as dubbo-related issue/pr stale wait-for-feedback

Comments

@xshiyu
Copy link

xshiyu commented Nov 9, 2021

版本:spring-cloud-starter-dubbo-2.2.6.RELEASE
过程:启动的过程中,JVM会卡着不动,导致CPU 100%,无法启动

堆栈信息:
"main" #1 prio=5 os_prio=31 tid=0x00007fcb5a80b800 nid=0x2903 runnable [0x00007000006ca000]
java.lang.Thread.State: RUNNABLE
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1674)

  • locked <0x0000000773e2def8> (a java.util.concurrent.ConcurrentHashMap$ReservationNode)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.createProxyIfAbsent(DubboMetadataServiceProxy.java:140)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.createProxyIfAbsent(DubboMetadataServiceProxy.java:130)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.getProxy(DubboMetadataServiceProxy.java:99)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.getProxy0(DubboMetadataServiceProxy.java:164)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.getProxy(DubboMetadataServiceProxy.java:160)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.getProxy(DubboServiceMetadataRepository.java:266)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.getServiceRestMetadataSet(DubboServiceMetadataRepository.java:576)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.initDubboRestServiceMetadataRepository(DubboServiceMetadataRepository.java:471)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.initializeMetadata(DubboServiceMetadataRepository.java:262)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository$$Lambda$1141/1205751246.accept(Unknown Source)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.initializeMetadata(DubboServiceMetadataRepository.java:251)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository$$FastClassBySpringCGLIB$$4ef4b7bd.invoke()
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository$$EnhancerBySpringCGLIB$$8f342aa4.initializeMetadata()
    at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.preInit(DubboCloudRegistry.java:150)
    at co m.alibaba.cloud.dubbo.registry.DubboCloudRegistry.doRegister(DubboCloudRegistry.java:185)
  • locked <0x000000077efbe7d8> (a com.alibaba.cloud.dubbo.registry.DubboCloudRegistry)
    at org.apache.dubbo.registry.support.FailbackRegistry.register(FailbackRegistry.java:240)
    at org.apache.dubbo.registry.ListenerRegistryWrapper.register(ListenerRegistryWrapper.java:57)
    at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:466)
    at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:454)
    at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:72)
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:161)
    at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:73)
    at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
    at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:367)
    at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:305)
  • locked <0x000000077899af80> (a org.apache.dubbo.config.spring.ReferenceBean)
    at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:205)
  • locked <0x000000077899af80> (a org.apache.dubbo.config.spring.ReferenceBean)
    at com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory.create(DubboGenericServiceFactory.java:84)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceInvocationHandler.(DubboMetadataServiceInvocationHandler.java:40)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.createProxy(DubboMetadataServiceProxy.java:192)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.lambda$createProxyIfAbsent$0(DubboMetadataServiceProxy.java:141)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy$$Lambda$1067/1533182537.apply(Unknown Source)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
  • locked <0x0000000773e2def8> (a java.util.concurrent.ConcurrentHashMap$ReservationNode)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.createProxyIfAbsent(DubboMetadataServiceProxy.java:140)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.createProxyIfAbsent(DubboMetadataServiceProxy.java:130)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.getProxy(DubboMetadataServiceProxy.java:99)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.getProxy0(DubboMetadataServiceProxy.java:164)
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy.getProxy(DubboMetadataServiceProxy.java:160)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.getProxy(DubboServiceMetadataRepository.java:266)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.getServiceRestMetadataSet(DubboServiceMetadataRepository.java:576)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.initDubboRestServiceMetadataRepository(DubboServiceMetadataRepository.java:471)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.initializeMetadata(DubboServiceMetadataRepository.java:262)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository$$FastClassBySpringCGLIB$$4ef4b7bd.invoke()
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository$$EnhancerBySpringCGLIB$$8f342aa4.initializeMetadata()
    at com.alibaba.cloud.dubbo.openfeign.TargeterInvocationHandler.createDubboInvocationHandler(TargeterInvocationHandler.java:140)
    at com.alibaba.cloud.dubbo.openfeign.TargeterInvocationHandler.createDubboProxyIfRequired(TargeterInvocationHandler.java:103)
    at com.alibaba.cloud.dubbo.openfeign.TargeterInvocationHandler.invoke(TargeterInvocationHandler.java:97)
    at org.springframework.cloud.openfeign.$Proxy236.target(Unknown Source)
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:318)
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:347)
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:327)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:169)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101)
  • locked <0x00000006c0741aa0> (a java.util.concurrent.ConcurrentHashMap)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1828)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1265)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1532)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1489)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1270)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:521)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:228)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$155/1839962989.getObject(Unknown Source)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  • locked <0x00000006c0741aa0> (a java.util.concurrent.ConcurrentHashMap)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1525)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1489)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1408)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1265)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:521)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:228)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$155/1839962989.getObject(Unknown Source)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  • locked <0x00000006c0741aa0> (a java.util.concurrent.ConcurrentHashMap)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:453)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:527)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:228)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$155/1839962989.getObject(Unknown Source)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  • locked <0x00000006c0741aa0> (a java.util.concurrent.ConcurrentHashMap)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
  • locked <0x00000006c07b39e0> (a java.lang.Object)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
    at com.bc.job.JobExecutorApplication.main(JobExecutorApplication.java:17)

暂时的解决办法:
项目中覆盖DubboMetadataServiceProxy源码,修改createProxyIfAbsent方法
private DubboMetadataService createProxyIfAbsent(String serviceName, String version) {
if (dubboMetadataServiceCache.get(serviceName) == null) {
DubboMetadataService proxy = createProxy(serviceName, version);
dubboMetadataServiceCache.put(serviceName, proxy);
}
return dubboMetadataServiceCache.get(serviceName);
// return dubboMetadataServiceCache.computeIfAbsent(serviceName,
// name -> createProxy(name, version));
}

@zkzlx zkzlx added the area/dubbo Tagged as dubbo-related issue/pr label Nov 15, 2021
Copy link

This issue has been open 30 days with no activity. This will be closed in 7 days.

@github-actions github-actions bot added the stale label Feb 28, 2024
Copy link

github-actions bot commented Mar 6, 2024

This issue has been automatically marked as stale because it hasn't had any recent activity.If you think this should still be open, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. Thank you for your interest and contribution to the Sping Cloud Alibaba Community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dubbo Tagged as dubbo-related issue/pr stale wait-for-feedback
Projects
None yet
Development

No branches or pull requests

2 participants