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


##########
metadata/metadata.go:
##########
@@ -34,27 +39,37 @@ func GetMetadataService() MetadataService {
 }
 
 func GetMetadataInfo(registryId string) *info.MetadataInfo {
+       registryMetadataLock.RLock()
+       defer registryMetadataLock.RUnlock()
        return registryMetadataInfo[registryId]
 }
 
 func AddService(registryId string, url *common.URL) {
+       registryMetadataLock.Lock()

Review Comment:
   [P1] 这里仍然裸读 registryMetadataInfo。这个 PR 让 
AddService/AddSubscribeURL/GetMetadataInfo 通过 registryMetadataLock 保护同一个全局 
map,但 RemoveService/RemoveSubscribeURL 还在没有 RLock 的情况下做 map 
lookup;当服务导出/订阅与注销并发发生时,Add 分支可能正在写入 registryMetadataInfo,Remove 分支同时读会继续触发 
concurrent map read/write。这里需要先在 registryMetadataLock 下取出 
metadataInfo,再释放全局锁后调用 metadataInfo.RemoveService,和 AddService 的锁粒度保持一致。



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