From 5994b6a7b0fe9d6166f9998631f9b8404d126b74 Mon Sep 17 00:00:00 2001 From: wei liu Date: Thu, 21 Mar 2024 11:55:07 +0800 Subject: [PATCH] fix: Search doesn't expire shard leader cache (#31380) (#31450) issue: #31351 pr: #31380 This PR fixed that search doesn't expire shard leader cache when send request to query node failed, which make every request keep trying to connect a offline query node Signed-off-by: Wei Liu --- internal/proxy/task_search.go | 2 ++ internal/proxy/task_statistic.go | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/proxy/task_search.go b/internal/proxy/task_search.go index 56cf7c7a8d..47532f323d 100644 --- a/internal/proxy/task_search.go +++ b/internal/proxy/task_search.go @@ -542,10 +542,12 @@ func (t *searchTask) searchShard(ctx context.Context, nodeID int64, qn types.Que result, err = qn.Search(ctx, req) if err != nil { log.Warn("QueryNode search return error", zap.Error(err)) + globalMetaCache.DeprecateShardCache(t.request.GetDbName(), t.collectionName) return err } if result.GetStatus().GetErrorCode() == commonpb.ErrorCode_NotShardLeader { log.Warn("QueryNode is not shardLeader") + globalMetaCache.DeprecateShardCache(t.request.GetDbName(), t.collectionName) return errInvalidShardLeaders } if result.GetStatus().GetErrorCode() != commonpb.ErrorCode_Success { diff --git a/internal/proxy/task_statistic.go b/internal/proxy/task_statistic.go index ef43850693..16a2bca039 100644 --- a/internal/proxy/task_statistic.go +++ b/internal/proxy/task_statistic.go @@ -301,7 +301,6 @@ func (g *getStatisticsTask) getStatisticsShard(ctx context.Context, nodeID int64 log.Warn("QueryNode statistic result error", zap.Int64("nodeID", nodeID), zap.String("reason", result.GetStatus().GetReason())) - globalMetaCache.DeprecateShardCache(g.request.GetDbName(), g.collectionName) return fmt.Errorf("fail to get statistic, QueryNode ID=%d, reason=%s", nodeID, result.GetStatus().GetReason()) } g.resultBuf.Insert(result)