[Bug] issues 15271 Refactoring the bug in the registry center
- Dominant language
- Java
- Stars
- 41.6k
- Forks
- 26.4k
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 4
Description
### Pre-check
- [x] I am sure that all the content I provide is in English.
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) 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?
- [x] Yes I am willing to submit a pull request on my own!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
Contributor guide
Research direction
Start by reproducing the multiple-ZooKeeper-registry case on the dubbo 3.3 branch with one unavailable registry configured as check=false. Read Curator5ZookeeperClient#Curator5ZookeeperClient, AbstractZookeeperClient#create, Curator5ZookeeperClient#createPersistent, ListenerRegistryWrapper, and RegistryDirectory#subscribe. Done means startup no longer treats the unavailable registry as successfully connected or repeatedly fails while creating node data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100