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


##########
registry/servicediscovery/service_discovery_registry.go:
##########
@@ -129,6 +125,12 @@ func (s *serviceDiscoveryRegistry) RegisterService() error 
{
                s.lock.Unlock()
        }
 
+       if metadata.GetMetadataType() == constant.RemoteMetadataStorageType {
+               if err := s.metadataReport.PublishAppMetadata(metaInfo.App, 
metaInfo.Revision, metaInfo); err != nil {

Review Comment:
   [P1] 先发布元数据再暴露实例,或补完整回滚
   
   当前代码先 `Register` 全部实例并追加 `s.instances`,最后才调用 
`PublishAppMetadata`。消费者收到实例事件后会立即按 revision 
读取元数据;发布尚未完成时会跳过实例,且元数据发布本身不保证产生新的实例事件。更严重的是发布失败后 `RegisterService` 返回错误,但 
`Server` 只在整段成功后设置 `serviceInstanceRegistered`,rollback 
不会注销这里已经注册的实例,启动失败仍可能留下可路由实例。当前新增测试还断言发布失败后 `registerCalled == 
true`,把这个副作用固化成了期望。
   
   请先构造全部实例并计算 revision,单次发布成功后再注册;若必须后发布,则对中途注册或发布失败反向 unregister 并恢复本地状态。请补 
`ServeContext` 级发布失败、残留实例和重试去重测试。



##########
registry/servicediscovery/service_discovery_registry.go:
##########
@@ -129,6 +125,12 @@ func (s *serviceDiscoveryRegistry) RegisterService() error 
{
                s.lock.Unlock()
        }
 
+       if metadata.GetMetadataType() == constant.RemoteMetadataStorageType {

Review Comment:
   [P1] 空 exported URL 时不要进入远程发布
   
   这个分支移出 `urls` 循环后没有保留 `len(urls) > 0` 条件。纯消费者或无 provider 的 `MetadataInfo` 
可以存在且 exported URLs 为空;此时 `App`/`Revision` 可能为空,并且循环内的 `metadataReport == nil` 
检查完全没有执行,下一行会向后端写入空键或直接 nil dereference。Base 在空集合上不会发布,这是本 PR 新增的行为。
   
   请在任何 report 解引用前检查 `metadataReport`,并对 `len(urls) == 0` 直接 no-op;补纯消费者 + 
remote metadata、nil report、零发布次数和不启动空 revision timer 的测试。



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