diff --git a/pkg/utils/grpcutil/grpcutil.go b/pkg/utils/grpcutil/grpcutil.go index 9823adf2cfbe..4d2f250d53e0 100644 --- a/pkg/utils/grpcutil/grpcutil.go +++ b/pkg/utils/grpcutil/grpcutil.go @@ -252,10 +252,7 @@ func CheckStream(ctx context.Context, cancel context.CancelFunc, done chan struc // NeedRebuildConnection checks if the error is a connection error. func NeedRebuildConnection(err error) bool { - if err == nil { - return false - } - return err == io.EOF || + return err != nil && err == io.EOF || strings.Contains(err.Error(), codes.Unavailable.String()) || // Unavailable indicates the service is currently unavailable. This is a most likely a transient condition. strings.Contains(err.Error(), codes.DeadlineExceeded.String()) || // DeadlineExceeded means operation expired before completion. strings.Contains(err.Error(), codes.Internal.String()) || // Internal errors. diff --git a/server/forward.go b/server/forward.go index bfb2893ca3ae..3f0ae0485449 100644 --- a/server/forward.go +++ b/server/forward.go @@ -159,7 +159,7 @@ func (s *GrpcServer) forwardTSO(stream pdpb.PD_TsoServer) error { tsopbResp, err := s.forwardTSORequestWithDeadLine(forwardCtx, cancelForward, forwardStream, request, tsDeadlineCh) if err != nil { tsoStreamErr = errors.WithStack(err) - return errors.WithStack(err) + return tsoStreamErr } // The error types defined for tsopb and pdpb are different, so we need to convert them.