Fix proxy crash issue when meta cache miss (#19844)

issue: #19557

/kind bug

Signed-off-by: Yuchen Gao <yuchen.gao@zilliz.com>

Signed-off-by: Yuchen Gao <yuchen.gao@zilliz.com>
This commit is contained in:
Ten Thousand Leaves 2022-10-18 13:11:26 +08:00 committed by GitHub
parent 3e11f2a700
commit db33f401fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()