From c172af78bd05a6305cbeb7c65583172133facc26 Mon Sep 17 00:00:00 2001 From: congqixia Date: Wed, 9 Jun 2021 15:02:48 +0800 Subject: [PATCH] Add dataservice state check (#5687) Signed-off-by: Congqi Xia --- internal/dataservice/grpc_services.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/dataservice/grpc_services.go b/internal/dataservice/grpc_services.go index 839df860b..13b2700fd 100644 --- a/internal/dataservice/grpc_services.go +++ b/internal/dataservice/grpc_services.go @@ -194,6 +194,10 @@ func (s *Server) GetInsertBinlogPaths(ctx context.Context, req *datapb.GetInsert ErrorCode: commonpb.ErrorCode_UnexpectedError, }, } + if s.isClosed() { + resp.Status.Reason = "server is initializing" + return resp, nil + } p := path.Join(Params.SegmentBinlogSubPath, strconv.FormatInt(req.SegmentID, 10)) + "/" // prefix/id/ instead of prefix/id _, values, err := s.kvClient.LoadWithPrefix(p) if err != nil { @@ -237,6 +241,10 @@ func (s *Server) GetCollectionStatistics(ctx context.Context, req *datapb.GetCol ErrorCode: commonpb.ErrorCode_UnexpectedError, }, } + if s.isClosed() { + resp.Status.Reason = "server is initializing" + return resp, nil + } nums, err := s.meta.GetNumRowsOfCollection(req.CollectionID) if err != nil { resp.Status.Reason = err.Error() @@ -253,6 +261,10 @@ func (s *Server) GetPartitionStatistics(ctx context.Context, req *datapb.GetPart ErrorCode: commonpb.ErrorCode_UnexpectedError, }, } + if s.isClosed() { + resp.Status.Reason = "server is initializing" + return resp, nil + } nums, err := s.meta.GetNumRowsOfPartition(req.CollectionID, req.PartitionID) if err != nil { resp.Status.Reason = err.Error() @@ -380,6 +392,10 @@ func (s *Server) GetRecoveryInfo(ctx context.Context, req *datapb.GetRecoveryInf ErrorCode: commonpb.ErrorCode_UnexpectedError, }, } + if s.isClosed() { + resp.Status.Reason = "server is initializing" + return resp, nil + } segmentIDs := s.meta.GetSegmentsOfPartition(collectionID, partitionID) segment2Binlogs := make(map[UniqueID][]*datapb.FieldBinlog) for _, id := range segmentIDs { -- GitLab