driver: convert ErrQueryInterrupted to actual error types (#50517)
ref pingcap/tidb#49643
This commit is contained in:
12
DEPS.bzl
12
DEPS.bzl
@ -7028,13 +7028,13 @@ def go_deps():
|
||||
name = "com_github_tikv_client_go_v2",
|
||||
build_file_proto_mode = "disable_global",
|
||||
importpath = "github.com/tikv/client-go/v2",
|
||||
sha256 = "11c26ac74edc44bad623ac96676af6015ebcc06da5495b4240f4f830238bf4eb",
|
||||
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20240125030910-e6f5a45b002e",
|
||||
sha256 = "964bc4f42d34e5ef7ec6b273e56ec568733b00855b93eb3a5abc8cecd228debc",
|
||||
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20240202121323-8b3b01e8d770",
|
||||
urls = [
|
||||
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240125030910-e6f5a45b002e.zip",
|
||||
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240125030910-e6f5a45b002e.zip",
|
||||
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240125030910-e6f5a45b002e.zip",
|
||||
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240125030910-e6f5a45b002e.zip",
|
||||
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240202121323-8b3b01e8d770.zip",
|
||||
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240202121323-8b3b01e8d770.zip",
|
||||
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240202121323-8b3b01e8d770.zip",
|
||||
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240202121323-8b3b01e8d770.zip",
|
||||
],
|
||||
)
|
||||
go_repository(
|
||||
|
||||
2
go.mod
2
go.mod
@ -107,7 +107,7 @@ require (
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/tdakkota/asciicheck v0.2.0
|
||||
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
|
||||
github.com/tikv/client-go/v2 v2.0.8-0.20240125030910-e6f5a45b002e
|
||||
github.com/tikv/client-go/v2 v2.0.8-0.20240202121323-8b3b01e8d770
|
||||
github.com/tikv/pd/client v0.0.0-20240126020320-567c7d43a008
|
||||
github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a
|
||||
github.com/twmb/murmur3 v1.1.6
|
||||
|
||||
4
go.sum
4
go.sum
@ -864,8 +864,8 @@ github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJf
|
||||
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU=
|
||||
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW93SG+q0F8KI+yFrcIDT4c/RNoc4=
|
||||
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
|
||||
github.com/tikv/client-go/v2 v2.0.8-0.20240125030910-e6f5a45b002e h1:I/T4S2jY6yHQdwYQKDBXdDPt44xG/P9TkqUicraEjYk=
|
||||
github.com/tikv/client-go/v2 v2.0.8-0.20240125030910-e6f5a45b002e/go.mod h1:jZLZhtui1Po+x616K7jxVAMe+aQfAuWqUZluRdO75Kc=
|
||||
github.com/tikv/client-go/v2 v2.0.8-0.20240202121323-8b3b01e8d770 h1:+ISGAm7M0T4SrK1nrkZI9nWmhe62XR48eTh898vKvFM=
|
||||
github.com/tikv/client-go/v2 v2.0.8-0.20240202121323-8b3b01e8d770/go.mod h1:jZLZhtui1Po+x616K7jxVAMe+aQfAuWqUZluRdO75Kc=
|
||||
github.com/tikv/pd/client v0.0.0-20240126020320-567c7d43a008 h1:McTV/45piKWPinw0m7gFospPEGBW8AfK5J0RB/G9DP4=
|
||||
github.com/tikv/pd/client v0.0.0-20240126020320-567c7d43a008/go.mod h1:Z/QAgOt29zvwBTd0H6pdx45VO6KRNc/O/DzGkVmSyZg=
|
||||
github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a h1:A6uKudFIfAEpoPdaal3aSqGxBzLyU8TqyXImLwo6dIo=
|
||||
|
||||
@ -10,6 +10,8 @@ go_library(
|
||||
"//pkg/kv",
|
||||
"//pkg/parser/terror",
|
||||
"//pkg/util/dbterror",
|
||||
"//pkg/util/dbterror/exeerrors",
|
||||
"//pkg/util/sqlkiller",
|
||||
"@com_github_pingcap_errors//:errors",
|
||||
"@com_github_tikv_client_go_v2//error",
|
||||
"@com_github_tikv_pd_client//errs",
|
||||
|
||||
@ -22,6 +22,8 @@ import (
|
||||
"github.com/pingcap/tidb/pkg/kv"
|
||||
"github.com/pingcap/tidb/pkg/parser/terror"
|
||||
"github.com/pingcap/tidb/pkg/util/dbterror"
|
||||
"github.com/pingcap/tidb/pkg/util/dbterror/exeerrors"
|
||||
"github.com/pingcap/tidb/pkg/util/sqlkiller"
|
||||
tikverr "github.com/tikv/client-go/v2/error"
|
||||
pderr "github.com/tikv/pd/client/errs"
|
||||
)
|
||||
@ -116,9 +118,21 @@ func ToTiDBErr(err error) error {
|
||||
return ErrTiFlashServerTimeout
|
||||
}
|
||||
|
||||
if stderrs.Is(err, tikverr.ErrQueryInterrupted) {
|
||||
if stderrs.Is(err, tikverr.ErrQueryInterruptedWithSignal{Signal: sqlkiller.QueryInterrupted}) {
|
||||
// TODO: This error is defined here, while others are using exeerrors as in sql killer. Maybe unify them?
|
||||
return ErrQueryInterrupted
|
||||
}
|
||||
if stderrs.Is(err, tikverr.ErrQueryInterruptedWithSignal{Signal: sqlkiller.MaxExecTimeExceeded}) {
|
||||
return exeerrors.ErrMaxExecTimeExceeded.GenWithStackByArgs()
|
||||
}
|
||||
if stderrs.Is(err, tikverr.ErrQueryInterruptedWithSignal{Signal: sqlkiller.QueryMemoryExceeded}) {
|
||||
// connection id is unknown in client, which should be logged or filled by upper layers
|
||||
return exeerrors.ErrMemoryExceedForQuery.GenWithStackByArgs(-1)
|
||||
}
|
||||
if stderrs.Is(err, tikverr.ErrQueryInterruptedWithSignal{Signal: sqlkiller.ServerMemoryExceeded}) {
|
||||
// connection id is unknown in client, which should be logged or filled by upper layers
|
||||
return exeerrors.ErrMemoryExceedForInstance.GenWithStackByArgs(-1)
|
||||
}
|
||||
|
||||
if stderrs.Is(err, tikverr.ErrTiKVServerBusy) {
|
||||
return ErrTiKVServerBusy
|
||||
|
||||
@ -33,6 +33,8 @@ const (
|
||||
MaxExecTimeExceeded
|
||||
QueryMemoryExceeded
|
||||
ServerMemoryExceeded
|
||||
// When you add a new signal, you should also modify store/driver/error/ToTidbErr,
|
||||
// so that errors in client can be correctly converted to tidb errors.
|
||||
)
|
||||
|
||||
// SQLKiller is used to kill a query.
|
||||
|
||||
Reference in New Issue
Block a user