From a71516530692cff2547efb9a28824d5bcf0c24a9 Mon Sep 17 00:00:00 2001 From: yah01 Date: Sun, 8 Oct 2023 16:55:31 +0800 Subject: [PATCH] Set timeout for leader observer syncing (#27504) Signed-off-by: yah01 --- internal/querycoordv2/observers/leader_observer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/querycoordv2/observers/leader_observer.go b/internal/querycoordv2/observers/leader_observer.go index e51f892217..09da5c9a40 100644 --- a/internal/querycoordv2/observers/leader_observer.go +++ b/internal/querycoordv2/observers/leader_observer.go @@ -31,6 +31,7 @@ import ( "github.com/milvus-io/milvus/internal/querycoordv2/utils" "github.com/milvus-io/milvus/pkg/log" "github.com/milvus-io/milvus/pkg/util/commonpbutil" + "github.com/milvus-io/milvus/pkg/util/paramtable" ) const ( @@ -281,6 +282,8 @@ func (o *LeaderObserver) sync(ctx context.Context, replicaID int64, leaderView * }, Version: time.Now().UnixNano(), } + ctx, cancel := context.WithTimeout(ctx, paramtable.Get().QueryCoordCfg.SegmentTaskTimeout.GetAsDuration(time.Millisecond)) + defer cancel() resp, err := o.cluster.SyncDistribution(ctx, leaderView.ID, req) if err != nil { log.Warn("failed to sync distribution", zap.Error(err))