Add dataservice state check (#5687)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/5779/head
congqixia 2021-06-09 15:02:48 +08:00 committed by zhenshan.cao
parent 1727edb5d3
commit c172af78bd
1 changed files with 16 additions and 0 deletions

View File

@ -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 {