You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/01 13:16:09 UTC

[GitHub] [dubbo] haoyann opened a new issue #8654: [3.0] GenericService can't created multiple times

haoyann opened a new issue #8654:
URL: https://github.com/apache/dubbo/issues/8654


   - [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   - [x] I have checked the [FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 3.0.2
   * Operating System version: xxx
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   1. 创建 `GenericService` 调用完成之后销毁,代码类似下面
   ```
           ApplicationConfig applicationConfig = new ApplicationConfig();
           applicationConfig.setName("generic-call-consumer");
           RegistryConfig registryConfig = new RegistryConfig();
           registryConfig.setAddress("zookeeper://127.0.0.1:2181");
           ReferenceConfig<GenericService> referenceConfig = new ReferenceConfig<>();
           referenceConfig.setInterface("org.test.apache.dubbo.interfaces.TestService");
           applicationConfig.setRegistry(registryConfig);
           referenceConfig.setApplication(applicationConfig);
           referenceConfig.setGeneric(true);
           referenceConfig.setAsync(true);
           referenceConfig.setTimeout(7000);
           GenericService genericService = referenceConfig.get();
           genericService.$invoke("test", null, null);
           referenceConfig.destroy();
   ```
   2. 在一次调用成功之后,再次调用抛出异常
   ```
   java.lang.IllegalStateException: Found multiple ReferenceConfigs with unique service name [org.test.apache.dubbo.interfaces.PeopleService], previous: <dubbo:reference async="true" sticky="false" timeout="7000" check="false" generic="true" interface="org.test.apache.dubbo.interfaces.TestService" />, later: <dubbo:reference async="true" timeout="7000" generic="true" interface="org.test.apache.dubbo.interfaces.PeopleService" />. There can only be one instance of ReferenceConfig with the same triple (group, interface, version). If multiple instances are required for the same interface, please use a different group or version.
   	at org.apache.dubbo.config.context.ConfigManager.checkDuplicatedInterfaceConfig(ConfigManager.java:741) ~[dubbo-3.0.2.jar:3.0.2]
   	at org.apache.dubbo.config.context.ConfigManager.addIfAbsent(ConfigManager.java:611) ~[dubbo-3.0.2.jar:3.0.2]
   	at org.apache.dubbo.config.context.ConfigManager.addConfig(ConfigManager.java:490) ~[dubbo-3.0.2.jar:3.0.2]
   	at org.apache.dubbo.config.context.ConfigManager.addConfig(ConfigManager.java:461) ~[dubbo-3.0.2.jar:3.0.2]
   	at org.apache.dubbo.config.context.ConfigManager.addReference(ConfigManager.java:388) ~[dubbo-3.0.2.jar:3.0.2]
   	at org.apache.dubbo.config.bootstrap.DubboBootstrap.reference(DubboBootstrap.java:446) ~[dubbo-3.0.2.jar:3.0.2]
   	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:238) ~[dubbo-3.0.2.jar:3.0.2]
   	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:204) ~[dubbo-3.0.2.jar:3.0.2]
   	at org.test.apache.dubbo.consumer.HelloConsumer.test(HelloConsumer.java:51) ~[classes/:na]
   ```
   3. 经过分析之后,`ReferenceConfig` 第一次创建完成之后将会缓存起来,之后同一个服务的 `ReferenceConfig`  将从缓存中获取,并比较对象是否相等。但是`ReferenceConfig` 初始化完成之后会做一些属性的赋值,导致在此地方虽然是同一个服务的 `ReferenceConfig` 的 `equals` 方法却返回 `false`
   prevConfig
   ![image](https://user-images.githubusercontent.com/43994656/131676603-95a19058-15fa-4189-868a-f0f4d927f09b.png)
   config
   ![image](https://user-images.githubusercontent.com/43994656/131676645-445c28ea-1684-4796-9231-a2debca497dc.png)
   4. 泛化调用创建的 `ReferenceConfig` 是否需要缓存,感觉有内存爆炸的风险,还有这里的 `equals` 是否需要改进,现在看来即使是同一个服务,参数全部相同的情况下到这个地方也会是false。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [dubbo] haoyann commented on issue #8654: [3.0] GenericService can't created multiple times

Posted by GitBox <gi...@apache.org>.
haoyann commented on issue #8654:
URL: https://github.com/apache/dubbo/issues/8654#issuecomment-913936882


   现在有两张方法可以暂时规避这个问题:
   1. 设置 sticky ` referenceConfig.setSticky(false)`  属性,与缓存中保持一致
   2. 允许有重复的存在 ReferenceConfig 存在,配置 `dubbo.config.ignore-duplicated-interface = true`
   
   这两种方法都会将配置一直存放在缓存中,是否可以考虑在 `ReferenceConfig#destroy` 的时候,将 ReferenceConfig 从 ConfigManager 中移除。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [dubbo] haoyann edited a comment on issue #8654: [3.0] GenericService can't created multiple times

Posted by GitBox <gi...@apache.org>.
haoyann edited a comment on issue #8654:
URL: https://github.com/apache/dubbo/issues/8654#issuecomment-913936882


   现在有两种方法可以暂时规避这个问题:
   1. 设置 sticky ` referenceConfig.setSticky(false)`  属性,与缓存中保持一致
   2. 允许有重复的存在 ReferenceConfig 存在,配置 `dubbo.config.ignore-duplicated-interface = true`
   
   这两种方法都会将配置一直存放在缓存中,是否可以考虑在 `ReferenceConfig#destroy` 的时候,将 ReferenceConfig 从 ConfigManager 中移除。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [dubbo] haoyann edited a comment on issue #8654: [3.0] GenericService can't created multiple times

Posted by GitBox <gi...@apache.org>.
haoyann edited a comment on issue #8654:
URL: https://github.com/apache/dubbo/issues/8654#issuecomment-913936882


   现在有两种方法可以暂时规避这个问题:
   1. 设置 sticky ` referenceConfig.setSticky(false)`  属性,与缓存中保持一致
   2. 允许有重复的 ReferenceConfig 存在,配置 `dubbo.config.ignore-duplicated-interface = true`
   
   这两种方法都会将配置一直存放在缓存中,是否可以考虑在 `ReferenceConfig#destroy` 的时候,将 ReferenceConfig 从 ConfigManager 中移除。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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