AlexStocks commented on code in PR #3623:
URL: https://github.com/apache/dubbo-go/pull/3623#discussion_r3749854679


##########
registry/servicediscovery/service_discovery_registry.go:
##########
@@ -514,11 +514,10 @@ func (s *serviceDiscoveryRegistry) Subscribe(url 
*common.URL, notify registry.No
                        " either specify 'provided-by' for reference or enable 
metadata-report center subscription url:%s", url.String())
        } else {
                logger.Infof("[Registry][ServiceDiscovery] find initial mapping 
applications %q for service %s", services, url.ServiceKey())
-               // first notify
-               err := 
mappingListener.OnEvent(registry.NewServiceMappingChangedEvent(url.ServiceKey(),
 services))
-               if err != nil {
-                       logger.Errorf("[Registry][ServiceDiscovery] 
ServiceInstancesChangedListenerImpl handle error, err=%v", err)
-               }
+               // Subscribe the initial applications directly. The mapping 
listener tracks
+               // changes after the initial subscription; routing this event 
through it
+               // makes provided-by look like an unchanged mapping and skips 
SubscribeURL.
+               s.SubscribeURL(url, notify, services)

Review Comment:
   [P1] 已用公开入口确认这个基线缺失会产生实际重复注册:metadata report 初始返回 `test-app` 并完成第一次 listener 
安装后,向保存的 mapping listener 重放完全相同的集合,底层 `ServiceDiscovery.AddListener` 从期望的 1 
次变为 2 次,日志也出现两次订阅。建议仅让 `provided-by` 路径直接 `SubscribeURL`;metadata-report 路径继续经 
`OnEvent` 完成订阅并在 mutex 下更新 baseline,或提供等价的同步初始化方法。回归测试应覆盖 A→A 仍为一次、A→A+B 只新增一次。



-- 
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