fix: Proxy crash due to shard leader cache data race (#32971)

issue: #32970
cause InvalidateShardLeaderCache use wrong lock, which may cause data
race in meta cache, then proxy may crash

This PR fixed that use leaderMut when try to access shard leader cache.

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
pull/32818/head^2
wei liu 2024-05-11 14:32:12 +08:00 committed by GitHub
parent 36f1ea93a5
commit 8a9a42198d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -1002,8 +1002,8 @@ func (m *MetaCache) DeprecateShardCache(database, collectionName string) {
func (m *MetaCache) InvalidateShardLeaderCache(collections []int64) {
log.Info("Invalidate shard cache for collections", zap.Int64s("collectionIDs", collections))
m.mu.RLock()
defer m.mu.RUnlock()
m.leaderMut.Lock()
defer m.leaderMut.Unlock()
collectionSet := typeutil.NewUniqueSet(collections...)
for _, db := range m.collLeader {