Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7233,13 +7233,13 @@ def go_deps():
build_tags = ["nextgen"],
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sha256 = "904f8a5f2109225801c83ced1542513684c72a15b20d41f6904c383e31d1f6eb",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20250606040308-37a271405306",
sha256 = "e5952c1ca480c8b65d52e03096e960aff85bcca24cc01b641baa553ec5c4b2ff",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20250609073940-74c0a811505b",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250606040308-37a271405306.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250606040308-37a271405306.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250606040308-37a271405306.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250606040308-37a271405306.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250609073940-74c0a811505b.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250609073940-74c0a811505b.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250609073940-74c0a811505b.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250609073940-74c0a811505b.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3278,7 +3278,7 @@ Region is unavailable

["tikv:9006"]
error = '''
GC life time is shorter than transaction duration, transaction starts at %v, GC safe point is %v
GC life time is shorter than transaction duration, transaction start ts is %v (%v), txn safe point is %v (%v)
'''

["tikv:9008"]
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ require (
github.com/stretchr/testify v1.10.0
github.com/tdakkota/asciicheck v0.4.1
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tikv/client-go/v2 v2.0.8-0.20250606040308-37a271405306
github.com/tikv/client-go/v2 v2.0.8-0.20250609073940-74c0a811505b
github.com/tikv/pd/client v0.0.0-20250528071146-6cd8a77df2fa
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67
github.com/twmb/murmur3 v1.1.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
github.com/tikv/client-go/v2 v2.0.8-0.20250606040308-37a271405306 h1:/Kd9d16WYmGXQwZYyJhvaGEkMX4Fkocvn9mISwQlRto=
github.com/tikv/client-go/v2 v2.0.8-0.20250606040308-37a271405306/go.mod h1:SWsAhPA9u76Zu5/jzzn+ad5Aj8PnCm2JM50KYCbLLTQ=
github.com/tikv/client-go/v2 v2.0.8-0.20250609073940-74c0a811505b h1:sgHt/P+UubqoqMlaNxlDvrfAM1F+WtXN60ViPg+zNhs=
github.com/tikv/client-go/v2 v2.0.8-0.20250609073940-74c0a811505b/go.mod h1:SWsAhPA9u76Zu5/jzzn+ad5Aj8PnCm2JM50KYCbLLTQ=
github.com/tikv/pd/client v0.0.0-20250528071146-6cd8a77df2fa h1:mZZW8kDe3mspK5nM6meDjEhtnSVA4JIt4gm7FCC1yYA=
github.com/tikv/pd/client v0.0.0-20250528071146-6cd8a77df2fa/go.mod h1:yc63HG/FHgJNvfDPqMOciMtOju1QDYaxajqyN6rnFX0=
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 h1:9LPGD+jzxMlnk5r6+hJnar67cgpDIz/iyD+rfl5r2Vk=
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -3069,7 +3069,7 @@ func getNextPartitionInfo(reorg *reorgInfo, t table.PartitionedTable, currPhysic
ts := oracle.GoTimeToTS(time.Now())
//nolint:forcetypeassert
s := reorg.jobCtx.store.(tikv.Storage)
s.UpdateSPCache(ts, time.Now())
s.UpdateTxnSafePointCache(ts, time.Now())
time.Sleep(time.Second * 3)
}
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/errno/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ const (
ErrTiKVServerBusy = 9003
ErrResolveLockTimeout = 9004
ErrRegionUnavailable = 9005
ErrGCTooEarly = 9006
ErrTxnAbortedByGC = 9006
ErrWriteConflict = 9007
ErrTiKVStoreLimit = 9008
ErrPrometheusAddrIsNotSet = 9009
Expand Down
22 changes: 13 additions & 9 deletions pkg/errno/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -1162,15 +1162,19 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
ErrStorageClassInvalidSpec: mysql.Message("Invalid storage class: %s", nil),

// TiKV/PD errors.
ErrPDServerTimeout: mysql.Message("PD server timeout: %s", nil),
ErrTiKVServerTimeout: mysql.Message("TiKV server timeout", nil),
ErrTiKVServerBusy: mysql.Message("TiKV server is busy", nil),
ErrTiFlashServerTimeout: mysql.Message("TiFlash server timeout", nil),
ErrTiFlashServerBusy: mysql.Message("TiFlash server is busy", nil),
ErrTiFlashBackfillIndex: mysql.Message("TiFlash backfill index failed: %s", nil),
ErrResolveLockTimeout: mysql.Message("Resolve lock timeout", nil),
ErrRegionUnavailable: mysql.Message("Region is unavailable", nil),
ErrGCTooEarly: mysql.Message("GC life time is shorter than transaction duration, transaction starts at %v, GC safe point is %v", nil),
ErrPDServerTimeout: mysql.Message("PD server timeout: %s", nil),
ErrTiKVServerTimeout: mysql.Message("TiKV server timeout", nil),
ErrTiKVServerBusy: mysql.Message("TiKV server is busy", nil),
ErrTiFlashServerTimeout: mysql.Message("TiFlash server timeout", nil),
ErrTiFlashServerBusy: mysql.Message("TiFlash server is busy", nil),
ErrTiFlashBackfillIndex: mysql.Message("TiFlash backfill index failed: %s", nil),
ErrResolveLockTimeout: mysql.Message("Resolve lock timeout", nil),
ErrRegionUnavailable: mysql.Message("Region is unavailable", nil),
// In most cases, the error `ErrTxnAbortedByGC` is caused by the transaction runs too long, instead of improper GC
// life time configuration. This means the description of this error is not accurate.
// However, as this error message is already widely acknowledged and might have become part of our diagnosing
// process, we keep the old error message format.
ErrTxnAbortedByGC: mysql.Message("GC life time is shorter than transaction duration, transaction start ts is %v (%v), txn safe point is %v (%v)", nil),
ErrWriteConflict: mysql.Message("Write conflict, txnStartTS=%d, conflictStartTS=%d, conflictCommitTS=%d, key=%s%s%s%s, reason=%s", []int{3, 4, 5, 6}), // the first and third parts of the key are the optional database names and table names
ErrTiKVStoreLimit: mysql.Message("Store token is up to the limit, store id = %d", nil),
ErrPrometheusAddrIsNotSet: mysql.Message("Prometheus address is not set in PD and etcd", nil),
Expand Down
12 changes: 6 additions & 6 deletions pkg/executor/point_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestSelectCheckVisibility(t *testing.T) {
ts := txn.StartTS()
sessionStore := tk.Session().GetStore().(tikv.Storage)
// Update gc safe time for check data visibility.
sessionStore.UpdateSPCache(ts+1, time.Now())
sessionStore.UpdateTxnSafePointCache(ts+1, time.Now())
checkSelectResultError := func(sql string, expectErr *terror.Error) {
re, err := tk.Exec(sql)
require.NoError(t, err)
Expand All @@ -60,15 +60,15 @@ func TestSelectCheckVisibility(t *testing.T) {
require.True(t, expectErr.Equal(err))
}
// Test point get.
checkSelectResultError("select * from t where a='1'", storeerr.ErrGCTooEarly)
checkSelectResultError("select * from t where a='1'", storeerr.ErrTxnAbortedByGC)
// Test batch point get.
checkSelectResultError("select * from t where a in ('1','2')", storeerr.ErrGCTooEarly)
checkSelectResultError("select * from t where a in ('1','2')", storeerr.ErrTxnAbortedByGC)
// Test Index look up read.
checkSelectResultError("select * from t where b > 0 ", storeerr.ErrGCTooEarly)
checkSelectResultError("select * from t where b > 0 ", storeerr.ErrTxnAbortedByGC)
// Test Index read.
checkSelectResultError("select b from t where b > 0 ", storeerr.ErrGCTooEarly)
checkSelectResultError("select b from t where b > 0 ", storeerr.ErrTxnAbortedByGC)
// Test table read.
checkSelectResultError("select * from t", storeerr.ErrGCTooEarly)
checkSelectResultError("select * from t", storeerr.ErrTxnAbortedByGC)
}

func TestReturnValues(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/staticrecordset/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestStaticRecordSetExceedGCTime(t *testing.T) {
tk.MustExec("truncate table t")

// Update the safe point
store.(tikv.Storage).UpdateSPCache(startTS+1, time.Now())
store.(tikv.Storage).UpdateTxnSafePointCache(startTS+1, time.Now())

// Check data, it'll get an error
chk := srs.NewChunk(nil)
Expand Down
18 changes: 15 additions & 3 deletions pkg/store/driver/error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var (
// ErrTiKVServerTimeout is the error when tikv server is timeout.
ErrTiKVServerTimeout = dbterror.ClassTiKV.NewStd(errno.ErrTiKVServerTimeout)
ErrTiFlashServerTimeout = dbterror.ClassTiKV.NewStd(errno.ErrTiFlashServerTimeout)
// ErrGCTooEarly is the error that GC life time is shorter than transaction duration
ErrGCTooEarly = dbterror.ClassTiKV.NewStd(errno.ErrGCTooEarly)
// ErrTxnAbortedByGC is the error that a transaction has been run for too long and aborted by GC.
ErrTxnAbortedByGC = dbterror.ClassTiKV.NewStd(errno.ErrTxnAbortedByGC)
// ErrTiKVStaleCommand is the error that the command is stale in tikv.
ErrTiKVStaleCommand = dbterror.ClassTiKV.NewStd(errno.ErrTiKVStaleCommand)
// ErrQueryInterrupted is the error when the query is interrupted.
Expand Down Expand Up @@ -150,9 +150,21 @@ func ToTiDBErr(err error) error {
return ErrTiFlashServerBusy
}

var txnAbortedByGC *tikverr.ErrTxnAbortedByGC
if stderrs.As(err, &txnAbortedByGC) {
return ErrTxnAbortedByGC.GenWithStackByArgs(
txnAbortedByGC.TxnStartTS, txnAbortedByGC.TxnStartTSTime,
txnAbortedByGC.TxnSafePoint, txnAbortedByGC.TxnSafePointTime,
)
}

var gcTooEarly *tikverr.ErrGCTooEarly
if stderrs.As(err, &gcTooEarly) {
return ErrGCTooEarly.GenWithStackByArgs(gcTooEarly.TxnStartTS, gcTooEarly.GCSafePoint)
// The old error type doesn't contain the exact value of txn start ts and the (GC or txn) safe point, and its
// fields are in time.Time format. Pass "<unknown>" to replace the value.
// It's expected that `tikverr.ErrTxnAbortedByGC` should never occur again, and are replaced by
// tikverr.ErrTxnAbortedByGC.
return ErrTxnAbortedByGC.GenWithStackByArgs("<unknown>", gcTooEarly.TxnStartTS, "<unknown>", gcTooEarly.GCSafePoint)
}

if stderrs.Is(err, tikverr.ErrTiKVStaleCommand) {
Expand Down
5 changes: 4 additions & 1 deletion pkg/store/gcworker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ go_library(
"@com_github_tikv_client_go_v2//txnkv/rangetask",
"@com_github_tikv_client_go_v2//util",
"@com_github_tikv_pd_client//:client",
"@com_github_tikv_pd_client//clients/gc",
"@com_github_tikv_pd_client//constants",
"@org_uber_go_zap//:zap",
],
)
Expand All @@ -52,7 +54,7 @@ go_test(
embed = [":gcworker"],
flaky = True,
race = "on",
shard_count = 27,
shard_count = 26,
deps = [
"//pkg/config",
"//pkg/ddl/placement",
Expand All @@ -78,6 +80,7 @@ go_test(
"@com_github_tikv_client_go_v2//tikvrpc",
"@com_github_tikv_client_go_v2//txnkv/txnlock",
"@com_github_tikv_pd_client//:client",
"@com_github_tikv_pd_client//clients/gc",
"@com_github_tikv_pd_client//constants",
"@org_uber_go_goleak//:goleak",
],
Expand Down
Loading