Skip to content

Commit

Permalink
store/tikv: make tikv.ErrTiKVServerTimeout as a normal error (#24367)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMouche authored Apr 30, 2021
1 parent c5ca2ea commit c506155
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions store/driver/txn/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -176,6 +184,10 @@ func toTiDBErr(err error) error {
return kv.ErrInvalidTxn
}

if errors.ErrorEqual(err, tikverr.ErrTiKVServerTimeout) {
return ErrTiKVServerTimeout
}

return errors.Trace(err)
}

Expand Down
1 change: 0 additions & 1 deletion store/tikv/error/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const (

// TiKV/PD/TiFlash errors.
CodePDServerTimeout = 9001
CodeTiKVServerTimeout = 9002
CodeTiKVServerBusy = 9003
CodeResolveLockTimeout = 9004
CodeRegionUnavailable = 9005
Expand Down
3 changes: 2 additions & 1 deletion store/tikv/error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ 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.
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)
Expand Down

0 comments on commit c506155

Please sign in to comment.