dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

[Feature] Service Discovery support local cache when registry is unavailable

Open AlbumenJ opened this issue 1 year ago • 22 comments

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

AlbumenJ avatar Mar 08 '24 02:03 AlbumenJ

What scenarios need this feature? In general, the registry sdk already supports local cache.

finefuture avatar Mar 08 '24 09:03 finefuture

What scenarios need this feature? In general, the registry sdk already supports local cache.

  1. zookeeper not support
  2. 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.

AlbumenJ avatar Mar 10 '24 03:03 AlbumenJ

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.

FAWC438 avatar Mar 11 '24 09:03 FAWC438

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.

  1. We have no completion time limitation
  2. For code quality, we have add a lot of checkers in Github Actions and we will check it when pull request reviewing

AlbumenJ avatar Mar 12 '24 09:03 AlbumenJ

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.

FAWC438 avatar Mar 13 '24 10:03 FAWC438

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.

AlbumenJ avatar Mar 13 '24 11:03 AlbumenJ

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.

walkinggo avatar Apr 30 '24 22:04 walkinggo

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

walkinggo avatar May 27 '24 08:05 walkinggo

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

AlbumenJ avatar May 28 '24 02:05 AlbumenJ

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?

walkinggo avatar May 29 '24 05:05 walkinggo

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.

AlbumenJ avatar May 30 '24 10:05 AlbumenJ

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.

walkinggo avatar Jun 02 '24 14:06 walkinggo

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.

Yep, you're right. BTW, we should make sure Dubbo will try to reconnect the broken registry continuously.

AlbumenJ avatar Jun 03 '24 02:06 AlbumenJ

If Dubbo cannot reconnect to the broken registry, this may be another problem. should open another issue

HeyAlaia avatar Aug 12 '24 07:08 HeyAlaia