[Feature] Service Discovery support local cache when registry is unavailable
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 and found no similar feature requirement.
Apache Dubbo Component
Java SDK (apache/dubbo)
Descriptions
Service Discovery support local cache when registry is unavailable
Related issues
No response
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
- [X] I agree to follow this project's Code of Conduct
What scenarios need this feature? In general, the registry sdk already supports local cache.
What scenarios need this feature? In general, the registry sdk already supports local cache.
- zookeeper not support
- Nacos's local cache is not useful for Dubbo. Nacos will use local cache by highest priority, but Dubbo only want it as the fallback.
Hi, I am new to Dubbo community and willing to complete this task.
Is there any restriction on this issue? For example, in terms of completion time and code quality.
Hi, I am new to Dubbo community and willing to complete this task.
Is there any restriction on this issue? For example, in terms of completion time and code quality.
- We have no completion time limitation
- For code quality, we have add a lot of checkers in Github Actions and we will check it when pull request reviewing
Hi @AlbumenJ, I checked the relevant code and documentation, and I think the "local cache" mentioned in this issue actually refers to the consumer caching information such as the provider's ip:port obtained from the registry that is not down. Is that correct?
I did see the local caching function of metadata in the code, but as far as I know from reading the documentation, the metadata link maintained by Dubbo does not actually require the participation of the Service Discovery registry(Nacos or Zookeeper etc.), so does the work of this issue actually have nothing to do with metadata ?
And, regarding the implementation of local cache, since you mentioned that it will be used as a fallback solution, I think it only needs to be implemented in memory (for example, through a Map ) without the need to store it in the disk (like Nacos) , because it is a small probability event after all.
And, regarding the implementation of local cache, since you mentioned that it will be used as a fallback solution, I think it only needs to be implemented in memory (for example, through a
Map) without the need to store it in the disk (like Nacos) , because it is a small probability event after all.
The main purpose is to save in the disk. To prevent if registry crashed Dubbo cannot start.
And, regarding the implementation of local cache, since you mentioned that it will be used as a fallback solution, I think it only needs to be implemented in memory (for example, through a
Map) without the need to store it in the disk (like Nacos) , because it is a small probability event after all.The main purpose is to save in the disk. To prevent if registry crashed Dubbo cannot start.
Indeed, you can use serialization interfaces to save information on the local disk. However, if users tamper with the files storing this information, it can lead to data security issues. Unauthorized changes might corrupt the data, introduce errors, or cause security vulnerabilities if sensitive data is exposed or manipulated.
Hey, I want to help too, can you provide more detailed information? For example, what is the local specific information storage location and storage form. @AlbumenJ
Hey, I want to help too, can you provide more detailed information? For example, what is the local specific information storage location and storage form. @AlbumenJ
You can check the related example in org.apache.dubbo.registry.support.AbstractRegistry
Firstly,we should make the zookeeper support the local cache.Secondly,we should make the nacos implements the fallback.It's the all the tasks need to finish in this issue?
Firstly,we should make the zookeeper support the local cache.Secondly,we should make the nacos implements the fallback.It's the all the tasks need to finish in this issue?
We can make it more common and not depend on the specific registry.
I test it, and i find out that dubbo cannot work if registry is down.I can check it is true when registry is zookeeper or nacos.And also,i can see the org.apache.dubbo.registry.support.AbstractRegistry will store the local cache when localCacheEnabled is true.I think the way to finish it is read the local cache when the registry cannot be connected.
I test it, and i find out that dubbo cannot work if registry is down.I can check it is true when registry is zookeeper or nacos.And also,i can see the
org.apache.dubbo.registry.support.AbstractRegistrywill store the local cache whenlocalCacheEnabledis true.I think the way to finish it is read the local cache when the registry cannot be connected.
Yep, you're right. BTW, we should make sure Dubbo will try to reconnect the broken registry continuously.
If Dubbo cannot reconnect to the broken registry, this may be another problem. should open another issue