apache / apache/dubbo

multiple-service-discovery not work as expected

Open
#7,366 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

- [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
- [x] I have checked the [FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: 2.7.10-SNAPSHOT/master
* Operating System version: ANY
* Java version: 8

### Steps to reproduce this issue

服务提供者与消费者使用multiple协议的按节点发现的注册中心
```




```

**问题1**:提供者启动时报错
```
java.net.UnknownHostException: multiple:0.0.0.0
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:607)
at org.apache.dubbo.config.ServiceConfig.findConfigedHosts(ServiceConfig.java:589)
at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:446)
at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:328)
at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:303)
at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:204)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$exportServices$14(DubboBootstrap.java:1094)
at java.util.HashMap$Values.forEach(HashMap.java:981)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1081)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:895)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:62)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:55)
```

**问题2**:先启动提供者、再启动消费者,服务调用正常。停止提供者,消费者定期打印错误日志
```
org.apache.dubbo.remoting.RemotingException: client(url: DefaultServiceInstance{id='192.168.3.6:20881', serviceName='demo-provider-A', host='192.168.3.6', port=20881, enabled=true, healthy=true, metadata={dubbo.metadata-service.url-params={"dubbo":{"version":"1.0.0","dubbo":"2.0.2","port":"20880"}}, dubbo.endpoints=[{"port":20881,"protocol":"dubbo"}], dubbo.metadata.revision=E5DE9EA37771ECEEDEEFAD292D1C9FBA, dubbo.metadata.storage-type=remote}}metadata{app='demo-provider-A',revision='E5DE9EA37771ECEEDEEFAD292D1C9FBA',services={demo-provider-A/org.apache.dubbo.metadata.MetadataService:1.0.0:dubbo=service{name='org.apache.dubbo.metadata.MetadataService',group='demo-provider-A',version='1.0.0',protocol='dubbo',params={deprecated=false, dubbo=2.0.2, version=1.0.0, group=demo-provider-A},consumerParams=null}, org.apache.dubbo.demo.DemoServiceA:dubbo=service{name='org.apache.dubbo.demo.DemoServiceA',group='null',version='null',protocol='dubbo',params={deprecated=false, dubbo=2.0.2, timeout=3000},consumerParams={init=false, side=consumer, register.ip=192.168.3.6, methods=sayHello, provided-by=demo-provider-A, dubbo=2.0.2, pid=19298, check=false, interface=org.apache.dubbo.demo.DemoServiceA, qos.enable=false, metadata-type=remote, application=demo-consumer, sticky=false, timestamp=1615344197219}}}}) failed to connect to server /192.168.3.6:20881, error message is:Connection refused: /192.168.3.6:20881
at org.apache.dubbo.remoting.transport.netty4.NettyClient.doConnect(NettyClient.java:169)
at org.apache.dubbo.remoting.transport.AbstractClient.connect(AbstractClient.java:198)
at org.apache.dubbo.remoting.transport.AbstractClient.reconnect(AbstractClient.java:254)
at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeClient.reconnect(HeaderExchangeClient.java:166)
at org.apache.dubbo.remoting.exchange.support.header.ReconnectTimerTask.doTask(ReconnectTimerTask.java:49)
at org.apache.dubbo.remoting.exchange.support.header.AbstractTimerTask.run(AbstractTimerTask.java:87)
at org.apache.dubbo.common.timer.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:648)
at org.apache.dubbo.common.timer.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:727)
at org.apache.dubbo.common.timer.HashedWheelTimer$Worker.run(HashedWheelTimer.java:449)
at java.lang.Thread.run(Thread.java:748)
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /192.168.3.6:20881
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
```

问题3:从当个一个注册中心手工删除instance的ip,消费者调用服务报错NoProvider,这不符合multiple的设计预期。
```
Exception in thread "main" org.apache.dubbo.rpc.RpcException: No provider available from registry multiple:0.0.0.0:9090 for service org.apache.dubbo.demo.DemoServiceA on consumer 192.168.3.6 use dubbo version , please check status of providers(disabled, not registered or in blacklist).
at org.apache.dubbo.registry.integration.DynamicDirectory.doList(DynamicDirectory.java:165)
at org.apache.dubbo.rpc.cluster.directory.AbstractDirectory.list(AbstractDirectory.java:95)
at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.list(AbstractClusterInvoker.java:297)
at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:262)
at org.apache.dubbo.rpc.cluster.interceptor.ClusterInterceptor.intercept(ClusterInterceptor.java:47)
at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$InterceptorInvokerNode.invoke(AbstractCluster.java:92)
at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:93)
at org.apache.dubbo.registry.client.migration.ServiceDiscoveryMigrationInvoker.invoke(ServiceDiscoveryMigrationInvoker.java:59)
at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:95)
at org.apache.dubbo.common.bytecode.proxy0.sayHello(proxy0.java)
at org.apache.dubbo.demo.consumer.Consumer.main(Consumer.java:45)
```

示例demo:https://github.com/70-cloud-lab/dubbo-issues/tree/main/210310-multiple-service-discovery-bug

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.