Skip to content

使用域名指向注册中心集群导致的单点问题 #2545

Closed

Description

@356082462
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.6.2
  • 域名解析示例:
    10.0.0.1 zk.foo.com
    10.0.0.2 zk.foo.com
    10.0.0.3 zk.foo.com
    10.0.0.4 zk.foo.com
    10.0.0.5 zk.foo.com
  • 注册中心:zookeeper

在生产环境中要求只能使用域名,注册中心的域名解析如示例中所示,Dubbo框架在创建注册中心时,会对域名进行解析,且只取其中一个IP,这会导致每次解析获得的IP有可能不一样,有可能出现如下问题:
1、解析获取到不一样的IP的时候,会再次创建一个注册中心实例,导致和注册中心建立多个连接。
2、如果始终解析到的是一个IP,如果该注册中心节点不可以,zookeeper客户端也没有可重试的IP,那么会导致应用与注册中心的会话失效,导致临时服务节点被删除。
下面是获取注册中心Key的代码:
https://github.com/apache/incubator-dubbo/blob/e6b0bc8a856abd7f2d7a2e0f06ccc78dc90e2e0a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java#L88
就是在该方法中将域名解析成单一的IP,是否可以考虑将该实现换成不解析域名的方法:
https://github.com/apache/incubator-dubbo/blob/7a48fac84b14ac6a21c1bdfc5958705dd8dda84d/dubbo-compatible/src/main/java/com/alibaba/dubbo/common/URL.java#L498-L500
将域名解析的任务交给zookeeper客户端完成,zookeeper客户端默认会将域名解析成IP列表。

Activity

  1. zonghaishang commented on Sep 26, 2018

    @zonghaishang
    Member

    @356082462

    Dubbo does not resolve the registry address is a good suggestion,delayed address (such as zookeeper) parsing, also pay attention to the limitations of dns cache, but jvm provides parameter control

  2. zonghaishang commented on Sep 26, 2018

    @zonghaishang
    Member

    Would you like to submit pr to fix this problem?

  3. 356082462 commented on Sep 26, 2018

    @356082462
    ContributorAuthor

    @zonghaishang
    好的,我已经提交了代码。关于JVM会缓存DNS解析记录,你是想提醒我一方面要保护DNS,另一方面是希望注册中心客户端进入重试逻辑时不会对DNS服务器形成强依赖是吗?

  4. added a commit that references this issue on Jul 23, 2019
    c8facc5
  5. added a commit that references this issue on Sep 10, 2019
    116c9c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions