Skip to content

[Bug] issues 15271 Refactoring the bug in the registry center #16186

@fu-cheng1

Description

@fu-cheng1

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

dubbo 3.3 branch. jdk 11

Steps to reproduce this issue

Configure multiple ZooKeeper registries, with one service not started and configured as check=false

What you expected to happen

There is an issue with this approach. When multiple ZooKeeper registries are configured and one of them has check=false, the logic in org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperClient#Curator5ZookeeperClient was changed from the original behavior of closing the connection when !connected to closing it only when check && !connected. As a result, the subsequent workflow incorrectly assumes that the connection has been successfully established and continues writing node data to that connection.

A typical example is node creation in org.apache.dubbo.remoting.zookeeper.curator5.AbstractZookeeperClient#create. Each recursive attempt to create the node fails, which prolongs the application startup time. Eventually, an exception is thrown in org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperClient#createPersistent(java.lang.String, boolean), causing the application startup to fail.

Anything else

I want to solve this issue, I'm willing to submit a PR. Could you provide me with some ideas on how to approach this problem?
My approach is to add a registry != null check to all methods in org.apache.dubbo.registry.ListenerRegistryWrapper, while also passing in the original URL object. When org.apache.dubbo.registry.ListenerRegistryWrapper#getUrl is invoked, if registry == null, it should return the original URL directly. In this way, when the following code is executed in org.apache.dubbo.registry.integration.RegistryDirectory#subscribe:
registry.getUrl()
.getParameter(
RegistryConstants.REGISTRY_CLUSTER_KEY,
registry.getUrl().getParameter(PROTOCOL_KEY));
it will no longer trigger a NullPointerException.

Do you have a (mini) reproduction demo?

  • Yes, I have a minimal reproduction demo to help resolve this issue more effectively!

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedEverything needs help from contributors

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions