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

Same address cannot distinguish different registry center

Open lanux opened this issue 2 years ago • 1 comments

Environment

  • Server: Dubbo-go, v3.0.5
  • Client: Dubbo-go, v3.0.5
  • Protocol: dubbo
  • Registry: Nacos, v1

Issue description

Nacos registry,Different namespaces represent different registry eg. developtestproduct

http://122.32.33.4:6801/nacos?namespace=develop http://122.32.33.4:6801/nacos?namespace=test http://122.32.33.4:6801/nacos?namespace=product

registryUrl.PrimitiveURL all equals "registry://122.32.33.4:6801" When the method getRegistry is called, it returns the same registry every time

func (proto *registryProtocol) getRegistry(registryUrl *common.URL) registry.Registry {
	var err error
	reg, loaded := proto.registries.Load(registryUrl.PrimitiveURL)
	if !loaded {
		reg, err = extension.GetRegistry(registryUrl.Protocol, registryUrl)
		if err != nil {
			logger.Errorf("Registry can not connect success, program is going to panic.Error message is %s", err.Error())
			panic(err)
		}
		proto.registries.Store(registryUrl.PrimitiveURL, reg)
	}
	return reg.(registry.Registry)
}

Logs

Click me to check logs
Copy logs to here.

lanux avatar Nov 27 '23 01:11 lanux

I think we should consider to have some parameters like namespace included in the mapping key.

chickenlj avatar Dec 07 '23 04:12 chickenlj