fix: [2.4] Store default value if `ErrKeyNotFound` is returned (#37691) (#37705)

Cherry-pick from master
pr: #37691
Related to #37690

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/37713/head
congqixia 2024-11-15 14:50:32 +08:00 committed by GitHub
parent 5d5f899274
commit e222289038
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -119,7 +119,11 @@ func (m *Manager) CASCachedValue(key string, origin string, value interface{}) b
m.cacheMutex.Lock()
defer m.cacheMutex.Unlock()
current, err := m.GetConfig(key)
if err != nil && !errors.Is(err, ErrKeyNotFound) {
if errors.Is(err, ErrKeyNotFound) {
m.configCache[key] = value
return true
}
if err != nil {
return false
}
if current != origin {