apache / dubbo-go

Go Implementation For Apache Dubbo .
https://dubbo.apache.org/
Apache License 2.0
4.73k stars 929 forks source link

consumer 使用 url 时,启动若无法连接服务,会直接panic #2006

Open huangjun0124 opened 2 years ago

huangjun0124 commented 2 years ago

dubbo.yaml 中按照如下配置 consumer,check设置为了false,但是启动时会因为无法连接url服务而直接panic。 java 项目就没有这个问题。

consumer:
        request-timeout: 20s
        check: false
        filter: "cshutdown" #common-filter,
        references:
            SampleService:
                check: false
                registry-ids:
                    - localzk
                Retries: "1"
                protocol: "dubbo"
                interface: "com.demo.SampleService"
                url: "dubbo://com.demo.sampleservice:20008"

错误信息如下: 2022-08-04T14:31:06.937+0800 ERROR getty/getty_client.go:167 try to connect server com.demo.sampleservice:20008 failed for : failed to create client connection to com.demo.sampleservice:20008 in 3s dubbo.apache.org/dubbo-go/v3/remoting/getty.(*Client).Connect /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/remoting/getty/getty_client.go:167 dubbo.apache.org/dubbo-go/v3/remoting.(*ExchangeClient).doInit /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/remoting/exchange_client.go:86 dubbo.apache.org/dubbo-go/v3/remoting.NewExchangeClient /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/remoting/exchange_client.go:74 dubbo.apache.org/dubbo-go/v3/protocol/dubbo.getExchangeClient.func1 /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/protocol/dubbo/dubbo_protocol.go:200 dubbo.apache.org/dubbo-go/v3/protocol/dubbo.getExchangeClient /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/protocol/dubbo/dubbo_protocol.go:208 dubbo.apache.org/dubbo-go/v3/protocol/dubbo.(*DubboProtocol).Refer /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/protocol/dubbo/dubbo_protocol.go:91 dubbo.apache.org/dubbo-go/v3/config.(*ReferenceConfig).Refer /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/config/reference_config.go:197 dubbo.apache.org/dubbo-go/v3/config.(*ConsumerConfig).Load /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/config/consumer_config.go:130 dubbo.apache.org/dubbo-go/v3/config.(*RootConfig).Start.func1 /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/config/root_config.go:203 sync.(*Once).doSlow /usr/local/go/src/sync/once.go:68 sync.(*Once).Do /usr/local/go/src/sync/once.go:59 dubbo.apache.org/dubbo-go/v3/config.(*RootConfig).Start /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/config/root_config.go:201 dubbo.apache.org/dubbo-go/v3/config.(*RootConfig).Init /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/config/root_config.go:196 dubbo.apache.org/dubbo-go/v3/config.Load /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.2/config/config_loader.go:57

AlexStocks commented 2 years ago

would you check the root cause of this panic and then fix the bug?

zhaoyunxing92 commented 2 years ago

有可以复现的代码吗

huangjun0124 commented 2 years ago

有可以复现的代码吗

用go语言做consumer的就能复现吧,只要url配置的服务,在启动的时候无法访问就会panic

Mulavar commented 2 years ago

please refer to https://github.com/apache/dubbo-go/blob/1d6b35ff267c0eb668cddc95d98248d491723d56/config/reference_config.go#L150. this param is used to specify the registry or the provider address like tri://127.0.0.1:20000. you can try replacing com.demo.sampleservice with the IP address of the provider.

huangjun0124 commented 2 years ago

actually the thing is that we are using istio to match dubbo service, this url param is set like this because we designed to have a service named this. now the service is not yet started when dubbogo starts, so it directly panic. we can prevent this error by starting the provider first, then consumer starts ok. but, this will depend on service schedule sequence which is not really acceptable in practive. besides, if we have two service depends on each other(consumer for each other), this two will never be able to start due to startup panic by setting dubbogo url this way. The java version of dubbo works fine in this situation

zhaoyunxing92 commented 2 years ago

@bobhttp

AlexStocks commented 2 years ago

bob: 现象可以复现,不影响直连使用,但是错误内容不清晰,对用户使用不友好。

huangjun0124 commented 2 years ago

这个问题有进展吗

AlexStocks commented 2 years ago

这个问题有进展吗

我们评估了,觉得这不是个 bug。

huangjun0124 commented 2 years ago

但是panic会导致整个程序无法启动。依赖的服务没有启起来的情况下,自己也无法启动,这不合理吧

AlexStocks commented 2 years ago

但是panic会导致整个程序无法启动。依赖的服务没有启起来的情况下,自己也无法启动,这不合理吧

晚上9点dubbogo周会,到时候我会把会议连接发到 dubbogo 社区钉钉群 23331795,你晚上如果有空的话来参加下。