Map old error code to new error (#27616)

Signed-off-by: yah01 <yah2er0ne@outlook.com>
pull/27492/head
yah01 2023-10-11 12:43:33 +08:00 committed by GitHub
parent 11b521392e
commit 2df9908c6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View File

@ -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()
}))

View File

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