AsperforMias commented on code in PR #3625:
URL: https://github.com/apache/dubbo-go/pull/3625#discussion_r3746282370
##########
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:
然后要改的话,相对应的,require.NoError 断言这边也要一起改
--
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]