Skip to content

Commit

Permalink
Accelerate flush in flushAll (#26769)
Browse files Browse the repository at this point in the history
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
  • Loading branch information
bigsheeper authored Sep 1, 2023
1 parent e8f1b17 commit 64cf5ea
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions internal/proxy/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3172,14 +3172,11 @@ func (node *Proxy) FlushAll(ctx context.Context, _ *milvuspb.FlushAllRequest) (*

hasError := func(status *commonpb.Status, err error) bool {
if err != nil {
resp.Status = &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: err.Error(),
}
resp.Status = merr.Status(err)
log.Warn("FlushAll failed", zap.String("err", err.Error()))
return true
}
if status.ErrorCode != commonpb.ErrorCode_Success {
if status != nil && status.ErrorCode != commonpb.ErrorCode_Success {
log.Warn("FlushAll failed", zap.String("err", status.GetReason()))
resp.Status = status
return true
Expand All @@ -3204,12 +3201,26 @@ func (node *Proxy) FlushAll(ctx context.Context, _ *milvuspb.FlushAllRequest) (*
return resp, nil
}

flushRsp, err := node.Flush(ctx, &milvuspb.FlushRequest{
Base: commonpbutil.NewMsgBase(commonpbutil.WithMsgType(commonpb.MsgType_Flush)),
DbName: dbName,
CollectionNames: showColRsp.GetCollectionNames(),
})
if hasError(flushRsp.GetStatus(), err) {
group, ctx := errgroup.WithContext(ctx)
for _, collection := range showColRsp.GetCollectionNames() {
collection := collection
group.Go(func() error {
flushRsp, err := node.Flush(ctx, &milvuspb.FlushRequest{
Base: commonpbutil.NewMsgBase(commonpbutil.WithMsgType(commonpb.MsgType_Flush)),
DbName: dbName,
CollectionNames: []string{collection},
})
if err != nil {
return err
}
if flushRsp.GetStatus().GetErrorCode() != commonpb.ErrorCode_Success {
return merr.Error(flushRsp.GetStatus())
}
return nil
})
}
err = group.Wait()
if hasError(nil, err) {
return resp, nil
}
}
Expand Down

0 comments on commit 64cf5ea

Please sign in to comment.