Alanxtl commented on code in PR #3625:
URL: https://github.com/apache/dubbo-go/pull/3625#discussion_r3746173939
##########
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:
这个函数返回一个ok是不是更好
##########
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))
Review Comment:
改成debug等级吧
##########
registry/directory/directory.go:
##########
@@ -645,24 +649,30 @@ func (dir *RegistryDirectory)
markClosingTombstone(instanceKey string, invoker p
if invoker != nil && invoker.GetURL() != nil {
tombstone.ServiceKey = invoker.GetURL().ServiceKey()
tombstone.Address = invoker.GetURL().Location
+ tombstone.Timestamp =
invoker.GetURL().GetParam(constant.TimestampKey, "")
}
dir.closingTombstones.Store(instanceKey, tombstone)
}
func (dir *RegistryDirectory) hasActiveClosingTombstone(instanceKey string)
bool {
+ _, ok := dir.activeClosingTombstone(instanceKey)
+ return ok
+}
+
+func (dir *RegistryDirectory) activeClosingTombstone(instanceKey string)
(closingTombstone, bool) {
if instanceKey == "" {
- return false
+ return closingTombstone{}, false
}
tombstoneValue, ok := dir.closingTombstones.Load(instanceKey)
if !ok {
- return false
+ return closingTombstone{}, false
}
tombstone := tombstoneValue.(closingTombstone)
if time.Now().After(tombstone.ExpireAt) {
dir.closingTombstones.Delete(instanceKey)
- return false
+ return closingTombstone{}, false
}
- return true
+ return tombstone, true
}
Review Comment:
hasActiveClosingTombstone现在也没有调用者 而且还是个内部函数 直接删了不就行了
--
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]