Skip to content

Commit 350b4a8

Browse files
authored
*: (release-7.1) Validate ts only for stale read (pingcap#59921)
ref pingcap#59402
1 parent 33a7541 commit 350b4a8

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

DEPS.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,8 +4179,8 @@ def go_deps():
41794179
name = "com_github_tikv_client_go_v2",
41804180
build_file_proto_mode = "disable_global",
41814181
importpath = "github.com/tikv/client-go/v2",
4182-
sum = "h1:F+Iq8yyBtQ4Wa2o+wzbYZ65ysuCK0mFHcCapz+4lqi0=",
4183-
version = "v2.0.8-0.20250218014331-8e7b324b5e6e",
4182+
sum = "h1:dKtFbSBZM3FP/4qGx3bW85C8qBNpqLhQtNBy7G+cqKk=",
4183+
version = "v2.0.8-0.20250304121347-870885c3570c",
41844184
)
41854185
go_repository(
41864186
name = "com_github_tikv_pd",

executor/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ go_library(
243243
"@com_github_tikv_client_go_v2//error",
244244
"@com_github_tikv_client_go_v2//kv",
245245
"@com_github_tikv_client_go_v2//oracle",
246+
"@com_github_tikv_client_go_v2//oracle/oracles",
246247
"@com_github_tikv_client_go_v2//tikv",
247248
"@com_github_tikv_client_go_v2//tikvrpc",
248249
"@com_github_tikv_client_go_v2//txnkv",

executor/set.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/pingcap/tidb/util/gcutil"
3737
"github.com/pingcap/tidb/util/logutil"
3838
"github.com/pingcap/tidb/util/sem"
39+
"github.com/tikv/client-go/v2/oracle/oracles"
3940
"go.uber.org/zap"
4041
)
4142

@@ -199,7 +200,13 @@ func (e *SetExecutor) setSysVariable(ctx context.Context, name string, v *expres
199200
newSnapshotIsSet := newSnapshotTS > 0 && newSnapshotTS != oldSnapshotTS
200201
if newSnapshotIsSet {
201202
isStaleRead := name == variable.TiDBTxnReadTS
202-
err = sessionctx.ValidateSnapshotReadTS(ctx, e.ctx.GetStore(), newSnapshotTS, isStaleRead)
203+
var ctxForReadTsValidator context.Context
204+
if !isStaleRead {
205+
ctxForReadTsValidator = context.WithValue(ctx, oracles.ValidateReadTSForTidbSnapshot{}, struct{}{})
206+
} else {
207+
ctxForReadTsValidator = ctx
208+
}
209+
err = sessionctx.ValidateSnapshotReadTS(ctxForReadTsValidator, e.ctx.GetStore(), newSnapshotTS, isStaleRead)
203210
if name != variable.TiDBTxnReadTS {
204211
// Also check gc safe point for snapshot read.
205212
// We don't check snapshot with gc safe point for read_ts

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ require (
9494
github.com/stretchr/testify v1.8.2
9595
github.com/tdakkota/asciicheck v0.2.0
9696
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
97-
github.com/tikv/client-go/v2 v2.0.8-0.20250218014331-8e7b324b5e6e
97+
github.com/tikv/client-go/v2 v2.0.8-0.20250304121347-870885c3570c
9898
github.com/tikv/pd/client v0.0.0-20240725070735-fb162bf0aa3f
9999
github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e
100100
github.com/twmb/murmur3 v1.1.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,8 @@ github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJf
968968
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU=
969969
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW93SG+q0F8KI+yFrcIDT4c/RNoc4=
970970
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
971-
github.com/tikv/client-go/v2 v2.0.8-0.20250218014331-8e7b324b5e6e h1:F+Iq8yyBtQ4Wa2o+wzbYZ65ysuCK0mFHcCapz+4lqi0=
972-
github.com/tikv/client-go/v2 v2.0.8-0.20250218014331-8e7b324b5e6e/go.mod h1:45NuHB8x+VAoztMIjF6hEgXvPQXhXWPfMxDg0N8CoRY=
971+
github.com/tikv/client-go/v2 v2.0.8-0.20250304121347-870885c3570c h1:dKtFbSBZM3FP/4qGx3bW85C8qBNpqLhQtNBy7G+cqKk=
972+
github.com/tikv/client-go/v2 v2.0.8-0.20250304121347-870885c3570c/go.mod h1:45NuHB8x+VAoztMIjF6hEgXvPQXhXWPfMxDg0N8CoRY=
973973
github.com/tikv/pd/client v0.0.0-20240725070735-fb162bf0aa3f h1:Szw9YxqGGEneSniBd4ep09jgB77cKUy+AuhKOmdGPdE=
974974
github.com/tikv/pd/client v0.0.0-20240725070735-fb162bf0aa3f/go.mod h1:QCBn54O5lhfkYfxj8Tyiqaxue/mthHEMyi7AqJP/+n4=
975975
github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e h1:MV6KaVu/hzByHP0UvJ4HcMGE/8a6A4Rggc/0wx2AvJo=

0 commit comments

Comments
 (0)