dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] cvictory opened a new issue #2539: When adding @Referenc in Multicast registry, deadlock happened.
Date Thu, 20 Sep 2018 07:27:05 GMT
cvictory opened a new issue #2539: When adding @Referenc in Multicast registry, deadlock happened.
URL: https://github.com/apache/incubator-dubbo/issues/2539
 
 
   
   ### Environment
   
   * Dubbo version: 2.6.x
   * Operating System version:  mac
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   1. when use multicast as registry (It work well when using zookeeper)
   2. use @Reference to get the consumer
   
   You can write a demo base on dubbo demo module, just modify 3 files.  
   
   1.Add new configuration file (dubbo-demo2-consumer.xml):
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   
   <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
          xmlns:context="http://www.springframework.org/schema/context"
          xmlns="http://www.springframework.org/schema/beans"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
          http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
   
       <!-- consumer's application name, used for tracing dependency relationship (not
a matching criterion),
       don't set it same as provider -->
       <dubbo:application name="demo-consumer"/>
   
       <!-- use multicast registry center to discover service -->
       <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
   
       <!-- generate proxy for the remote service, then demoService can be used in the
same way as the
       local regular interface -->
       <dubbo:annotation/>
       <context:component-scan base-package="com.alibaba.dubbo.demo.consumer">
           <context:include-filter type="annotation" expression="com.alibaba.dubbo.config.annotation.Reference"/>
       </context:component-scan>
   
   </beans>
   
   ```
   2.new service to consumer package:
   ```
   @Service
   public class ConsumerService {
   
       @Reference(parameters = {"k1", "v1"})
       private DemoService demoService;
   
       public void testReference() {
           System.out.println(demoService.sayHello("www.world"));
       }
   }
   ```
   3.new main File :  
   
   ```
   public class Consumer2 {
   
       public static void main(String[] args) {
           //Prevent to get IPV6 address,this way only work in debug mode
           //But you can pass use -Djava.net.preferIPv4Stack=true,then it work well whether
in debug mode or not
           System.setProperty("java.net.preferIPv4Stack", "true");
           ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new
String[]{"META-INF/spring/dubbo-demo2-consumer.xml"});
           context.start();
           ConsumerService consumerService = (ConsumerService) context.getBean(ConsumerService.class);
// get remote service proxy
   
           while (true) {
               try {
                   Thread.sleep(1000);
                   consumerService.testReference(); // call remote method
   
               } catch (Throwable throwable) {
                   throwable.printStackTrace();
               }
           }
       }
   }
   ```
   
   
   ### Actual Result
   
   when start the consumer, the program has no response. 
   so I print the jstack trace as follow: 
   
   ```
   
   Found one Java-level deadlock:
   =============================
   "DubboMulticastRegistryReceiver":
     waiting to lock monitor 0x00007fde47292668 (object 0x000000076eb01868, a java.util.concurrent.ConcurrentHashMap),
     which is held by "main"
   "main":
     waiting to lock monitor 0x00007fde4a810488 (object 0x000000076eb5e4c0, a com.alibaba.dubbo.registry.integration.RegistryDirectory),
     which is held by "DubboMulticastRegistryReceiver"
   
   Java stack information for the threads listed above:
   ===================================================
   "DubboMulticastRegistryReceiver":
           at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:188)
           - waiting to lock <0x000000076eb01868> (a java.util.concurrent.ConcurrentHashMap)
           at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:492)
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:432)
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:403)
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:389)
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1002)
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:345)
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340)
           at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1092)
           at com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory.getExtension(SpringExtensionFactory.java:67)
           at com.alibaba.dubbo.common.extension.factory.AdaptiveExtensionFactory.getExtension(AdaptiveExtensionFactory.java:47)
           at com.alibaba.dubbo.common.extension.ExtensionLoader.injectExtension(ExtensionLoader.java:521)
           at com.alibaba.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:497)
           at com.alibaba.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:309)
           - locked <0x000000076b5ff4d8> (a com.alibaba.dubbo.common.utils.Holder)
           at com.alibaba.dubbo.common.extension.ExtensionLoader.getActivateExtension(ExtensionLoader.java:193)
           at com.alibaba.dubbo.common.extension.ExtensionLoader.getActivateExtension(ExtensionLoader.java:172)
           at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.buildInvokerChain(ProtocolFilterWrapper.java:48)
           at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:108)
           at com.alibaba.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
           at com.alibaba.dubbo.registry.integration.RegistryDirectory.toInvokers(RegistryDirectory.java:387)
           at com.alibaba.dubbo.registry.integration.RegistryDirectory.refreshInvoker(RegistryDirectory.java:253)
           at com.alibaba.dubbo.registry.integration.RegistryDirectory.notify(RegistryDirectory.java:223)
           - locked <0x000000076eb5e4c0> (a com.alibaba.dubbo.registry.integration.RegistryDirectory)
           at com.alibaba.dubbo.registry.support.AbstractRegistry.notify(AbstractRegistry.java:414)
           at com.alibaba.dubbo.registry.support.FailbackRegistry.doNotify(FailbackRegistry.java:280)
           at com.alibaba.dubbo.registry.support.FailbackRegistry.notify(FailbackRegistry.java:266)
           at com.alibaba.dubbo.registry.multicast.MulticastRegistry.registered(MulticastRegistry.java:333)
           at com.alibaba.dubbo.registry.multicast.MulticastRegistry.receive(MulticastRegistry.java:209)
           at com.alibaba.dubbo.registry.multicast.MulticastRegistry.access$100(MulticastRegistry.java:54)
           at com.alibaba.dubbo.registry.multicast.MulticastRegistry$1.run(MulticastRegistry.java:104)
           at java.lang.Thread.run(Thread.java:748)
   "main":
           at java.lang.Object.wait(Native Method)
           - waiting on <0x000000076eb5e4c0> (a com.alibaba.dubbo.registry.integration.RegistryDirectory)
           at com.alibaba.dubbo.registry.multicast.MulticastRegistry.doSubscribe(MulticastRegistry.java:278)
           - locked <0x000000076eb5e4c0> (a com.alibaba.dubbo.registry.integration.RegistryDirectory)
           at com.alibaba.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:196)
           at com.alibaba.dubbo.registry.multicast.MulticastRegistry.subscribe(MulticastRegistry.java:394)
           at com.alibaba.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:159)
           at com.alibaba.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:306)
           at com.alibaba.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:287)
           at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:65)
           at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:106)
           at com.alibaba.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
           at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:394)
           at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:333)
           at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:163)
           - locked <0x000000076eb00f18> (a com.alibaba.dubbo.config.spring.ReferenceBean)
           at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:66)
           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 com.alibaba.dubbo.config.AbstractConfig.toString(AbstractConfig.java:466)
           at java.lang.String.valueOf(String.java:2994)
           at java.lang.StringBuilder.append(StringBuilder.java:131)
           at com.alibaba.dubbo.config.spring.beans.factory.annotation.AbstractAnnotationConfigBeanBuilder.build(AbstractAnnotationConfigBeanBuilder.java:79)
           at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildReferenceBean(ReferenceAnnotationBeanPostProcessor.java:385)
           at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.access$100(ReferenceAnnotationBeanPostProcessor.java:65)
           at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceFieldElement.inject(ReferenceAnnotationBeanPostProcessor.java:363)
           at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
           at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.postProcessPropertyValues(ReferenceAnnotationBeanPostProcessor.java:92)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1268)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
           at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
           at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
           - locked <0x000000076eb01868> (a java.util.concurrent.ConcurrentHashMap)
           at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
           at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
           at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
           - locked <0x000000076ec5b718> (a java.lang.Object)
           at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
           at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
           at com.alibaba.dubbo.demo.consumer.Consumer2.main(Consumer2.java:15)
   
   Found 1 deadlock.
   
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Mime
View raw message