diff --git a/internal/proxy/meta_cache.go b/internal/proxy/meta_cache.go index 134d799d8bc7c..27d265ad215e2 100644 --- a/internal/proxy/meta_cache.go +++ b/internal/proxy/meta_cache.go @@ -1036,7 +1036,7 @@ func (m *MetaCache) DeprecateShardCache(database, collectionName string) { if ok { delete(dbInfo, collectionName) if len(dbInfo) == 0 { - delete(dbInfo, database) + delete(m.collInfo, database) } } } @@ -1072,7 +1072,7 @@ func (m *MetaCache) InvalidateShardLeaderCache(collections []int64) { } } if len(dbInfo) == 0 { - delete(dbInfo, dbName) + delete(m.collLeader, dbName) } } } diff --git a/internal/proxy/shard_client.go b/internal/proxy/shard_client.go index d72e001b2d724..9f0fbe7b78d13 100644 --- a/internal/proxy/shard_client.go +++ b/internal/proxy/shard_client.go @@ -229,12 +229,12 @@ func (c *shardClientMgrImpl) PurgeClient() { return case <-ticker.C: shardLocations := globalMetaCache.ListShardLocation() - for nodeID := range c.clients.data { + c.clients.Lock() + defer c.clients.Unlock() + for nodeID, client := range c.clients.data { if _, ok := shardLocations[nodeID]; !ok { - c.clients.Lock() + client.Release() delete(c.clients.data, nodeID) - c.clients.Unlock() - c.ReleaseClient(nodeID) } } }