store/tikv: make tikv.ErrTiKV* as normal errors instead of dberror (#24396)

This commit is contained in:
Shirly
2021-05-06 12:09:52 +08:00
committed by GitHub
parent 337beb1f89
commit 0d4e66ee8d
3 changed files with 26 additions and 13 deletions

View File

@ -39,8 +39,12 @@ import (
// tikv error instance
var (
// ErrTiKVServerTimeout is the error when tikv server is timeout.
ErrTiKVServerTimeout = dbterror.ClassTiKV.NewStd(errno.ErrTiKVServerTimeout)
ErrResolveLockTimeout = dbterror.ClassTiKV.NewStd(errno.ErrResolveLockTimeout)
ErrTiKVServerTimeout = dbterror.ClassTiKV.NewStd(errno.ErrTiKVServerTimeout)
// ErrTiKVStaleCommand is the error that the command is stale in tikv.
ErrTiKVStaleCommand = dbterror.ClassTiKV.NewStd(errno.ErrTiKVStaleCommand)
// ErrTiKVMaxTimestampNotSynced is the error that tikv's max timestamp is not synced.
ErrTiKVMaxTimestampNotSynced = dbterror.ClassTiKV.NewStd(errno.ErrTiKVMaxTimestampNotSynced)
ErrResolveLockTimeout = dbterror.ClassTiKV.NewStd(errno.ErrResolveLockTimeout)
)
func genKeyExistsError(name string, value string, err error) error {
@ -189,6 +193,14 @@ func toTiDBErr(err error) error {
return ErrTiKVServerTimeout
}
if errors.ErrorEqual(err, tikverr.ErrTiKVStaleCommand) {
return ErrTiKVStaleCommand
}
if errors.ErrorEqual(err, tikverr.ErrTiKVMaxTimestampNotSynced) {
return ErrTiKVMaxTimestampNotSynced
}
if errors.ErrorEqual(err, tikverr.ErrResolveLockTimeout) {
return ErrResolveLockTimeout
}

View File

@ -32,8 +32,6 @@ const (
CodeTiKVStoreLimit = 9008
CodeTiKVStaleCommand = 9010
CodeTiKVMaxTimestampNotSynced = 9011
CodeTiFlashServerTimeout = 9012
CodeTiFlashServerBusy = 9013
CodeTiFlashServerTimeout = 9012
CodeTiFlashServerBusy = 9013
)

View File

@ -35,6 +35,10 @@ var (
ErrInvalidTxn = errors.New("invalid transaction")
// ErrTiKVServerTimeout is the error when tikv server is timeout.
ErrTiKVServerTimeout = errors.New("tikv server timeout")
// ErrTiKVStaleCommand is the error that the command is stale in tikv.
ErrTiKVStaleCommand = errors.New("tikv stale command")
// ErrTiKVMaxTimestampNotSynced is the error that tikv's max timestamp is not synced.
ErrTiKVMaxTimestampNotSynced = errors.New("tikv max timestamp not synced")
// ErrResolveLockTimeout is the error that resolve lock timeout.
ErrResolveLockTimeout = errors.New("resolve lock timeout")
)
@ -44,13 +48,12 @@ const MismatchClusterID = "mismatch cluster id"
// error instances.
var (
ErrTiFlashServerTimeout = dbterror.ClassTiKV.NewStd(CodeTiFlashServerTimeout)
ErrPDServerTimeout = dbterror.ClassTiKV.NewStd(CodePDServerTimeout)
ErrRegionUnavailable = dbterror.ClassTiKV.NewStd(CodeRegionUnavailable)
ErrTiKVServerBusy = dbterror.ClassTiKV.NewStd(CodeTiKVServerBusy)
ErrTiFlashServerBusy = dbterror.ClassTiKV.NewStd(CodeTiFlashServerBusy)
ErrTiKVStaleCommand = dbterror.ClassTiKV.NewStd(CodeTiKVStaleCommand)
ErrTiKVMaxTimestampNotSynced = dbterror.ClassTiKV.NewStd(CodeTiKVMaxTimestampNotSynced)
ErrTiFlashServerTimeout = dbterror.ClassTiKV.NewStd(CodeTiFlashServerTimeout)
ErrPDServerTimeout = dbterror.ClassTiKV.NewStd(CodePDServerTimeout)
ErrRegionUnavailable = dbterror.ClassTiKV.NewStd(CodeRegionUnavailable)
ErrTiKVServerBusy = dbterror.ClassTiKV.NewStd(CodeTiKVServerBusy)
ErrTiFlashServerBusy = dbterror.ClassTiKV.NewStd(CodeTiFlashServerBusy)
ErrGCTooEarly = dbterror.ClassTiKV.NewStd(CodeGCTooEarly)
ErrQueryInterrupted = dbterror.ClassTiKV.NewStd(CodeQueryInterrupted)
ErrLockAcquireFailAndNoWaitSet = dbterror.ClassTiKV.NewStd(CodeLockAcquireFailAndNoWaitSet)