apache / dubbo-go

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

panic: http: multiple registrations for /triple.reflection.v1alpha.ServerReflection/ #2495

Closed chickenlj closed 10 months ago

chickenlj commented 10 months ago

Error

panic: http: multiple registrations for /triple.reflection.v1alpha.ServerReflection/

goroutine 1 [running]:
net/http.(*ServeMux).Handle(0x1400083a480, {0x14000347d10, 0x2c}, {0x10699ee40, 0x14000452940})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/server.go:2516 +0x384
dubbo.apache.org/dubbo-go/v3/protocol/triple.compatHandleService(0x1400083a480, {0x0, 0x0, 0x0})
        /Users/ken/aliware/dubbo3/golang/dubbo-go/protocol/triple/server.go:240 +0x314
dubbo.apache.org/dubbo-go/v3/protocol/triple.(*Server).RefreshService(0x1400045a9d0, {0x1069b57f8, 0x140004348d0}, 0x0)
        /Users/ken/aliware/dubbo3/golang/dubbo-go/protocol/triple/server.go:154 +0x1f8
dubbo.apache.org/dubbo-go/v3/protocol/triple.(*TripleProtocol).openServer(0x140003e4bd0, {0x1069b57f8, 0x140004348d0}, 0x0)
        /Users/ken/aliware/dubbo3/golang/dubbo-go/protocol/triple/triple.go:93 +0x164
dubbo.apache.org/dubbo-go/v3/protocol/triple.(*TripleProtocol).Export(0x140003e4bd0, {0x1069b57f8, 0x140004348d0})
        /Users/ken/aliware/dubbo3/golang/dubbo-go/protocol/triple/triple.go:70 +0x224
dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*ProtocolFilterWrapper).Export(0x14000668590, {0x1069b57f8, 0x140004348d0})
        /Users/ken/aliware/dubbo3/golang/dubbo-go/protocol/protocolwrapper/protocol_filter_wrapper.go:58 +0x108
dubbo.apache.org/dubbo-go/v3/registry/protocol.(*registryProtocol).doLocalExport(0x140004526c0, {0x1069b5980, 0x1400031e018}, 0x140001da690)
        /Users/ken/aliware/dubbo3/golang/dubbo-go/registry/protocol/protocol.go:234 +0x108
dubbo.apache.org/dubbo-go/v3/registry/protocol.(*registryProtocol).Export(0x140004526c0, {0x1069b5980, 0x1400031e018})

How to reproduce:

Run config-api/rpc/triple test in dubbo-samples project with dubbo-go feature-triple branch

FinalT commented 10 months ago

Fix this issue requires merging pr #2454 #2496

DMwangnima commented 10 months ago

The ideal way is retrieve information from URL and use it to get mapping Service from config.GetProviderConfig().Services. But URL does not store that key.

In this sample, config.GetProviderConfig().Services would be like this:

image

Since we could not modify the format of key, there would be some workarounds and solutions:

  1. Checkout Interface during iteration: It is inefficiency but we can do in this way temporarily.
  2. Add key information in URL.attributes Attributes would not be transferred outside the service so that it is okay.