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


##########
config_center/zookeeper/impl.go:
##########
@@ -274,9 +343,22 @@ func (c *zookeeperDynamicConfiguration) closeConfigs() {
 }
 
 func (c *zookeeperDynamicConfiguration) RestartCallBack() bool {
+       for _, watcher := range c.cache.reset() {
+               c.removeWatcher(watcher)
+       }
+       if c.cacheListener != nil {
+               c.cacheListener.restoreBusinessWatches()
+       }
        return true
 }
 
+func (c *zookeeperDynamicConfiguration) removeWatcher(watcher *zk.Watcher) {
+       if watcher == nil || c.client == nil || c.client.Conn == nil {
+               return
+       }
+       c.client.Conn.RemoveWatcher(watcher)

Review Comment:
   [P1] 这里新增的 `RemoveWatcher` 会直接触发当前 go-zookeeper 依赖中的并发读写竞态。当前 Head 的 Unit 
Test 已在 `TestRestartCallBackResetsCache` 和 
`TestCacheListenerRemoveListenerDropsWatchAtAutoLimit` 稳定报 race:连接循环在 
`setState` 写 `Conn.state`,`RemoveWatcher -> invalidateWatcher` 同时读取该字段;另一处 
`CacheListener.removeWatcher` 也走同一路径。Base 没有任何 `RemoveWatcher` 调用,因此这是本 PR 
新增路径,当前 Unit Test 也因此失败。请先升级/修复依赖使 watcher invalidation 
使用一致的原子访问或同步,再保留主动移除逻辑,并让这两个真实 ZooKeeper `-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