Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix dynamic update config doesn't works for some param (#35572) #35637

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions pkg/config/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,15 @@ func (m *Manager) CASCachedValue(key string, origin string, value interface{}) b
func (m *Manager) EvictCachedValue(key string) {
m.cacheMutex.Lock()
defer m.cacheMutex.Unlock()
delete(m.configCache, key)
// cause param'value may rely on other params, so we need to evict all the cached value when config is changed
clear(m.configCache)
}

func (m *Manager) EvictCacheValueByFormat(keys ...string) {
m.cacheMutex.Lock()
defer m.cacheMutex.Unlock()

set := typeutil.NewSet(keys...)
for key := range m.configCache {
if set.Contain(formatKey(key)) {
delete(m.configCache, key)
}
}
// cause param'value may rely on other params, so we need to evict all the cached value when config is changed
clear(m.configCache)
}

func (m *Manager) GetConfig(key string) (string, error) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/util/paramtable/component_param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,12 @@ func TestCachedParam(t *testing.T) {

assert.Equal(t, 1*time.Hour, params.DataCoordCfg.GCInterval.GetAsDuration(time.Second))
assert.Equal(t, 1*time.Hour, params.DataCoordCfg.GCInterval.GetAsDuration(time.Second))

params.Save(params.QuotaConfig.DiskQuota.Key, "192")
assert.Equal(t, float64(192*1024*1024), params.QuotaConfig.DiskQuota.GetAsFloat())
assert.Equal(t, float64(192*1024*1024), params.QuotaConfig.DiskQuotaPerCollection.GetAsFloat())
params.Save(params.QuotaConfig.DiskQuota.Key, "256")
assert.Equal(t, float64(256*1024*1024), params.QuotaConfig.DiskQuota.GetAsFloat())
assert.Equal(t, float64(256*1024*1024), params.QuotaConfig.DiskQuotaPerCollection.GetAsFloat())
params.Save(params.QuotaConfig.DiskQuota.Key, "192")
}
Loading