From 85aa92974979da77ccb1fddbaf0953def93a55a6 Mon Sep 17 00:00:00 2001 From: "cai.zhang" Date: Fri, 28 Jun 2024 14:18:06 +0800 Subject: [PATCH] enhance: Set the timeout for SyncSegments based on the number of segments (#34228) issue: #32809 master pr: #34226 Signed-off-by: Cai Zhang --- internal/datacoord/session_manager.go | 5 +++-- pkg/util/paramtable/component_param.go | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/datacoord/session_manager.go b/internal/datacoord/session_manager.go index 0c4f93ba2a..deeb2947ea 100644 --- a/internal/datacoord/session_manager.go +++ b/internal/datacoord/session_manager.go @@ -217,7 +217,8 @@ func (c *SessionManagerImpl) SyncSegments(nodeID int64, req *datapb.SyncSegments zap.Int64("nodeID", nodeID), zap.Int64("planID", req.GetPlanID()), ) - ctx, cancel := context.WithTimeout(context.Background(), Params.DataCoordCfg.CompactionRPCTimeout.GetAsDuration(time.Second)) + timeout := Params.DataCoordCfg.CompactionRPCTimeout.GetAsDuration(time.Second) * time.Duration(max(len(req.GetSegmentInfos())/10, 1)) + ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() cli, err := c.getClient(ctx, nodeID) if err != nil { @@ -226,7 +227,7 @@ func (c *SessionManagerImpl) SyncSegments(nodeID int64, req *datapb.SyncSegments } err = retry.Do(context.Background(), func() error { - ctx, cancel := context.WithTimeout(context.Background(), Params.DataCoordCfg.CompactionRPCTimeout.GetAsDuration(time.Second)) + ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() resp, err := cli.SyncSegments(ctx, req) diff --git a/pkg/util/paramtable/component_param.go b/pkg/util/paramtable/component_param.go index 3208dec4c8..eaa90c589c 100644 --- a/pkg/util/paramtable/component_param.go +++ b/pkg/util/paramtable/component_param.go @@ -3148,10 +3148,10 @@ During compaction, the size of segment # of rows is able to exceed segment max # p.ChannelCheckpointMaxLag.Init(base.mgr) p.SyncSegmentsInterval = ParamItem{ - Key: "dataCoord.sync.interval", - Version: "2.4.3", + Key: "dataCoord.syncSegmentsInterval", + Version: "2.4.6", Doc: "The time interval for regularly syncing segments", - DefaultValue: "600", // 10 * 60 seconds + DefaultValue: "300", // 5 * 60 seconds } p.SyncSegmentsInterval.Init(base.mgr)