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/11/09 02:52:16 UTC

[GitHub] [dubbo] haoyann opened a new issue #9239: 新增动态配置无效

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


   <!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
   
   - [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 3.0 branch
   * Operating System version: all
   * Java version: all
   
   ### Steps to reproduce this issue
   #8833 改动忽略了新增配置的类型,导致使用 zkClient.create() 和 nacos 新增配置无效。
   ```
           if (event.getChangeType().equals(ConfigChangeType.ADDED)) {
               return;
           }
   ```
   Nacos 获取配置类型
   ```
           private ConfigChangeType getChangeType(String configInfo, String oldValue) {
               if (StringUtils.isBlank(configInfo)) {
                   return ConfigChangeType.DELETED;
               }
               if (StringUtils.isBlank(oldValue)) {
                   return ConfigChangeType.ADDED;
               }
               return ConfigChangeType.MODIFIED;
           }
   ```
   
   ### Expected Behavior
   
   <!-- What do you expect from the above steps?-->
   
   ### Actual Behavior
   
   <!-- What actually happens? -->
   
   If there is an exception, please attach the exception trace:
   
   ```
   Just put your stack trace here!
   ```
   


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   @AlbumenJ  这个issue可以关了,pr已经merge 


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   dubbo-samples-applevel-override的DemoServiceIT有通过UpgradeUtil.writeXxxRule()调用ZookeeperDynamicConfiguration.publishConfig(key, group, value)方法(最终调用的是doPublishConfig方法),跟了一下这个方法触发的事件只有consumer端的MigrationRuleListener在监听,并不涉及AbstractConfiguratorListener。
   另外跟踪确认这个工程只有provider端在用AbstractConfiguratorListener监听zk事件,客户端调用zk.create并不会触发服务端的zk事件,客户端继续调用org.apache.curator.framework.imps.CreateBuilderImpl.forPath方法时才会触发服务端zk事件,其中触发服务端ADDED事件的时候,CreateBuilderImpl.forPath传给服务端的data是CuratorFrameworkFactory的defaultData,值是localAddress(本机地址),所以provider通过AbstractConfiguratorListener收到的事件content只是客户端的ip地址。
   看起来dubbo consumer和provider的zk事件处理类是不一样的,所以AbstractConfiguratorListener应该不会导致出现新增动态配置无效的情况。 


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   dubbo-samples的dubbo-samples-applevel-override就能稳定重现:
   1. CuratorZookeeperClient的344行设置断点
   ```
               } else if (childData.getStat().getVersion() == 0) {
                   content = new String(childData.getData(), CHARSET);
                   eventType = EventType.NodeCreated;  <== line 344 set breakpoint here
               } else {
   ```
   2. 启动zk服务,端口2181
   3. debug启动BasicProvider, 启动参数加dubbo.port=20880
   4. debug启动BasicProvider, 启动参数加dubbo.port=20881
   5. 在ZKTools的66行设置断点:
   ```
               if (client.checkExists().forPath(path) == null) {
                   client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(path);  <== line 66 set breakpoint
               }
   ```
   6. debug执行DemoServiceIT单元测试
   7. DemoServiceIT到达ZKTools的66行断点处之后开始单步执行,单步执行若干次之后,两个provider中的一个就会执行到CuratorZookeeperClient的344行断点,查看content内容就会看到里面只有一个ip地址。
   


-- 
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 #9239: 新增动态配置无效

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


   > 改回原来的处理方式了,解析事件内容失败时的日志级别从error改为了warn,同时删掉了调用栈信息。
   
   多谢,不过如果原始的异常是在 CI 里面发现的,可以排查一下 CI 程序,看下为什么会写入一个 IP 地址进去。


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   下午没能重现issue现象的原因很弱鸡,断点设置的dubbo版本和dubbo-samples使用的dubbo版本不一致,所以设置的断点都没有执行到,改成一致版本之后,就可以跟踪了。
   nacos和zk的确不一样,以dubbo-samples的dubbo-samples-nacos-override为例,启动BasicProvider时,同时有两个线程要解析服务实例的URL列表:
   1. 线程A执行RegistryProtocol的export方法:调用overrideUrlWithConfig创建ServiceConfigurationListener,通过AbstractConfiguratorListener的initWith方法,直接调用AbstractConfiguratorListener的genConfiguratorsFromRawRule解析URL列表;
   2. 线程B执行NacosDynamicConfiguration内部NacosConfigListener对象的innerReceive方法:通过AbstractConfiguratorListener的process方法(ADDED事件),调用AbstractConfiguratorListener的genConfiguratorsFromRawRule解析URL列表。
   
   两个线程解析的rawConfig内容相同,解析出来的URL列表存入的configurators也是同一个对象,不清楚为什么由两个不同的线程重复解析。
   
   Dubbo-admin我下载了develop当前分支,构建之后测了一下dubbo-samples-nacos-override的动态配置增、改、删,确认和述线程B执行过程相同(事件分别为ADDED、MODIFIED、DELETED)。
   
   目前看nacos没有zk那样的单独创建node的事件。
   @chickenlj @haoyann @CrazyHZM 
   
   更新:
   zk创建节点时如果用的是forPath(path, rawConfig.getBytes())而不是forPath(path),zk的ADDED事件content也是有内容的。
   所以ADDED事件还是需要解析。


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   既然AbstractConfiguratorListener的process的目的就是解析URL,事件content如果是单个IP,也应视为URL,我重新改了一下PR,解析yaml异常就再用org.apache.dubbo.common.URL.valueOf处理一下,只要不是null就不告警了。


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   既然AbstractConfiguratorListener的process的目的就是解析URL,事件content如果是单个IP,也应视为URL(虽然纯粹的IP也没有什么用,后面的处理代码还是弃掉),我重新改了一下PR,解析yaml异常就再用org.apache.dubbo.common.URL.valueOf处理一下,只要不是null就不告警了。


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   dubbo-samples-applevel-override的DemoServiceIT有通过UpgradeUtil.writeXxxRule()调用ZookeeperDynamicConfiguration.publishConfig(key, group, value)方法(最终调用的是doPublishConfig方法),跟了一下这个方法触发的事件只有consumer端的MigrationRuleListener在监听,并不涉及AbstractConfiguratorListener。
   另外跟踪确认这个工程只有provider端在用AbstractConfiguratorListener监听zk事件,客户端调用zk.create并不会触发服务端的zk事件,客户端继续调用org.apache.curator.framework.imps.CreateBuilderImpl.forPath方法时才会触发服务端zk事件,其中触发服务端ADDED事件的时候,CreateBuilderImpl.forPath传给服务端的data是CuratorFrameworkFactory的defaultData,值是localAddress(本机地址),所以provider通过AbstractConfiguratorListener收到的事件content只是客户端的ip地址。
   看起来dubbo consumer和provider的zk事件处理类是不一样的,所以AbstractConfiguratorListener应该不会导致出现zk新增动态配置无效的情况。 


-- 
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] zrlw removed a comment on issue #9239: 新增动态配置无效

Posted by GitBox <gi...@apache.org>.
zrlw removed a comment on issue #9239:
URL: https://github.com/apache/dubbo/issues/9239#issuecomment-966958950


   搭建了一套nacos测试了一下dubbo-samples集成测试涉及nacos的四个工程:dubbo-samples-nacos-conditionrouter、dubbo-samples-nacos-configcenter、dubbo-samples-nacos-override、dubbo-samples-nacos-tagrouter,这些工程都有调用nacos的ConfigService.publishConfig(dataId, group, content),跟踪发现这些工程没有调用NacosDynamicConfiguration、NacosMetadataReport的getChangeType方法,也没有调用AbstractConfiguratorListener的process方法。
   目前我测试的案例只有内置zk的provider才会用到AbstractConfiguratorListener,我没看到dubbo provider内置其他注册中心的实现方法。
   如果只是内置zk采用AbstractConfiguratorListener,那么创建节点的事件内容肯定是dubbo客户端ip,这个东西解析了也没有什么用处,没有weight等参数还是会被丢弃掉。
   我感觉这个issue貌似没有什么用,如果上述判断没有问题,两个PR应该可以关掉了。
   


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   dubbo-samples的dubbo-samples-applevel-override就能稳定重现:
   1. CuratorZookeeperClient的344行设置断点
   ```
               } else if (childData.getStat().getVersion() == 0) {
                   content = new String(childData.getData(), CHARSET);
                   eventType = EventType.NodeCreated;  <== line 344 set breakpoint here
               } else {
   ```
   2. 启动zk服务,端口2181
   3. debug启动BasicProvider, 启动参数加dubbo.port=20880
   4. debug启动BasicProvider, 启动参数加dubbo.port=20881
   5. 在ZKTools的66行设置断点:
   ```
               if (client.checkExists().forPath(path) == null) {
                   client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(path);  <== line 66 set breakpoint
               }
   ```
   6. debug执行DemoServiceIT单元测试
   7. 到达ZKTools的66行断点处之后开始单步执行,两个provider中的一个会执行到CuratorZookeeperClient的344行断点,查看content内容就会看到里面只有一个ip地址。
   


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   之前zk的CacheListener的dataChanged只设置ConfigChangeType.DELETED和ConfigChangeType.MODIFIED,ADDED类型是是 #8821 加的。
   这么做是当时发现dubbo构建有时会抛异常,比如:
   https://github.com/apache/dubbo/runs/3616815684?check_suite_focus=true
   跟踪发现zk create常常先发一个data version版本为0的通知,事件的内容只是client ip地址,这种情况作为ConfigChangeType.MODIFIED被AbstractConfiguratorListener解析时就会异常。
   


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   既然AbstractConfiguratorListener的process的目的就是解析URL,事件content如果是单个IP,也应视为URL(虽然不带参数的纯IP也没有什么用,后面的Configurator.toConfigurators方法还是会清空configurators),我重新改了一下PR,解析yaml异常就再用org.apache.dubbo.common.URL.valueOf处理一下,只要不是null就不告警了。


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   下午没能重现issue现象的原因很弱鸡,断点设置的dubbo版本和dubbo-samples使用的dubbo版本不一致,所以设置的断点都没有执行到,改成一致版本之后,就可以跟踪了。
   nacos和zk的确不一样,以dubbo-samples的dubbo-samples-nacos-override为例,启动BasicProvider时,同时有两个线程要解析服务实例的URL列表:
   1. 线程A执行RegistryProtocol的export方法:调用overrideUrlWithConfig创建ServiceConfigurationListener,通过AbstractConfiguratorListener的initWith方法,直接调用AbstractConfiguratorListener的genConfiguratorsFromRawRule解析URL列表;
   2. 线程B执行NacosDynamicConfiguration内部NacosConfigListener对象的innerReceive方法:通过AbstractConfiguratorListener的process方法(ADDED事件),调用AbstractConfiguratorListener的genConfiguratorsFromRawRule解析URL列表。
   两个线程解析的rawConfig内容相同,解析出来的URL列表存入的configurators也是同一个对象,不清楚为什么由两个不同的线程重复解析。
   
   Dubbo-admin我下载了develop当前分支,构建之后测了一下dubbo-samples-nacos-override的动态配置增、删、改,确认和述线程B执行过程相同。
   
   目前看nacos没有zk那样的单独创建node的事件,本ISSUE有两种方案:
   A. ADDED事件内容也尝试解析,解析失败后忽略;
   B. 将Nacos的ADDED改为MODIFIED事件,AbstractConfiguratorListener不解析ADDED事件的内容。
   最终采用哪一个办法还需要各位确定。
   @chickenlj @haoyann @CrazyHZM 
   


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   zk的create事件通知内容只是个ip地址,如果对应ConfigChangeType.MODIFIED,那么genConfiguratorsFromRawRule解析内容时就会异常。
   看NacosDynamicConfiguration、NacosMetadataReport代码,貌似nacos没有zk这样单独的create事件通知,可否把这两个类里的getChangeType改一下:
   ```
           private ConfigChangeType getChangeType(String configInfo, String oldValue) {
               if (StringUtils.isBlank(configInfo)) {
                   return ConfigChangeType.DELETED;
               }
               /* nacos没有单独的create事件通知
               if (StringUtils.isBlank(oldValue)) {
                   return ConfigChangeType.ADDED;
               }
               */
               return ConfigChangeType.MODIFIED;
           }
   ```


-- 
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 #9239: 新增动态配置无效

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


   在 dubbo-admin 的界面上创建一个动态配置
   nacos 接收到变更流程如下
   
   ![image](https://user-images.githubusercontent.com/43994656/141449417-6574c718-d133-4f62-8932-60a515b0c8d1.png)
   
   ![image](https://user-images.githubusercontent.com/43994656/141449508-73c7f20e-1cfb-4c66-98e3-f6bd47a1fcce.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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   下午没能重现issue现象的原因很弱鸡,断点设置的dubbo版本和dubbo-samples使用的dubbo版本不一致,所以设置的断点都没有执行到,改成一致版本之后,就可以跟踪了。
   nacos和zk的确不一样,以dubbo-samples的dubbo-samples-nacos-override为例,启动BasicProvider时,同时有两个线程要解析服务实例的URL列表:
   1. 线程A执行RegistryProtocol的export方法:调用overrideUrlWithConfig创建ServiceConfigurationListener,通过AbstractConfiguratorListener的initWith方法,直接调用AbstractConfiguratorListener的genConfiguratorsFromRawRule解析URL列表;
   2. 线程B执行NacosDynamicConfiguration内部NacosConfigListener对象的innerReceive方法:通过AbstractConfiguratorListener的process方法(ADDED事件),调用AbstractConfiguratorListener的genConfiguratorsFromRawRule解析URL列表。
   
   两个线程解析的rawConfig内容相同,解析出来的URL列表存入的configurators也是同一个对象,不清楚为什么由两个不同的线程重复解析。
   
   Dubbo-admin我下载了develop当前分支,构建之后测了一下dubbo-samples-nacos-override的动态配置增、改、删,确认和述线程B执行过程相同(事件分别为ADDED、MODIFIED、DELETED)。
   
   目前看nacos没有zk那样的单独创建node的事件,本ISSUE有两种方案:
   A. ADDED事件内容也尝试解析,解析失败后忽略;
   B. 将Nacos的ADDED改为MODIFIED事件,AbstractConfiguratorListener不解析ADDED事件的内容。
   最终采用哪一个办法还需要各位确定。
   @chickenlj @haoyann @CrazyHZM 
   


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   zk的create事件通知内容只是个ip地址,如果对应ConfigChangeType.MODIFIED,那么genConfiguratorsFromRawRule解析内容时就会异常。
   看NacosDynamicConfiguration、NacosMetadataReport代码,貌似nacos没有zk这样单独的create事件通知,可否把这两个类里的getChangeType改一下:
   ```
           private ConfigChangeType getChangeType(String configInfo, String oldValue) {
               if (StringUtils.isBlank(configInfo)) {
                   return ConfigChangeType.DELETED;
               }
               /* nacos没有单独的create事件通知
               if (StringUtils.isBlank(oldValue)) {
                   return ConfigChangeType.ADDED;
               }
               */
               return ConfigChangeType.MODIFIED;
           }
   ```


-- 
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] zrlw removed a comment on issue #9239: 新增动态配置无效

Posted by GitBox <gi...@apache.org>.
zrlw removed a comment on issue #9239:
URL: https://github.com/apache/dubbo/issues/9239#issuecomment-963990074


   zk的create事件通知内容只是个ip地址,如果对应ConfigChangeType.MODIFIED,那么genConfiguratorsFromRawRule解析内容时就会异常。
   看NacosDynamicConfiguration、NacosMetadataReport代码,貌似nacos没有zk这样单独的create事件通知,可否把这两个类里的getChangeType改一下:
   ```
           private ConfigChangeType getChangeType(String configInfo, String oldValue) {
               if (StringUtils.isBlank(configInfo)) {
                   return ConfigChangeType.DELETED;
               }
               /* nacos没有单独的create事件通知
               if (StringUtils.isBlank(oldValue)) {
                   return ConfigChangeType.ADDED;
               }
               */
               return ConfigChangeType.MODIFIED;
           }
   ```


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   改回原来的处理方式了,解析事件内容失败时的日志级别从error改为了warn,同时删掉了调用栈信息。


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   dubbo-samples的dubbo-samples-applevel-override就能稳定重现:
   1. CuratorZookeeperClient的344行设置断点
   ```
               } else if (childData.getStat().getVersion() == 0) {
                   content = new String(childData.getData(), CHARSET);
                   eventType = EventType.NodeCreated;  <== line 344 set breakpoint here
               } else {
   ```
   2. 启动zk服务,端口2181
   3. debug启动BasicProvider, 启动参数加dubbo.port=20880
   4. debug启动BasicProvider, 启动参数加dubbo.port=20881
   5. 在ZKTools的66行设置断点:
   ```
               if (client.checkExists().forPath(path) == null) {
                   client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(path);  <== line 66 set breakpoint
               }
   ```
   6. debug执行DemoServiceIT单元测试
   7. DemoServiceIT到达ZKTools的66行断点处之后开始单步执行,单步执行完66行,两个provider中的一个就会执行到CuratorZookeeperClient的344行断点,查看content内容就会看到里面只有一个ip地址。
   
   重复上述测试要先重新debug启动两个provider,再debug启动DemoServiceIT,否则到不了ZKTools的66行断点。


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   dubbo-samples的dubbo-samples-applevel-override就能稳定重现:
   1. CuratorZookeeperClient的344行设置断点
   ```
               } else if (childData.getStat().getVersion() == 0) {
                   content = new String(childData.getData(), CHARSET);
                   eventType = EventType.NodeCreated;  <== line 344 set breakpoint here
               } else {
   ```
   2. 启动zk服务,端口2181
   3. debug启动BasicProvider, 启动参数加dubbo.port=20880
   4. debug启动BasicProvider, 启动参数加dubbo.port=20881
   5. 在ZKTools的66行设置断点:
   ```
               if (client.checkExists().forPath(path) == null) {
                   client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(path);  <== line 66 set breakpoint
               }
   ```
   6. debug执行DemoServiceIT单元测试
   7. DemoServiceIT到达ZKTools的66行断点处之后开始单步执行,单步执行完66行,两个provider中都会执行到CuratorZookeeperClient的344行断点,查看content内容就会看到里面只有一个ip地址。
   
   重复上述测试要先重新debug启动两个provider,再debug启动DemoServiceIT,否则到不了ZKTools的66行断点。


-- 
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 #9239: 新增动态配置无效

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


   > @haoyann 有相关的测试案例么?
   
   使用 dubbo-admin [服务治理/动态配置] 新增一个动态配置规则。
   ![image](https://user-images.githubusercontent.com/43994656/140937846-cc026b1f-62a7-40bc-b0b6-ef5110668be8.png)
   当前 dubbo-admin 使用 `DynamicConfiguration` 新增配置
   https://github.com/apache/dubbo-admin/blob/906e87122f39527c54086db0d66fb04bcf746ba6/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/registry/config/impl/MultiDynamicConfiguration.java#L80-L82
   `dynamicConfiguration.publishConfig(key, group, value)` 对应 zookeeper 的实现就是使用的 `zkClient.create` 。
   
   而且你提到的 
   >zk的create事件通知内容只是个ip地址
   
   这里应该排查一下为什么只是一个ip地址,因为这是服务治理所监听的路径,不会无故写入内容。而且在这个场景下处理 ADDED 是符合预期的。


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   目前只有org.apache.dubbo.registry.integration.RegistryProtocol、
   org.apache.dubbo.registry.integration.RegistryDirectory、org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory三个类的内部listener类是AbstractConfiguratorListener的派生类,通过AbstractConfiguratorListener的process方法解析事件内容,获得URL列表信息。


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   搭建了一套nacos测试了一下dubbo-samples集成测试涉及nacos的四个工程:dubbo-samples-nacos-conditionrouter、dubbo-samples-nacos-configcenter、dubbo-samples-nacos-override、dubbo-samples-nacos-tagrouter,这些工程都有调用nacos的ConfigService.publishConfig(dataId, group, content),跟踪发现这些工程没有调用NacosDynamicConfiguration、NacosMetadataReport的getChangeType方法,也没有调用AbstractConfiguratorListener的process方法。
   目前我测试的案例只有内置zk的provider才会用到AbstractConfiguratorListener,我没看到dubbo provider内置其他注册中心的实现方法。
   如果只是内置zk采用AbstractConfiguratorListener,那么创建节点的事件内容肯定是dubbo客户端ip,这个东西解析了也没有什么用处,没有weight等参数还是会被丢弃掉。
   我感觉这个issue貌似没有什么用,如果上述判断没有问题,两个PR应该可以关掉了。
   


-- 
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 #9239: 新增动态配置无效

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


   


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   @haoyann 有相关的测试案例么?


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   dubbo-samples的dubbo-samples-applevel-override就能稳定重现:
   1. CuratorZookeeperClient的344行设置断点
   ```
               } else if (childData.getStat().getVersion() == 0) {
                   content = new String(childData.getData(), CHARSET);
                   eventType = EventType.NodeCreated;  <== line 344 set breakpoint here
               } else {
   ```
   2. 启动zk服务,端口2181
   3. debug启动BasicProvider, 启动参数加dubbo.port=20880
   4. debug启动BasicProvider, 启动参数加dubbo.port=20881
   5. 在ZKTools的66行设置断点:
   ```
               if (client.checkExists().forPath(path) == null) {
                   client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(path);  <== line 66 set breakpoint
               }
   ```
   6. debug执行DemoServiceIT单元测试
   7. 一直执行到DemoServiceIT到达ZKTools的66行断点处(出现CuratorZookeeperClient的344行断点时继续执行即可),之后单步执行完66行,两个provider都会再次执行到CuratorZookeeperClient的344行的断点处,此时查看两个provider的事件content内容就会看到里面都只是一个ip地址。
   
   重复上述测试要先重新debug启动两个provider,再debug启动DemoServiceIT,否则到不了ZKTools的66行断点。


-- 
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] zrlw edited a comment on issue #9239: 新增动态配置无效

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


   下午没能重现issue现象的原因很弱鸡,断点设置的dubbo版本和dubbo-samples使用的dubbo版本不一致,所以设置的断点都没有执行到,改成一致版本之后,就可以跟踪了。
   nacos和zk的确不一样,以dubbo-samples的dubbo-samples-nacos-override为例,启动BasicProvider时,同时有两个线程要解析服务实例的URL列表:
   1. 线程A执行RegistryProtocol的export方法:调用overrideUrlWithConfig创建ServiceConfigurationListener,通过AbstractConfiguratorListener的initWith方法,直接调用AbstractConfiguratorListener的genConfiguratorsFromRawRule解析URL列表;
   2. 线程B执行NacosDynamicConfiguration内部NacosConfigListener对象的innerReceive方法:通过AbstractConfiguratorListener的process方法(ADDED事件),调用AbstractConfiguratorListener的genConfiguratorsFromRawRule解析URL列表。
   两个线程解析的rawConfig内容相同,解析出来的URL列表存入的configurators也是同一个对象,不清楚为什么由两个不同的线程重复解析。
   
   Dubbo-admin我下载了develop当前分支,构建之后测了一下dubbo-samples-nacos-override的动态配置增、改、删,确认和述线程B执行过程相同(事件分别为ADDED、MODIFIED、DELETED)。
   
   目前看nacos没有zk那样的单独创建node的事件,本ISSUE有两种方案:
   A. ADDED事件内容也尝试解析,解析失败后忽略;
   B. 将Nacos的ADDED改为MODIFIED事件,AbstractConfiguratorListener不解析ADDED事件的内容。
   最终采用哪一个办法还需要各位确定。
   @chickenlj @haoyann @CrazyHZM 
   


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   dubbo-samples-applevel-override的DemoServiceIT有通过UpgradeUtil.writeXxxRule()调用ZookeeperDynamicConfiguration.publishConfig(key, group, value)方法(最终调用的是doPublishConfig方法),跟了一下这个方法触发的事件只有consumer端的MigrationRuleListener在监听,并不涉及AbstractConfiguratorListener。
   另外跟踪确认这个工程只有provider端在用AbstractConfiguratorListener监听zk事件,客户端调用zk.create并不会触发服务端的zk事件,客户端继续调用SetDataBuilderImpl.forPath方法时才会触发服务端zk事件,其中触发服务端ADDED事件的时候,provider通过AbstractConfiguratorListener收到的事件content只是客户端的ip地址。
   看起来dubbo consumer和provider的zk事件处理类是不一样的,所以我没能重现新增动态配置无效的情况。 


-- 
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] zrlw commented on issue #9239: 新增动态配置无效

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


   dubbo-samples-applevel-override集成测试代码本身应该没有问题,出问题是zk会单独抛节点创建事件(单步执行就会抛),但是多数情况下创建和后面的set设置貌似合并成了一个事件,所以dubbo-samples-applevel-override多数情况下并不会抛异常。
   我没有测nacos,不清楚nacos是否存在zk类似的情况,除了nacos,还有很多种类的注册中心,不见得都是相同的规则。
   为了兼容不同的注册中心,无论ADDED还是MODIFIED事件,还是都解析一下看看吧,解析异常时记录一行告警日志算了。


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