AlexStocks commented on code in PR #3601:
URL: https://github.com/apache/dubbo-go/pull/3601#discussion_r3733604647
##########
registry/servicediscovery/store/cache_manager_test.go:
##########
@@ -150,3 +154,125 @@ func TestMetaInfoCacheManager(t *testing.T) {
cm2.destroy()
cm.destroy() // clear cache file
}
+
+func TestCacheManagerConcurrentAccess(t *testing.T) {
+ cacheFile := filepath.Join(t.TempDir(), "race_cache")
+ cm, err := NewCacheManager("raceTest", cacheFile, time.Millisecond, 32,
true)
+ if err != nil {
+ t.Fatalf("failed to create cache manager: %v", err)
+ }
+ defer cm.destroy()
+
+ runConcurrentCacheAccess(cm)
Review Comment:
[P1] 用可判别场景证明 GetAll 的原子快照
当前并发测试只检查 dump 可解码且非空;由于底层 lru.Cache 的单次操作本身有锁、getAllLocked 又会跳过消失键,我删除
GetAll 的外层锁后,这两个新增测试以 -race -count=20 仍全部通过。容量 1 探针能稳定暴露问题:Set 原子地用 b 替换 a
时真实缓存从不为空,但 unlocked GetAll 会在 Keys 与 Get 之间返回空 map,当前 Head 连续通过而 mutant
连续失败。建议把该场景或等价同步 seam 纳入正式测试,确保删除外层锁时测试必然失败。
--
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]