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/08/03 03:56:02 UTC

[GitHub] [dubbo] startjava opened a new issue #8403: 关于dubbo.registry.check=false的疑问

startjava opened a new issue #8403:
URL: https://github.com/apache/dubbo/issues/8403


   dubbo.registry.check=false这个属性到底是做什么用的?官网上解释的太模糊了。
   
   我使用dubbo3.0.1和nacos2.0.3,,我把nacos服务关了,然后使用dubbo.registry.check=false配置,启动服务提供者时,由于连接不上nacos出现异常,导致进程启动不了,最终销毁。
   
   那么我想请教的是,这个dubbo.registry.check=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] CrazyHZM closed issue #8403: 关于dubbo.registry.check=false的疑问

Posted by GitBox <gi...@apache.org>.
CrazyHZM closed issue #8403:
URL: https://github.com/apache/dubbo/issues/8403


   


-- 
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] BurningCN commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   > @BurningCN 感谢,这个代码我也看到了,但我调试时并没有进入catch内部,直接跳退catch,我想知道的是,如何重现true和false在运行上的区别,感谢!
   
   可以尝试下测试程序 FailbackRegistryTest#testDoRetry方法中调用registry.register(serviceUrl);这一行内部执行的的逻辑。


-- 
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] BurningCN commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   尝试把serviceUrl加上一个port,registryUrl的check改为true,最终目的你要满足内部代码判定check等于true的条件
   
   
   
   ---原始邮件---
   发件人: ***@***.***&gt;
   发送时间: 2021年8月3日(周二) 下午5:41
   收件人: ***@***.***&gt;;
   抄送: ***@***.******@***.***&gt;;
   主题: Re: [apache/dubbo] 关于dubbo.registry.check=false的疑问 (#8403)
   
   
   
   
    
   @BurningCN
    
   我把代码setUp()方法中的:
    public class FailbackRegistryTest {
    static String service;
    static URL serviceUrl;
    static URL registryUrl;
    MockRegistry registry;
    private int FAILED_PERIOD = 200;
    private int sleeptime = 100;
    private int trytimes = 5;
    /**  * @throws java.lang.Exception  */ @BeforeEach public void setUp() throws Exception {     service = "org.apache.dubbo.test.DemoService";     serviceUrl = URL.valueOf("remote://127.0.0.1/demoservice?method=get");     registryUrl = URL.valueOf("http://1.2.3.4:9090/registry?check=false&amp;file=N/A").addParameter(REGISTRY_RETRY_PERIOD_KEY, String.valueOf(FAILED_PERIOD)); }  
   中的check=false和check=true都测试了一下,,,控制台输出结果是一样的,没有什么区别。
    
   —
   You are receiving this because you were mentioned.
   Reply to this email directly, view it on GitHub, or unsubscribe.
   Triage notifications on the go with GitHub Mobile for iOS or Android.


-- 
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] startjava commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   但是zk却向上抛出,如果这样,说明Nacos的代码有bug!
   
   ```
   public class ZookeeperRegistry extends CacheableFailbackRegistry {
       @Override
       public void doRegister(URL url) {
           try {
               zkClient.create(toUrlPath(url), url.getParameter(DYNAMIC_KEY, true));
           } catch (Throwable e) {
               throw new RpcException("Failed to register " + url + " to zookeeper " + getUrl() + ", cause: " + e.getMessage(), e);
           }
       }
   ```


-- 
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] startjava commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   @BurningCN 
   
   我把代码setUp()方法中的:
   public class FailbackRegistryTest {
       static String service;
       static URL serviceUrl;
       static URL registryUrl;
       MockRegistry registry;
       private int FAILED_PERIOD = 200;
       private int sleeptime = 100;
       private int trytimes = 5;
   
       /**
        * @throws java.lang.Exception
        */
       @BeforeEach
       public void setUp() throws Exception {
           service = "org.apache.dubbo.test.DemoService";
           serviceUrl = URL.valueOf("remote://127.0.0.1/demoservice?method=get");
           registryUrl = URL.valueOf("http://1.2.3.4:9090/registry?check=false&file=N/A").addParameter(REGISTRY_RETRY_PERIOD_KEY, String.valueOf(FAILED_PERIOD));
       }
   
   
   中的check=false和check=true都测试了一下,,,控制台输出结果是一样的,没有什么区别。


-- 
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] startjava commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   嗯嗯 ,感谢提示的DEBUG @Test起始,至少从哪调试,关注哪些代码有了头绪了。等官方看看:)


-- 
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] BurningCN commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   源码内部注册或订阅捕获到异常的时候,如果check=false,那么捕获异常后只会打印错误日志,如果check=true,则会抛给上层
   
   注册过程源码大致如下
   ![image](https://user-images.githubusercontent.com/43363120/127989305-d194aad2-e44d-46b1-879e-076878047263.png)
   
   


-- 
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] startjava commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   @BurningCN 
   
   如下代码:
       @Override
       public void register(URL url) {
           if (!acceptable(url)) {
               logger.info("URL " + url + " will not be registered to Registry. Registry " + url + " does not accept service of this protocol type.");
               return;
           }
           super.register(url);
           removeFailedRegistered(url);
           removeFailedUnregistered(url);
           try {
               // Sending a registration request to the server side
               doRegister(url);
   
   中的 doRegister(url);方法,会调用如下代码:
   public class NacosRegistry extends FailbackRegistry {
   
       private void execute(NamingServiceCallback callback) {
           try {
               callback.callback(namingService);
           } catch (NacosException e) {
               if (logger.isErrorEnabled()) {
                   logger.error(e.getErrMsg(), e);
               }
           }
       }
   
   方法callback如果出现异常,则execute方法就吃掉异常了,不会向上throw抛出异常,导致进不了如下代码中的catch:
           try {
               // Sending a registration request to the server side
               doRegister(url);
           } catch (Exception e) {
               Throwable t = e;
   
               // If the startup detection is opened, the Exception is thrown directly.
               boolean check = getUrl().getParameter(Constants.CHECK_KEY, true)
                       && url.getParameter(Constants.CHECK_KEY, true)
                       && !(url.getPort() == 0);
               boolean skipFailback = t instanceof SkipFailbackWrapperException;
               if (check || skipFailback) {
                   if (skipFailback) {
                       t = t.getCause();
                   }
                   throw new IllegalStateException("Failed to register " + url + " to registry " + getUrl().getAddress() + ", cause: " + t.getMessage(), t);
               } else {
                   logger.error("Failed to register " + url + ", waiting for retry, cause: " + t.getMessage(), t);
               }
   
               // Record a failed registration request to a failed list, retry regularly
               addFailedRegistered(url);
           }
   
   不知道我分析的对不对,我是调试搞的,不会进入catch,也就不会执行if check判断代码了。


-- 
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] startjava commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   @BurningCN 感谢,这个代码我也看到了,但我调试时并没有进入catch内部,直接跳退catch,我想知道的是,如何重现true和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] startjava commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   @BurningCN  灼华,能帮我@一下写这个功能的大佬吗,帮看看。因为运行的行为和官方文档不一样,,这对于dubbo3的学习者来讲,肯定未来会有相同的问题。


-- 
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] CrazyHZM commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   This question can be mentioned in nacos about issues and ask why no exception is thrown.
   


-- 
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] BurningCN commented on issue #8403: 关于dubbo.registry.check=false的疑问

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


   哈哈 老哥挺有意思 nacos的具体逻辑我不太了解 你可以自己仔细验证下呢 真有bug的话可以提交个pr修复下
   
   
   
   ---原始邮件---
   发件人: ***@***.***&gt;
   发送时间: 2021年8月3日(周二) 晚上6:36
   收件人: ***@***.***&gt;;
   抄送: ***@***.******@***.***&gt;;
   主题: Re: [apache/dubbo] 关于dubbo.registry.check=false的疑问 (#8403)
   
   
   
   
    
   但是zk却向上抛出,如果这样,说明Nacos的代码有bug!
    public class ZookeeperRegistry extends CacheableFailbackRegistry {     @Override     public void doRegister(URL url) {         try {             zkClient.create(toUrlPath(url), url.getParameter(DYNAMIC_KEY, true));         } catch (Throwable e) {             throw new RpcException("Failed to register " + url + " to zookeeper " + getUrl() + ", cause: " + e.getMessage(), e);         }     }  
   —
   You are receiving this because you were mentioned.
   Reply to this email directly, view it on GitHub, or unsubscribe.
   Triage notifications on the go with GitHub Mobile for iOS or Android.


-- 
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