From 8a9a42198d75388a5eeba33c7d38ec242420ca22 Mon Sep 17 00:00:00 2001 From: wei liu Date: Sat, 11 May 2024 14:32:12 +0800 Subject: [PATCH] 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 --- internal/proxy/meta_cache.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/proxy/meta_cache.go b/internal/proxy/meta_cache.go index bf3c1a48d6..b9514091de 100644 --- a/internal/proxy/meta_cache.go +++ b/internal/proxy/meta_cache.go @@ -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 {