dubbo-go icon indicating copy to clipboard operation
dubbo-go copied to clipboard

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

Open keithlovingcats opened this issue 3 years ago • 11 comments

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/[email protected]/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/[email protected]/remoting/exchange_client.go:86 dubbo.apache.org/dubbo-go/v3/remoting.NewExchangeClient /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/config/reference_config.go:197 dubbo.apache.org/dubbo-go/v3/config.(*ConsumerConfig).Load /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/[email protected]/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/[email protected]/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/[email protected]/config/root_config.go:201 dubbo.apache.org/dubbo-go/v3/config.(*RootConfig).Init /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/[email protected]/config/root_config.go:196 dubbo.apache.org/dubbo-go/v3/config.Load /Users/huangjun/go/pkg/mod/dubbo.apache.org/dubbo-go/[email protected]/config/config_loader.go:57

keithlovingcats avatar Aug 04 '22 06:08 keithlovingcats

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

AlexStocks avatar Aug 04 '22 06:08 AlexStocks

有可以复现的代码吗

zhaoyunxing92 avatar Aug 05 '22 01:08 zhaoyunxing92

有可以复现的代码吗

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

keithlovingcats avatar Aug 05 '22 05:08 keithlovingcats

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.

Mulavar avatar Aug 08 '22 03:08 Mulavar

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

keithlovingcats avatar Aug 08 '22 03:08 keithlovingcats

@bobhttp

zhaoyunxing92 avatar Aug 12 '22 13:08 zhaoyunxing92

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

AlexStocks avatar Sep 23 '22 13:09 AlexStocks

这个问题有进展吗

keithlovingcats avatar Oct 13 '22 03:10 keithlovingcats

这个问题有进展吗

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

AlexStocks avatar Oct 13 '22 03:10 AlexStocks

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

keithlovingcats avatar Oct 14 '22 10:10 keithlovingcats

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

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

AlexStocks avatar Oct 14 '22 11:10 AlexStocks