ywxzm03 commented on PR #3612: URL: https://github.com/apache/dubbo-go/pull/3612#issuecomment-5365899178
> > > > > > 执行`make test-race`时,`TestCacheListenerRemoveListenerDropsWatchAtAutoLimit`和`TestRestartCallBackResetsCache`发生了数据竞争;原因是单测中执行到`defer cluster.Stop()`时,停止 ZooKeeper 服务端,接着`Conn.loop`检测到网络断开,触发的`setState`与`removeWatcher()`中的`invalidateWatcher()`存在并发访问窗口,发生了state的读写竞争(前者是原子写,但后者却是普通读);由于后来reviewer提出要引入zk服务端依赖,这个数据竞争问题得以才暴露出来; > > > > > > 若要解决这个问题,可以在dubbogo/go-zookeeper中将`invalidateWatcher`的state读取改为已有的原子读取`State()`即可,是否需要我去`dubbogo/go-zookeeper`那提个pr改一下这个小问题? > > > > > > > > > > > > > > > 提一下吧 > > > > > > > > > > > > fixed;已在go-zookeeper侧,将invalidateWatcher改为原子读:[dubbogo/go-zookeeper#12](https://github.com/dubbogo/go-zookeeper/pull/12) > > > > > > > > > 我发新tag了 go-zookeeper/v1.0.5 你更新到新版本吧 > > > > > > 更新到1.0.5后,本地跑make test-race,gost编译失败: > > ``` > > undefined: zk.TestCluster > > undefined: zk.StartTestCluster > > undefined: zk.WithRetryTimes > > ``` > > > > > > > > > > > > > > > > > > > > > > > > 原因是更新后的zk将部分测试api搬到了_test.go(WithRetryTimes是直接被删除了),所以这些api不会被编译到普通依赖包,而gost还用的之前的api,编译失败;如果要修这个,又要去gost那边将`TestCluster`、`StartTestCluster`、`WithRetryTimes` 由 `go-zookeeper` 转移到 `gost` 自己维护,我再去提个pr? > > ok 去 gost 也提一个pr吧 gost已经将TestCluster、StartTestCluster、WithRetryTimes转移到本地维护了:https://github.com/dubbogo/gost/pull/145 但在这之后,我尝试dubbogo依赖本地gost,重新跑了一遍make test-race,但etcd服务没连上导致测试超时,测试fail;原因是gost之前移除了grpc.WithBlock(),grpc.DialContext 不等待 Ready直接返回,超时没覆盖到后续Grant;所以我在另一个pr(https://github.com/dubbogo/gost/pull/146)中,在keepSession中,用独立的短超时 context发起首次Grant,且保留了gost删除WithBlock()的行为 -- 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]
