From 4586bcef9fd602347190df1371f0ed3a7646d565 Mon Sep 17 00:00:00 2001 From: zhagnlu <1542303831@qq.com> Date: Wed, 17 Apr 2024 01:20:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20correct=20AssignSegmentID=20return=20and?= =?UTF-8?q?=20add=20retry=20for=20loadCollectionF=E2=80=A6=20(#32335)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #32322 #31942 Signed-off-by: luzhang Co-authored-by: luzhang --- internal/datacoord/handler.go | 17 +++++++++++++---- internal/datacoord/services.go | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/internal/datacoord/handler.go b/internal/datacoord/handler.go index aebebfab4c..e5d2b1b530 100644 --- a/internal/datacoord/handler.go +++ b/internal/datacoord/handler.go @@ -394,10 +394,19 @@ func (h *ServerHandler) GetCollection(ctx context.Context, collectionID UniqueID if coll != nil { return coll, nil } - err := h.s.loadCollectionFromRootCoord(ctx, collectionID) - if err != nil { - log.Warn("failed to load collection from rootcoord", zap.Int64("collectionID", collectionID), zap.Error(err)) - return nil, err + ctx2, cancel := context.WithTimeout(ctx, time.Second*10) + defer cancel() + if err := retry.Do(ctx2, func() error { + err := h.s.loadCollectionFromRootCoord(ctx, collectionID) + if err != nil { + log.Warn("failed to load collection from rootcoord", zap.Int64("collectionID", collectionID), zap.Error(err)) + return err + } + return nil + }, retry.Attempts(5)); err != nil { + log.Ctx(ctx2).Warn("datacoord ServerHandler GetCollection finally failed", + zap.Int64("collectionID", collectionID), + zap.Error(err)) } return h.s.meta.GetCollection(collectionID), nil diff --git a/internal/datacoord/services.go b/internal/datacoord/services.go index 74305fc50c..94474a6d89 100644 --- a/internal/datacoord/services.go +++ b/internal/datacoord/services.go @@ -194,7 +194,7 @@ func (s *Server) AssignSegmentID(ctx context.Context, req *datapb.AssignSegmentI r.CollectionID, r.PartitionID, r.ChannelName, int64(r.Count)) if err != nil { log.Warn("failed to alloc segment", zap.Any("request", r), zap.Error(err)) - continue + return nil, err } log.Info("success to assign segments", zap.Int64("collectionID", r.GetCollectionID()), zap.Any("assignments", segmentAllocations))