Skip to content

Commit 7b4717b

Browse files
authored
*: (release-9.0) validate ts only for stale read (#60033)
ref #59402
1 parent cbda2c9 commit 7b4717b

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

DEPS.bzl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5893,13 +5893,13 @@ def go_deps():
58935893
name = "com_github_pingcap_kvproto",
58945894
build_file_proto_mode = "disable_global",
58955895
importpath = "github.com/pingcap/kvproto",
5896-
sha256 = "a8a2a43cd5e91f40881316cebcd45e5509c5733868923d99fed46a3098a5bfef",
5897-
strip_prefix = "github.com/pingcap/[email protected]20250205033218-ad14807ace91",
5896+
sha256 = "15a8029ff859e3ecf8de3767db3aa8478b226fab0be7729b514a8bed783b6bdd",
5897+
strip_prefix = "github.com/pingcap/[email protected]20250224053625-b6a98c6bf02d",
58985898
urls = [
5899-
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250205033218-ad14807ace91.zip",
5900-
"http://ats.apps.svc/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250205033218-ad14807ace91.zip",
5901-
"https://cache.hawkingrei.com/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250205033218-ad14807ace91.zip",
5902-
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250205033218-ad14807ace91.zip",
5899+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250224053625-b6a98c6bf02d.zip",
5900+
"http://ats.apps.svc/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250224053625-b6a98c6bf02d.zip",
5901+
"https://cache.hawkingrei.com/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250224053625-b6a98c6bf02d.zip",
5902+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250224053625-b6a98c6bf02d.zip",
59035903
],
59045904
)
59055905
go_repository(
@@ -7115,26 +7115,26 @@ def go_deps():
71157115
name = "com_github_tikv_client_go_v2",
71167116
build_file_proto_mode = "disable_global",
71177117
importpath = "github.com/tikv/client-go/v2",
7118-
sha256 = "1cd1a58479d10cf4defc85453d5c76e6275d2995ab74f2defc01a9a19f4ac5da",
7119-
strip_prefix = "github.com/tikv/client-go/[email protected].20250214064015-a805ea84f300",
7118+
sha256 = "5653bf193b8fadb46e44bb256c8ee15e03ae3ec07da70f940d254dd8883698f2",
7119+
strip_prefix = "github.com/tikv/client-go/[email protected].20250312123431-fe06bbfaaa89",
71207120
urls = [
7121-
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250214064015-a805ea84f300.zip",
7122-
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250214064015-a805ea84f300.zip",
7123-
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250214064015-a805ea84f300.zip",
7124-
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250214064015-a805ea84f300.zip",
7121+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250312123431-fe06bbfaaa89.zip",
7122+
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250312123431-fe06bbfaaa89.zip",
7123+
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250312123431-fe06bbfaaa89.zip",
7124+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20250312123431-fe06bbfaaa89.zip",
71257125
],
71267126
)
71277127
go_repository(
71287128
name = "com_github_tikv_pd_client",
71297129
build_file_proto_mode = "disable_global",
71307130
importpath = "github.com/tikv/pd/client",
7131-
sha256 = "62a42a037394147580beb340dbe0f707a1e3e32300764c5cb0c4715719697306",
7132-
strip_prefix = "github.com/tikv/pd/[email protected]20250213082949-e8930327be42",
7131+
sha256 = "7ab97b633caa85ad5e15e60ca0b3dad925fb2657c1f5a0121d32a29a71d112e9",
7132+
strip_prefix = "github.com/tikv/pd/[email protected]20250305170641-bdd857e5503b",
71337133
urls = [
7134-
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250213082949-e8930327be42.zip",
7135-
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250213082949-e8930327be42.zip",
7136-
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250213082949-e8930327be42.zip",
7137-
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250213082949-e8930327be42.zip",
7134+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250305170641-bdd857e5503b.zip",
7135+
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250305170641-bdd857e5503b.zip",
7136+
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250305170641-bdd857e5503b.zip",
7137+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250305170641-bdd857e5503b.zip",
71387138
],
71397139
)
71407140
go_repository(

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ require (
8888
github.com/pingcap/errors v0.11.5-0.20240318064555-6bd07397691f
8989
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
9090
github.com/pingcap/fn v1.0.0
91-
github.com/pingcap/kvproto v0.0.0-20250205033218-ad14807ace91
91+
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d
9292
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a
9393
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
9494
github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e
@@ -110,8 +110,8 @@ require (
110110
github.com/stretchr/testify v1.10.0
111111
github.com/tdakkota/asciicheck v0.3.0
112112
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
113-
github.com/tikv/client-go/v2 v2.0.8-0.20250214064015-a805ea84f300
114-
github.com/tikv/pd/client v0.0.0-20250213082949-e8930327be42
113+
github.com/tikv/client-go/v2 v2.0.8-0.20250312123431-fe06bbfaaa89
114+
github.com/tikv/pd/client v0.0.0-20250305170641-bdd857e5503b
115115
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3
116116
github.com/twmb/murmur3 v1.1.6
117117
github.com/uber/jaeger-client-go v2.22.1+incompatible

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,8 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z
680680
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
681681
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
682682
github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
683-
github.com/pingcap/kvproto v0.0.0-20250205033218-ad14807ace91 h1:immgftBDX85+LT5elPSY4AKV3I8yzKsaMQC7wC3rX2Q=
684-
github.com/pingcap/kvproto v0.0.0-20250205033218-ad14807ace91/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
683+
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d h1:52qhTQG8G8V/pHo/w7F4d2Tw98KMk2C+gAe3U8SWRAg=
684+
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
685685
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
686686
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
687687
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a h1:WIhmJBlNGmnCWH6TLMdZfNEDaiU8cFpZe3iaqDbQ0M8=
@@ -844,10 +844,10 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
844844
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
845845
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
846846
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
847-
github.com/tikv/client-go/v2 v2.0.8-0.20250214064015-a805ea84f300 h1:imV8hMAanK2keUM3sTnVgZ3qEyjB1RJ/tU0vrz68vAM=
848-
github.com/tikv/client-go/v2 v2.0.8-0.20250214064015-a805ea84f300/go.mod h1:C6LbDj8IjVyDsZlXAcLA57sdDRIQVrHXkgALHx7hk5g=
849-
github.com/tikv/pd/client v0.0.0-20250213082949-e8930327be42 h1:hvB0tf4u5ZU1vAew3MmbyxdYuogDLjIZYzSFt1ACFqo=
850-
github.com/tikv/pd/client v0.0.0-20250213082949-e8930327be42/go.mod h1:veL5JbFL99G5cvS/Q2cLiFQklIiSrVgsBCwFnXc+Zgo=
847+
github.com/tikv/client-go/v2 v2.0.8-0.20250312123431-fe06bbfaaa89 h1:mcYYT+HCCicZ0zRrib38Gr0W2gL2xppDvZy0a/f4Rww=
848+
github.com/tikv/client-go/v2 v2.0.8-0.20250312123431-fe06bbfaaa89/go.mod h1:C6LbDj8IjVyDsZlXAcLA57sdDRIQVrHXkgALHx7hk5g=
849+
github.com/tikv/pd/client v0.0.0-20250305170641-bdd857e5503b h1:LwThpm5/qjNC1TMKp7aYgfVKyz1/XLKSCGMGxZlq9Yg=
850+
github.com/tikv/pd/client v0.0.0-20250305170641-bdd857e5503b/go.mod h1:6fHHp8ecZIIkGyjxKn/oZFqX5dzrRkcHjFJPlBpigzQ=
851851
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 h1:y4mJRFlM6fUyPhoXuFg/Yu02fg/nIPFMOY8tOqppoFg=
852852
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460=
853853
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=

pkg/executor/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ go_library(
288288
"@com_github_tikv_client_go_v2//error",
289289
"@com_github_tikv_client_go_v2//kv",
290290
"@com_github_tikv_client_go_v2//oracle",
291+
"@com_github_tikv_client_go_v2//oracle/oracles",
291292
"@com_github_tikv_client_go_v2//tikv",
292293
"@com_github_tikv_client_go_v2//tikvrpc",
293294
"@com_github_tikv_client_go_v2//txnkv",

pkg/executor/set.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/pingcap/tidb/pkg/util/gcutil"
4242
"github.com/pingcap/tidb/pkg/util/logutil"
4343
"github.com/pingcap/tidb/pkg/util/sem"
44+
"github.com/tikv/client-go/v2/oracle/oracles"
4445
"go.uber.org/zap"
4546
)
4647

@@ -224,7 +225,13 @@ func (e *SetExecutor) setSysVariable(ctx context.Context, name string, v *expres
224225
newSnapshotIsSet := newSnapshotTS > 0 && newSnapshotTS != oldSnapshotTS
225226
if newSnapshotIsSet {
226227
isStaleRead := name == vardef.TiDBTxnReadTS
227-
err = sessionctx.ValidateSnapshotReadTS(ctx, e.Ctx().GetStore(), newSnapshotTS, isStaleRead)
228+
var ctxForReadTsValidator context.Context
229+
if !isStaleRead {
230+
ctxForReadTsValidator = context.WithValue(ctx, oracles.ValidateReadTSForTidbSnapshot{}, struct{}{})
231+
} else {
232+
ctxForReadTsValidator = ctx
233+
}
234+
err = sessionctx.ValidateSnapshotReadTS(ctxForReadTsValidator, e.Ctx().GetStore(), newSnapshotTS, isStaleRead)
228235
if name != vardef.TiDBTxnReadTS {
229236
// Also check gc safe point for snapshot read.
230237
// We don't check snapshot with gc safe point for read_ts

0 commit comments

Comments
 (0)