From b51d87d10b8770faa8fa15737efa14dcd18d35d2 Mon Sep 17 00:00:00 2001 From: "binbin.zhang" Date: Mon, 7 Aug 2023 14:29:42 +0800 Subject: [PATCH] config client cache data race (#645) * refine --- clients/config_client/config_client.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/clients/config_client/config_client.go b/clients/config_client/config_client.go index 72aa22cc..5b88d70b 100644 --- a/clients/config_client/config_client.go +++ b/clients/config_client/config_client.go @@ -438,15 +438,16 @@ func (client *ConfigClient) executeConfigListen() { } } - for _, v := range caches { - changeKey := util.GetConfigCacheKey(v.dataId, v.group, v.tenant) + for _, v := range client.cacheMap.Items() { + data := v.(cacheData) + changeKey := util.GetConfigCacheKey(data.dataId, data.group, data.tenant) if _, ok := changeKeys[changeKey]; !ok { - v.isSyncWithServer = true - client.cacheMap.Set(changeKey, v) + data.isSyncWithServer = true + client.cacheMap.Set(changeKey, data) continue } - v.isInitializing = true - client.cacheMap.Set(changeKey, v) + data.isInitializing = true + client.cacheMap.Set(changeKey, data) } }