alibaba / alibaba/spring-cloud-alibaba

Self check mechanism in Spring Cloud Alibaba Dubbo

Open
#1,995 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
29.2k
Forks
8.5k
Avg merge
1d 23h
Merged PRs (30d)
12

Description

我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。
We recommend using English. If you are non-native English speaker, you can use the translation software.

**Which Component**
eg. spring-cloud-starter-alibaba

**Describe what problem you have encountered**
Sometimes there were much Exception like this:
```
org.apache.dubbo.rpc.RpcException: No provider available in [invoker :interface org.apache.dubbo.rpc.service.GenericService -> spring-cloud://localhost:9090/org.apache.dubbo.registry.RegistryS
ervice?anyhost=true&application=xxx-service&bind.ip=10.0.68.162&bind.port=20887&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=true&group=xxx1-service&interf
ace=com.alibaba.cloud.dubbo.service.DubboMetadataService&lazy=false&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=3595&qos.enable=false®ister=true&
register.ip=10.0.68.162&release=2.7.3&remote.application=xxx1-service&revision=2.1.0.RELEASE&side=consumer&sticky=false&timeout=50000×tamp=1615491177605&version=1.0.0,directo
ry: org.apache.dubbo.registry.integration.RegistryDirectory@5ede64ae, invoker :interface org.apache.dubbo.rpc.service.GenericService -> zookeeper://a.b.c.d:2181/org.apache.dubbo.regi
stry.RegistryService?anyhost=true&application=xxx-service&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=true&group=xxx1-service&interface=com.alibaba.cloud.
dubbo.service.DubboMetadataService&lazy=false&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=3595&qos.enable=false®ister=true®ister.ip=10.0.68.16
2&release=2.7.3&remote.application=xxx1-service&revision=2.1.0.RELEASE&side=consumer&sticky=false&timeout=50000×tamp=1615491177605&version=1.0.0,directory: org.apache.dubbo.r
egistry.integration.RegistryDirectory@48837d47]
at org.apache.dubbo.rpc.cluster.support.RegistryAwareClusterInvoker.doInvoke(RegistryAwareClusterInvoker.java:59)
at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:248)
at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:78)
at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:55)
at org.apache.dubbo.common.bytecode.proxy96.$invoke(proxy96.java)
at com.alibaba.cloud.dubbo.service.DubboMetadataServiceInvocationHandler.invoke(DubboMetadataServiceInvocationHandler.java:49)
at com.sun.proxy.$Proxy563.getExportedURLs(Unknown Source)
at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry.getExportedURLs(AbstractSpringCloudRegistry.java:328)
at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry.subscribeDubboServiceURL(AbstractSpringCloudRegistry.java:260)
at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry$1.onApplicationEvent(AbstractSpringCloudRegistry.java:193)
at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry$1.onApplicationEvent(AbstractSpringCloudRegistry.java:186)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(Simpl
```
A clear and concise description of what you want to do.

**Describe what information you have read**
I try to solve this problem wrote before. so I read source code of spring-cloud-dubbo-starter, and this article: [Apache-Dubbo-服务自省架构设计](https://mercyblitz.github.io/2020/05/11/Apache-Dubbo-%E6%9C%8D%E5%8A%A1%E8%87%AA%E7%9C%81%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1/), wrote by @mercyblitz .

the mechanism:
1. `spring-cloud-zookeeper-discovery` will add service info in this node `/services` .
2. When using `spring-cloud-starter-dubbo`, there will be two register conter in dubbo, one is you use such as Zookeeper, another is SpringCloud, that from `com.alibaba.cloud.dubbo.registry.SpringCloudRegistry`. All of the providers and consumers will listen a different `ApplicationListener`. This logic is written in `com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry#registerServiceInstancesChangedEventListener`.
3. When `ServiceInstancesChangedEvent` were published, all listeners will call relative DubboMetadataService. It will has much call when just start.If more than one service are restarting, that will throw much Exception like mentioned above.

I have some opinions:
1. Whether it need a warn time when startup before sefl checking ?
2. There is a configuration which can close listen zookeeper's childevent, `spring.cloud.discovery.enabled`, however, this is a spring cloud configuration, if I close it, my gateway won't find that service.
3. If one interface check failed, whether other interface from that service don't need check? Or provide a backoff strategy.
4. When adding a listener, I think it can just add consumer interface listener, because the provider is itself.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry#registerServiceInstancesChangedEventListener and trace the getExportedURLs and subscribeDubboServiceURL calls mentioned in the stack trace. Read the linked Apache Dubbo service introspection article and compare the startup listener behavior with the reported failures. Done requires an agreed self-check mechanism and its behavior for startup timing, failed interfaces, and listener scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.