saleson opened a new issue, #9964:
URL: https://github.com/apache/dubbo/issues/9964
### Environment
* Dubbo version: 3.0.7
* Java version: 1.8
### Steps to reproduce this issue
场景:
consumer 的service-discovery.migration设置为APPLICATION_FIRST (默认),
provider同时存在接口级注册的实例和实例级注册的实例
(比如dubbo2升3),此时访问正常;但如果将实例级注册的实例全部下线后,即使仍存在接口级注册的实例,这时将会出现两个问题:
1、RPC调用报No provider
2、NettyClient会一直尝试重连
原因:
经过代码跟踪,发现是ServiceDiscoveryRegistryDirectory.refreshInvoker()方法中有两段保护逻辑:
`java
// 1
if (CollectionUtils.isEmpty(invokerUrls)) {
logger.warn("Received empty url list, will ignore for
protection purpose.");
return;
}
//2
if (CollectionUtils.isEmptyMap(newUrlInvokerMap)) {
logger.error(new IllegalStateException("Cannot create
invokers from url address list (total " + invokerUrls.size() + ")"));
return;
}
`
如果收到空的url列表,出现保护目的将会忽略。这会导致已经下线的实例,不会被释放连接,而是不断重连;且在MigrationInvoker中调用ServiceDiscoveryRegistryDirectory.isEmpty()返回false,
仍会采用serviceDiscoveryInvoker进行RPC调用,但连接失败,报No provider.
Pls. provide [GitHub address] to reproduce this issue.
If there is an exception, please attach the exception trace:
[24/04/22 21:00:47:593 CST] main WARN cluster.RouterChain: [DUBBO] No
provider available after route for the service
org.apache.dubbo.springboot.demo.DemoService from registry 192.168.1.7 on the
consumer 192.168.1.7 using the dubbo version 3.0.8-SNAPSHOT. Router snapshot is
below:
[ Parent (Input: 0) (Current Node Output: 0) (Chain Node Output: 0) ] Input:
Empty -> Chain Node Output: Empty
[ MockInvokersSelector (Input: 0) (Current Node Output: 0) (Chain Node
Output: 0) Router message: Empty invokers. Directly return. ] Current Node
Output: Empty, dubbo version: 3.0.8-SNAPSHOT, current host: 192.168.1.7
[24/04/22 21:00:47:593 CST] main WARN directory.AbstractDirectory: [DUBBO]
No provider available after connectivity filter for the service
org.apache.dubbo.springboot.demo.DemoService All validInvokers' size: 0 All
routed invokers' size: 0 All invokers' size: 1 from registry 127.0.0.1:2181 on
the consumer 192.168.1.7 using the dubbo version 3.0.8-SNAPSHOT., dubbo
version: 3.0.8-SNAPSHOT, current host: 192.168.1.7
Exception in thread "main" org.apache.dubbo.rpc.RpcException: Failed to
invoke the method sayHello in the service
org.apache.dubbo.springboot.demo.DemoService. No provider available for the
service org.apache.dubbo.springboot.demo.DemoService from registry
127.0.0.1:2181 on the consumer 192.168.1.7 using the dubbo version
3.0.8-SNAPSHOT. Please check if the providers have been started and registered.
at
org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.checkInvokers(AbstractClusterInvoker.java:366)
at
org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:73)
at
org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:340)
at
org.apache.dubbo.rpc.cluster.router.RouterSnapshotFilter.invoke(RouterSnapshotFilter.java:46)
at
org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:321)
at
org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:99)
at
org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:321)
at
org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:51)
at
org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:321)
at
org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter.invoke(ConsumerContextFilter.java:110)
at
org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:321)
at
org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:193)
at
org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$ClusterFilterInvoker.invoke(AbstractCluster.java:92)
at
org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:97)
at
org.apache.dubbo.registry.client.migration.MigrationInvoker.invoke(MigrationInvoker.java:280)
at
org.apache.dubbo.rpc.proxy.InvocationUtil.invoke(InvocationUtil.java:57)
at
org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:73)
at
org.apache.dubbo.springboot.demo.DemoServiceDubboProxy1.sayHello(DemoServiceDubboProxy1.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205)
at com.sun.proxy.$Proxy54.sayHello(Unknown Source)
at
org.apache.dubbo.springboot.demo.consumer.ConsumerApplication.doSayHello(ConsumerApplication.java:51)
at
org.apache.dubbo.springboot.demo.consumer.ConsumerApplication.main(ConsumerApplication.java:45)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]