mirror of https://github.com/milvus-io/milvus.git
Map old error code to new error (#27616)
Signed-off-by: yah01 <yah2er0ne@outlook.com>pull/27492/head
parent
11b521392e
commit
2df9908c6a
|
@ -29,7 +29,6 @@ import (
|
|||
"go.uber.org/zap"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/msgpb"
|
||||
"github.com/milvus-io/milvus/internal/datanode/allocator"
|
||||
"github.com/milvus-io/milvus/internal/proto/datapb"
|
||||
|
@ -819,22 +818,16 @@ func dropVirtualChannelFunc(dsService *dataSyncService, opts ...retry.Option) fl
|
|||
req.Segments = segments
|
||||
|
||||
err := retry.Do(context.Background(), func() error {
|
||||
rsp, err := dsService.dataCoord.DropVirtualChannel(context.Background(), req)
|
||||
resp, err := dsService.dataCoord.DropVirtualChannel(context.Background(), req)
|
||||
// should be network issue, return error and retry
|
||||
if err != nil {
|
||||
return fmt.Errorf(err.Error())
|
||||
}
|
||||
|
||||
// meta error, datanode handles a virtual channel does not belong here
|
||||
if rsp.GetStatus().GetErrorCode() == commonpb.ErrorCode_MetaFailed {
|
||||
log.Warn("meta error found, skip sync and start to drop virtual channel", zap.String("channel", dsService.vchannelName))
|
||||
err = merr.CheckRPCCall(resp, err)
|
||||
if errors.Is(err, merr.ErrChannelNotFound) {
|
||||
log.Warn("skip sync and start to drop virtual channel", zap.String("channel", dsService.vchannelName), zap.Error(err))
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// retry for other error
|
||||
if rsp.GetStatus().GetErrorCode() != commonpb.ErrorCode_Success {
|
||||
return fmt.Errorf("data service DropVirtualChannel failed, reason = %s", rsp.GetStatus().GetReason())
|
||||
}
|
||||
dsService.channel.transferNewSegments(lo.Map(startPos, func(pos *datapb.SegmentStartPosition, _ int) UniqueID {
|
||||
return pos.GetSegmentID()
|
||||
}))
|
||||
|
|
|
@ -148,6 +148,9 @@ func oldCode(code int32) commonpb.ErrorCode {
|
|||
case ErrSegmentNotFound.code():
|
||||
return commonpb.ErrorCode_SegmentNotFound
|
||||
|
||||
case ErrChannelLack.code():
|
||||
return commonpb.ErrorCode_MetaFailed
|
||||
|
||||
default:
|
||||
return commonpb.ErrorCode_UnexpectedError
|
||||
}
|
||||
|
@ -185,6 +188,9 @@ func OldCodeToMerr(code commonpb.ErrorCode) error {
|
|||
case commonpb.ErrorCode_SegmentNotFound:
|
||||
return ErrSegmentNotFound
|
||||
|
||||
case commonpb.ErrorCode_MetaFailed:
|
||||
return ErrChannelNotFound
|
||||
|
||||
default:
|
||||
return errUnexpected
|
||||
}
|
||||
|
@ -204,7 +210,7 @@ func Error(status *commonpb.Status) error {
|
|||
// use code first
|
||||
code := status.GetCode()
|
||||
if code == 0 {
|
||||
return newMilvusError(status.GetReason(), errUnexpected.errCode, false)
|
||||
return newMilvusError(status.GetReason(), Code(OldCodeToMerr(status.GetErrorCode())), false)
|
||||
}
|
||||
|
||||
return newMilvusError(status.GetReason(), code, code&retryableFlag != 0)
|
||||
|
|
Loading…
Reference in New Issue