Skip to content

Commit 9336ad0

Browse files
authored
*: (release-6.5) Validate ts only for stale read (#59741)
ref #59402
1 parent 438a8b6 commit 9336ad0

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

DEPS.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3603,8 +3603,8 @@ def go_deps():
36033603
name = "com_github_tikv_client_go_v2",
36043604
build_file_proto_mode = "disable_global",
36053605
importpath = "github.com/tikv/client-go/v2",
3606-
sum = "h1:YGhrcemIm3lAQ79g8Lb7aF/PhW6e7M5owperqKdLrb8=",
3607-
version = "v2.0.4-0.20250217042910-ad4338d3d0f9",
3606+
sum = "h1:TueUCiXuPnVK512DZoDfT/6cvpXBD1CMhg8fVu1nFDs=",
3607+
version = "v2.0.4-0.20250225113719-8f4f76934362",
36083608
)
36093609
go_repository(
36103610
name = "com_github_tikv_pd_client",

executor/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ go_library(
225225
"@com_github_tikv_client_go_v2//error",
226226
"@com_github_tikv_client_go_v2//kv",
227227
"@com_github_tikv_client_go_v2//oracle",
228+
"@com_github_tikv_client_go_v2//oracle/oracles",
228229
"@com_github_tikv_client_go_v2//tikv",
229230
"@com_github_tikv_client_go_v2//tikvrpc",
230231
"@com_github_tikv_client_go_v2//txnkv",

executor/set.go

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

@@ -198,7 +199,13 @@ func (e *SetExecutor) setSysVariable(ctx context.Context, name string, v *expres
198199
newSnapshotIsSet := newSnapshotTS > 0 && newSnapshotTS != oldSnapshotTS
199200
if newSnapshotIsSet {
200201
isStaleRead := name == variable.TiDBTxnReadTS
201-
err = sessionctx.ValidateSnapshotReadTS(ctx, e.ctx.GetStore(), newSnapshotTS, isStaleRead)
202+
var ctxForReadTsValidator context.Context
203+
if !isStaleRead {
204+
ctxForReadTsValidator = context.WithValue(ctx, oracles.ValidateReadTSForTidbSnapshot{}, struct{}{})
205+
} else {
206+
ctxForReadTsValidator = ctx
207+
}
208+
err = sessionctx.ValidateSnapshotReadTS(ctxForReadTsValidator, e.ctx.GetStore(), newSnapshotTS, isStaleRead)
202209
if name != variable.TiDBTxnReadTS {
203210
// Also check gc safe point for snapshot read.
204211
// 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
@@ -90,7 +90,7 @@ require (
9090
github.com/stretchr/testify v1.8.4
9191
github.com/tdakkota/asciicheck v0.1.1
9292
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
93-
github.com/tikv/client-go/v2 v2.0.4-0.20250217042910-ad4338d3d0f9
93+
github.com/tikv/client-go/v2 v2.0.4-0.20250225113719-8f4f76934362
9494
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05
9595
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144
9696
github.com/twmb/murmur3 v1.1.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,8 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR
948948
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
949949
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJfDRtkanvQPiooDH8HvJ2FBh+iKT/OmiQQ=
950950
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU=
951-
github.com/tikv/client-go/v2 v2.0.4-0.20250217042910-ad4338d3d0f9 h1:YGhrcemIm3lAQ79g8Lb7aF/PhW6e7M5owperqKdLrb8=
952-
github.com/tikv/client-go/v2 v2.0.4-0.20250217042910-ad4338d3d0f9/go.mod h1:mmVCLP2OqWvQJPOIevQPZvGphzh/oq9vv8J5LDfpadQ=
951+
github.com/tikv/client-go/v2 v2.0.4-0.20250225113719-8f4f76934362 h1:TueUCiXuPnVK512DZoDfT/6cvpXBD1CMhg8fVu1nFDs=
952+
github.com/tikv/client-go/v2 v2.0.4-0.20250225113719-8f4f76934362/go.mod h1:mmVCLP2OqWvQJPOIevQPZvGphzh/oq9vv8J5LDfpadQ=
953953
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05 h1:e4hLUKfgfPeJPZwOfU+/I/03G0sn6IZqVcbX/5o+hvM=
954954
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05/go.mod h1:MLIl+d2WbOF4A3U88WKtyXrQQW417wZDDvBcq2IW9bQ=
955955
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro=

0 commit comments

Comments
 (0)