AsperforMias commented on code in PR #3625:
URL: https://github.com/apache/dubbo-go/pull/3625#discussion_r3746278286
##########
registry/servicediscovery/service_instances_changed_listener_impl.go:
##########
@@ -91,19 +105,40 @@ func (lstn *ServiceInstancesChangedListenerImpl) OnEvent(e
observer.Event) error
return nil
}
- lstn.mutex.Lock()
- defer lstn.mutex.Unlock()
+ logger.Infof("[Registry][ServiceDiscovery] received instance
notification event, service=%s size=%d", ce.ServiceName, len(ce.Instances))
+ lstn.mutex.Lock()
lstn.allInstances[ce.ServiceName] = ce.Instances
- revisionToInstances := make(map[string][]registry.ServiceInstance,
len(lstn.revisionToMetadata))
- newRevisionToMetadata := make(map[string]*info.MetadataInfo,
len(lstn.revisionToMetadata))
+ lstn.mutex.Unlock()
+
+ lstn.refreshServiceURLs()
+ return nil
+}
+
+// refreshServiceURLs rebuilds service URLs from the latest instance snapshot
and
+// notifies subscribers. The build is serialized by buildMu, but lstn.mutex is
+// only held while reading or committing in-memory state: metadata RPCs run in
+// between without it, so a slow or unreachable provider cannot block event
+// processing or retry scheduling.
+func (lstn *ServiceInstancesChangedListenerImpl) refreshServiceURLs() {
Review Comment:
这里有个问题,因为实际上,`refreshServiceURLs()` 不返回任何东西,也就是内部算出"哪些 revision 的 metadata
没解析出来",自己存状态、自己调度重试。那这里返回的ok 要用于让 OnEvent 返回 err,这也意味着要改变 OnEvent 原有契约(之前
metadata 失败是"跳过该实例但不报错",现在加重试了)
--
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]