diff --git a/store/driver/txn/error.go b/store/driver/txn/error.go index 2c2ef4bc60d3b..33d30d635bc7c 100644 --- a/store/driver/txn/error.go +++ b/store/driver/txn/error.go @@ -25,15 +25,23 @@ import ( "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/parser/model" "github.com/pingcap/parser/mysql" + "github.com/pingcap/tidb/errno" "github.com/pingcap/tidb/kv" tikverr "github.com/pingcap/tidb/store/tikv/error" "github.com/pingcap/tidb/store/tikv/logutil" "github.com/pingcap/tidb/table/tables" "github.com/pingcap/tidb/tablecodec" "github.com/pingcap/tidb/types" + "github.com/pingcap/tidb/util/dbterror" "go.uber.org/zap" ) +// tikv error instance +var ( + // ErrTiKVServerTimeout is the error when tikv server is timeout. + ErrTiKVServerTimeout = dbterror.ClassTiKV.NewStd(errno.ErrTiKVServerTimeout) +) + func genKeyExistsError(name string, value string, err error) error { if err != nil { logutil.BgLogger().Info("extractKeyExistsErr meets error", zap.Error(err)) @@ -176,6 +184,10 @@ func toTiDBErr(err error) error { return kv.ErrInvalidTxn } + if errors.ErrorEqual(err, tikverr.ErrTiKVServerTimeout) { + return ErrTiKVServerTimeout + } + return errors.Trace(err) } diff --git a/store/tikv/error/errcode.go b/store/tikv/error/errcode.go index e84c4577c4058..71d97e76088b8 100644 --- a/store/tikv/error/errcode.go +++ b/store/tikv/error/errcode.go @@ -26,7 +26,6 @@ const ( // TiKV/PD/TiFlash errors. CodePDServerTimeout = 9001 - CodeTiKVServerTimeout = 9002 CodeTiKVServerBusy = 9003 CodeResolveLockTimeout = 9004 CodeRegionUnavailable = 9005 diff --git a/store/tikv/error/error.go b/store/tikv/error/error.go index db5be4ebc3666..417e805f5ef3d 100644 --- a/store/tikv/error/error.go +++ b/store/tikv/error/error.go @@ -33,6 +33,8 @@ var ( ErrCannotSetNilValue = errors.New("can not set nil value") // ErrInvalidTxn is the error when commits or rollbacks in an invalid transaction. ErrInvalidTxn = errors.New("invalid transaction") + // ErrTiKVServerTimeout is the error when tikv server is timeout. + ErrTiKVServerTimeout = errors.New("tikv server timeout") ) // MismatchClusterID represents the message that the cluster ID of the PD client does not match the PD. @@ -40,7 +42,6 @@ const MismatchClusterID = "mismatch cluster id" // error instances. var ( - ErrTiKVServerTimeout = dbterror.ClassTiKV.NewStd(CodeTiKVServerTimeout) ErrTiFlashServerTimeout = dbterror.ClassTiKV.NewStd(CodeTiFlashServerTimeout) ErrResolveLockTimeout = dbterror.ClassTiKV.NewStd(CodeResolveLockTimeout) ErrPDServerTimeout = dbterror.ClassTiKV.NewStd(CodePDServerTimeout)