xiaobaicai66695 commented on code in PR #3601:
URL: https://github.com/apache/dubbo-go/pull/3601#discussion_r3734467423
##########
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:
@AlexStocks @Alanxtl
已完成工作,新增测试TestCacheManagerGetAllReturnsAtomicSnapshotDuringReplacement
<img width="1115" height="182" alt="image"
src="https://github.com/user-attachments/assets/28b0a416-8408-433e-872d-477c626553f9"
/>
这是没有删除GetAll()外层锁的测试结果
将GetAll()的锁注释以后,20轮测试均出现报错 map[string]interface {}{}
<img width="660" height="215" alt="image"
src="https://github.com/user-attachments/assets/3ffa8d62-d85a-43b6-844c-391c69ba48ad"
/>
<img width="1525" height="938" alt="image"
src="https://github.com/user-attachments/assets/26d36ba8-c474-4828-ab93-c97204903860"
/>
--
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]