apache / dubbo-go

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

我fork的main分支,这个地方panic,看看是否需要修复 #2714

Open alan2016llg opened 2 months ago

alan2016llg commented 2 months ago

Environment

Issue description

Logs

Click me to check logs ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x1cd2871] goroutine 7179829 [running]: dubbo.apache.org/dubbo-go/v3/registry/servicediscovery.(*ServiceInstancesChangedListenerImpl).OnEvent(0xc0044bb940, {0x2d07e10?, 0xc00f77e960}) /home/zmn/go/pkg/mod/github.com/alan2016llg/dubbo-go/v3@v3.1.4/registry/servicediscovery/service_instances_changed_listener_impl.go:125 +0x10d1 dubbo.apache.org/dubbo-go/v3/registry/zookeeper.(*zookeeperServiceDiscovery).DataChange(0xc000397180, {{0xc006fa2f60, 0x2b}, 0x0, {0xc007b47180, 0x32a}}) /home/zmn/go/pkg/mod/github.com/alan2016llg/dubbo-go/v3@v3.1.4/registry/zookeeper/service_discovery.go:282 +0x557 dubbo.apache.org/dubbo-go/v3/remoting/zookeeper.(*ZkEventListener).handleZkNodeEvent(0xc003732570, {0xc010254018, 0x17}, {0xc00b14c010, 0x1, 0x1?}, {0x2ce3ce0, 0xc000397180}) /home/zmn/go/pkg/mod/github.com/alan2016llg/dubbo-go/v3@v3.1.4/remoting/zookeeper/listener.go:212 +0x536 dubbo.apache.org/dubbo-go/v3/remoting/zookeeper.(*ZkEventListener).startScheduleWatchTask(0xc003732570, {0xc001d2de78, 0x17}, {0xc00b14c010, 0x1, 0x1}, 0x8bb2c97000, {0x2ce3ce0, 0xc000397180}, 0xc00415b380) /home/zmn/go/pkg/mod/github.com/alan2016llg/dubbo-go/v3@v3.1.4/remoting/zookeeper/listener.go:454 +0x5ae dubbo.apache.org/dubbo-go/v3/remoting/zookeeper.(*ZkEventListener).listenDirEvent(0xc003732570, 0x0, {0xc001d2de78, 0x17}, {0x2ce3ce0?, 0xc000397180}, {0x0, 0x0}) /home/zmn/go/pkg/mod/github.com/alan2016llg/dubbo-go/v3@v3.1.4/remoting/zookeeper/listener.go:422 +0x5b1 dubbo.apache.org/dubbo-go/v3/remoting/zookeeper.(*ZkEventListener).ListenServiceEvent.func1({0xc001d2de78, 0x17}, {0x2ce3ce0?, 0xc000397180?}) /home/zmn/go/pkg/mod/github.com/alan2016llg/dubbo-go/v3@v3.1.4/remoting/zookeeper/listener.go:480 +0xb7 created by dubbo.apache.org/dubbo-go/v3/remoting/zookeeper.(*ZkEventListener).ListenServiceEvent /home/zmn/go/pkg/mod/github.com/alan2016llg/dubbo-go/v3@v3.1.4/remoting/zookeeper/listener.go:475 +0x1be ```
FoghostCn commented 2 months ago

pls provide more information such as config file or init logic

alan2016llg commented 2 months ago

@FoghostCn 我这边是泛化调用,配置的是双注册方式,配置如下: `nacosregistryConfig := &config.RegistryConfig{ Protocol: "nacos", Address: "localhost:8848,", Timeout: "10s", Username: "nacos", Password: "nacos", Namespace: "dev_dubbo", Preferred: true, } zkegistryConfig := &config.RegistryConfig{ Protocol: "zookeeper", Address: "localhost:2181", Timeout: "10s", Preferred: false, }

method := config.MethodConfig{InterfaceName: iface, Retries: "0"}
methods := []*config.MethodConfig{&method}
refConf := config.ReferenceConfig{
    InterfaceName:  iface,
    Cluster:        "failover",
    RegistryIDs:    []string{"nacos", "zk"},
    Protocol:       protocol,
    Generic:        "true",
    Methods:        methods,
    Version:        "1.0",
    RequestTimeout: "9s",
    ProvidedBy:     "example-dubbo",
}

rootConfig := config.NewRootConfigBuilder().
    AddRegistry("nacos", nacosregistryConfig).
    AddRegistry("zk", zkegistryConfig).
    Build()
if err := config.Load(config.WithRootConfig(rootConfig)); err != nil {
    panic(err)
}
_ = refConf.Init(rootConfig)
refConf.GenericLoad("example-dubbo")`
alan2016llg commented 2 months ago

@FoghostCn image

alan2016llg commented 2 months ago

@FoghostCn 我大概知道为什么没有获取到了、在日志中发现了如下err日志:ERROR servicediscovery/service_instances_changed_listener_impl.go:256 get metadata of 192.168.50.52 failed, java exception:Server side(192.168.50.52,10324) thread pool is exhausted, detail msg:Task org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable@60590860 rejected from java.util.concurrent.ThreadPoolExecutor@479ca085[Running, pool size = 100, active threads = 100, queued tasks = 0, completed tasks = 53] ,在这种情况下,会导致没获取到,然后上层方法panic了