lizining1231 commented on PR #3663:
URL: https://github.com/apache/dubbo-go/pull/3663#issuecomment-5297313648

   CI 的-race job 报的是具有偶发性的全局 common/config.Environment.dynamicConfiguration 
字段的数据竞争,或与本改动无关。以下是初步排查与确定:
   
   ### 报错日志
   [ci-race.txt](https://github.com/user-attachments/files/31082289/ci-race.txt)
   已尝试本地难以稳定用-race复现(`-race` 单测 ×单轮/多轮、全包 `-race`、`GOMAXPROCS=2` 
组合压测均通过),竞态窗口或与时序强相关,尝试构造A/B测试成功复现。
   
   ### 问题
   CI `-race` job 报 `registry/directory` 包内**全局 
`common/config.Environment.dynamicConfiguration` 字段**的数据竞争:
   
   - **写**:测试 goroutine(goroutine 
40)`TestNewRegistryDirectoryConsumerListenerUsesResolvedApplicationName` 调用 
`SetDynamicConfiguration`(directory_test.go:195)
   - **读**:**跨测试遗留**的订阅 goroutine(goroutine 36,ID < 40)在 
`TestTypedNilCachedInvokerDoesNotPanic` 遗留的事件处理中经 `tag.PriorityRouter.Notify` 
调用 `GetDynamicConfiguration`(router.go:108)
   
   ### 原因
   
   1. **无锁全局单例字段**:environment.go:41 的 `dynamicConfiguration` 是普通字段,Set/Get 无同步
   2. **订阅 goroutine 跨测试存活**:mock_registry.go:99 起的 goroutine 阻塞在 
`listener.Next()`(无缓冲 channel)上永不退出;`Destroy` 仅置标志、不关闭 channel
   3. **测试无清理**:directory_test.go:573 的 `normalRegistryDir` 无 `t.Cleanup`
   
   ### 时序证明
   
   `09.761Z` 第 3 次 Subscribe 遗留 goroutine 处理 TEST2 事件:
   `L276 update begin → L304 selector add → L305 tag 日志`(仅 
`GetDynamicConfiguration` 返回 nil 才打印)为**同一 goroutine 的同步执行链**,即读方,其与写方测试的写交错触发 
DATA RACE


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