milvus/pkg/config
congqixia 62bd51ec6d
fix: [2.4] Compare config value then swap when caching param value (#33785) (#33797)
Cherry-pick from master
pr: #33785
See also #33784

This PR change the behavior of `SetCacheValue` of config manager:

- Use mutex and map instead of concurrent map for `configCache`
- Compare config raw value before set cache value

With this implementation, concurrent caching & eviction shall always
have current output:

|time|caching |eviction|config   |cached   |
|----|--------|------- |---------|---------|
|t0  |get     |        |old value|null     |
|t1  |CAS OK  |        |old value|old value|
|t2  |        |update  |new value|old value|
|t3  |        |eviction|new value|null     |

|time|caching |eviction|config   |cached   |
|----|--------|------- |---------|---------|
|t0  |get     |        |old value|null     |
|t1  |        |update  |new value|null     |
|t2  |CAS fail|        |old value|null     |
|t3  |        |eviction|new value|null     |

|time|caching |eviction|config   |cached   |
|----|--------|------- |---------|---------|
|t0  |        |update  |new value|null     |
|t1  |get     |        |new value|null     |
|t2  |CAS OK  |        |new value|new value|
|t3  |        |eviction|new value|null     |

|time|caching |eviction|config   |cached   |
|----|--------|------- |---------|---------|
|t0  |        |update  |new value|null     |
|t1  |get     |        |new value|null     |
|t2  |        |eviction|new value|null     |
|t3  |CAS OK  |        |new value|new value|

|time|caching |eviction|config   |cached   |
|----|--------|------- |---------|---------|
|t0  |        |update  |new value|null     |
|t1  |        |eviction|new value|null     |
|t2  |get     |        |new value|null     |
|t3  |CAS OK  |        |new value|new value|

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
2024-06-13 17:51:57 +08:00
..
config_test.go Check error by Error() and NoError() for better report message (#24736) 2023-06-08 15:36:36 +08:00
config.go enhance: Cache formatted key for param item (#31388) 2024-03-19 14:05:05 +08:00
env_source.go fix: paramtable cache cause dynamic config non-dynamic (#33473) (#33590) 2024-06-05 10:15:51 +08:00
etcd_source_test.go fix: use atomic.Pointer to store EventHandler in case of data race (#30205) 2024-01-23 19:09:04 +08:00
etcd_source.go fix: [2.4] Compare config value then swap when caching param value (#33785) (#33797) 2024-06-13 17:51:57 +08:00
event_dispatcher_test.go enhance: Add unittest for config.EventDispatcher (#28552) 2023-11-18 19:12:20 +08:00
event_dispatcher.go enhance: support clean paramtable config event in test (#30534) 2024-02-20 14:16:51 +08:00
event.go Format the code (#27275) 2023-09-21 09:45:27 +08:00
file_source.go fix: [2.4] Compare config value then swap when caching param value (#33785) (#33797) 2024-06-13 17:51:57 +08:00
manager_test.go fix: [2.4] Compare config value then swap when caching param value (#33785) (#33797) 2024-06-13 17:51:57 +08:00
manager.go fix: [2.4] Compare config value then swap when caching param value (#33785) (#33797) 2024-06-13 17:51:57 +08:00
refresher.go enhance: adjust config source for support config event use paramtable (#29995) 2024-01-26 19:07:00 +08:00
source_test.go Format the code (#27275) 2023-09-21 09:45:27 +08:00
source.go fix: paramtable cache cause dynamic config non-dynamic (#33473) (#33590) 2024-06-05 10:15:51 +08:00