Alanxtl commented on code in PR #3357:
URL: https://github.com/apache/dubbo-go/pull/3357#discussion_r3328838105


##########
registry/servicediscovery/service_discovery_registry.go:
##########
@@ -166,13 +166,23 @@ func (s *serviceDiscoveryRegistry) UnRegister(url 
*common.URL) error {
        if !shouldRegister(url) {
                return nil
        }
+       if id, exist := s.url.GetNonDefaultParam(constant.RegistryIdKey); exist 
{
+               metadata.RemoveService(id, url)
+               if metadataInfo := metadata.GetMetadataInfo(id); metadataInfo 
!= nil {
+                       instance := createInstance(metadataInfo, url)
+                       metadataInfo.Revision = 
instance.GetMetadata()[constant.ExportedServicesRevisionPropertyName]
+               }
+       }
        return s.UnRegisterService()
 }
 
 func (s *serviceDiscoveryRegistry) UnSubscribe(url *common.URL, listener 
registry.NotifyListener) error {
        if !shouldSubscribe(url) {
                return nil
        }
+       if id, exist := s.url.GetNonDefaultParam(constant.RegistryIdKey); exist 
{
+               metadata.RemoveSubscribeURL(id, url)
+       }

Review Comment:
   `UnRegister(url)` 现在只删当前 URL 的 metadata,但随后仍调用 bulk 的 
`UnRegisterService()`,它会遍历并注销 `s.instances` 里的所有 instance。也就是说两个 provider URL 
注册后,注销 `providerURL1` 会把 `providerURL2` 的 instance 也从 service discovery 删除,但本地 
metadata 还保留 `providerURL2`。这会造成 registry 侧和本地 metadata 状态分裂。
   
   建议要么做 targeted unregister,要么如果语义就是注销整个 app,就同步清空对应 metadata;测试里也应断言 
`mockSD.unregisterIDs` 只包含目标 URL。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to