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

动态配置添加导致注册中心provider中出现compatible_config=true,导致新的consumer无法找到provider #392

Closed
comsince opened this issue May 14, 2019 · 7 comments

Comments

@comsince
Copy link

使用dubbo admin的修改动态配置,会导致其往注册中心provider节点添加compatible_config=true
参数,导致新的consumer无法找到provider问题

@nzomkxia
Copy link
Member

@comsince 这个配置是为了在dubbo2.6和dubbo2.7之间做兼容,如果是dubbo 2.6的客户端 应该对这个配置是无感的,能提供下出错的详细场景么?

@comsince
Copy link
Author

前提

dubbo 使用的2.7.2 dubbo admin使用的是最新的从develop分支代码中编译出来的,使用zk作为注册中心

  • 在服务治理->动态配置根据service名称新建一个动态配置提交
  • 新起一个dubbo consumer,报如下错误
Exception in thread "main" java.lang.IllegalStateException: Failed to check the status of the service com.comsince.github.PushService. No provider available for the service com.comsince.github.PushService from the url zookeeper://zk:2181/org.apache.dubbo.registry.RegistryService?application=push-dubbo-consumer&dubbo=2.0.2&generic=false&interface=com.comsince.github.PushService&lazy=false&methods=pushAll,pushByTokens,pushByToken,pushByIp&pid=10315&reference.filter=test&register.ip=172.16.46.201&side=consumer&sticky=false&timeout=6000&timestamp=1557884614033 to the consumer 172.16.46.201 use dubbo version 
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:401)
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:312)
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:232)

初步发现是在OverrideServiceImpl中,如下代码中更新注册中心的provider信息,将COMPATIBLE_CONFIG加入到provider节点信息中

//for 2.6
        if (StringUtils.isNotEmpty(update.getService())) {
            List<Override> oldOverrides = convertDTOtoOldOverride(old);
            List<Override> updatedOverrides = convertDTOtoOldOverride(update);
            for (Override o : oldOverrides) {
                registry.unregister(o.toUrl().addParameter(Constants.COMPATIBLE_CONFIG, true));
            }
            for (Override o : updatedOverrides) {
                registry.register(o.toUrl().addParameter(Constants.COMPATIBLE_CONFIG, true));
            }
        }

这样在RegistryDirectory

Map<String, List<URL>> categoryUrls = urls.stream()
                .filter(Objects::nonNull)
                .filter(this::isValidCategory)
                .filter(this::isNotCompatibleFor26x)

                .collect(Collectors.groupingBy(url -> {
                    if (UrlUtils.isConfigurator(url)) {
                        return CONFIGURATORS_CATEGORY;
                    } else if (UrlUtils.isRoute(url)) {
                        return ROUTERS_CATEGORY;
                    } else if (UrlUtils.isProvider(url)) {
                        return PROVIDERS_CATEGORY;
                    }
                    return "";
                }));

//这里过滤掉过了COMPATIBLE_CONFIG_KEY 为true的provider url
private boolean isNotCompatibleFor26x(URL url) {
        return StringUtils.isEmpty(url.getParameter(Constants.COMPATIBLE_CONFIG_KEY));
    }

所以注入上面根据service名称对2.6的兼容导致2.7无法通过注册中心发送provider,不知道这个设计有没有什么问题?

@comsince
Copy link
Author

还有一个问题,新版的configurator转移到/dubbo/config/service/configurator中,在dubbo admin中增加负载均衡配置,其会在上面的节点中增加如下yaml配置

configs:
- addresses:
  - ''
  enabled: true
  parameters:
    weight: 100
  side: provider
  type: weight
- !!org.apache.dubbo.admin.model.adapter.BalancingDTO2OverrideConfigAdapter
  enabled: true
  parameters:
    loadbalance: roundrobin
  side: consumer
  type: balancing
enabled: false
key: com.comsince.github.PushService
scope: service

org.apache.dubbo.admin.model.adapter.BalancingDTO2OverrideConfigAdapter 这个类在dubbo中是没有的,会报解析错误,难道还要dubbo还要依赖这个dubbo admin这个类库?

@nzomkxia
Copy link
Member

@comsince 第一个不是设计问题,这个参数是为了兼容性设计,逻辑是对的,第二个转成yaml的时候带上类型信息是有问题的,我修改下。
需要的话可以留个联系方式交流下

@comsince
Copy link
Author

联系方式已经发到你的github指定的gmail邮箱;
第一个问题话,如果是先在dubbo-admin进行动态设置,然后启动dubbo consumer会出现无法找到provider的问题,这个就有点郁闷了

nzomkxia added a commit that referenced this issue May 15, 2019
@nzomkxia
Copy link
Member

@comsince yaml配置的问题已经修复了

@nzomkxia
Copy link
Member

@comsince compatible_config的问题也已经修复,会在dubbo 2.7.2发布 nzomkxia/incubator-dubbo@d7ceb5e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants