From db33f401fd0793f09a793f0d78938735a652ee10 Mon Sep 17 00:00:00 2001 From: Ten Thousand Leaves <69466447+soothing-rain@users.noreply.github.com> Date: Tue, 18 Oct 2022 13:11:26 +0800 Subject: [PATCH] Fix proxy crash issue when meta cache miss (#19844) issue: #19557 /kind bug Signed-off-by: Yuchen Gao Signed-off-by: Yuchen Gao --- internal/proxy/meta_cache.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/proxy/meta_cache.go b/internal/proxy/meta_cache.go index a2c0d854b6..9acf54b3bc 100644 --- a/internal/proxy/meta_cache.go +++ b/internal/proxy/meta_cache.go @@ -617,15 +617,15 @@ func (m *MetaCache) GetShards(ctx context.Context, withCache bool, collectionNam shards := parseShardLeaderList2QueryNode(resp.GetShards()) - // manipulate info in map, get map returns a copy of the information - m.mu.RLock() - info = m.collInfo[collectionName] + info, err = m.GetCollectionInfo(ctx, collectionName) + if err != nil { + return nil, fmt.Errorf("failed to get shards, collection %s not found", collectionName) + } // lock leader info.leaderMutex.Lock() oldShards := info.shardLeaders info.shardLeaders = shards info.leaderMutex.Unlock() - m.mu.RUnlock() // update refcnt in shardClientMgr ret := info.CloneShardLeaders()