variable: add @@tidb_enable_batch_query_region (#60015)

ref pingcap/tidb#58439
This commit is contained in:
JmPotato
2025-03-12 18:46:57 +08:00
committed by GitHub
parent 60ade6ef17
commit 2fc7aa5ee6
7 changed files with 40 additions and 18 deletions

View File

@ -5893,13 +5893,13 @@ def go_deps():
name = "com_github_pingcap_kvproto",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/kvproto",
sha256 = "a8a2a43cd5e91f40881316cebcd45e5509c5733868923d99fed46a3098a5bfef",
strip_prefix = "github.com/pingcap/kvproto@v0.0.0-20250205033218-ad14807ace91",
sha256 = "15a8029ff859e3ecf8de3767db3aa8478b226fab0be7729b514a8bed783b6bdd",
strip_prefix = "github.com/pingcap/kvproto@v0.0.0-20250224053625-b6a98c6bf02d",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250205033218-ad14807ace91.zip",
"http://ats.apps.svc/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250205033218-ad14807ace91.zip",
"https://cache.hawkingrei.com/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250205033218-ad14807ace91.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250205033218-ad14807ace91.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250224053625-b6a98c6bf02d.zip",
"http://ats.apps.svc/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250224053625-b6a98c6bf02d.zip",
"https://cache.hawkingrei.com/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250224053625-b6a98c6bf02d.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20250224053625-b6a98c6bf02d.zip",
],
)
go_repository(
@ -7128,13 +7128,13 @@ def go_deps():
name = "com_github_tikv_pd_client",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/pd/client",
sha256 = "62a42a037394147580beb340dbe0f707a1e3e32300764c5cb0c4715719697306",
strip_prefix = "github.com/tikv/pd/client@v0.0.0-20250213082949-e8930327be42",
sha256 = "7b8e94afd2dfe2e12991ad419e8bb84781e592848ac901f60bec19a609633065",
strip_prefix = "github.com/tikv/pd/client@v0.0.0-20250311030855-e245c1fb30c9",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250213082949-e8930327be42.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250213082949-e8930327be42.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250213082949-e8930327be42.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250213082949-e8930327be42.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250311030855-e245c1fb30c9.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250311030855-e245c1fb30c9.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250311030855-e245c1fb30c9.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20250311030855-e245c1fb30c9.zip",
],
)
go_repository(

4
go.mod
View File

@ -88,7 +88,7 @@ require (
github.com/pingcap/errors v0.11.5-0.20240318064555-6bd07397691f
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
github.com/pingcap/fn v1.0.0
github.com/pingcap/kvproto v0.0.0-20250205033218-ad14807ace91
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e
@ -111,7 +111,7 @@ require (
github.com/tdakkota/asciicheck v0.3.0
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tikv/client-go/v2 v2.0.8-0.20250214064015-a805ea84f300
github.com/tikv/pd/client v0.0.0-20250213082949-e8930327be42
github.com/tikv/pd/client v0.0.0-20250311030855-e245c1fb30c9
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3
github.com/twmb/murmur3 v1.1.6
github.com/uber/jaeger-client-go v2.22.1+incompatible

8
go.sum
View File

@ -680,8 +680,8 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
github.com/pingcap/kvproto v0.0.0-20250205033218-ad14807ace91 h1:immgftBDX85+LT5elPSY4AKV3I8yzKsaMQC7wC3rX2Q=
github.com/pingcap/kvproto v0.0.0-20250205033218-ad14807ace91/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d h1:52qhTQG8G8V/pHo/w7F4d2Tw98KMk2C+gAe3U8SWRAg=
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a h1:WIhmJBlNGmnCWH6TLMdZfNEDaiU8cFpZe3iaqDbQ0M8=
@ -846,8 +846,8 @@ 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.20250214064015-a805ea84f300 h1:imV8hMAanK2keUM3sTnVgZ3qEyjB1RJ/tU0vrz68vAM=
github.com/tikv/client-go/v2 v2.0.8-0.20250214064015-a805ea84f300/go.mod h1:C6LbDj8IjVyDsZlXAcLA57sdDRIQVrHXkgALHx7hk5g=
github.com/tikv/pd/client v0.0.0-20250213082949-e8930327be42 h1:hvB0tf4u5ZU1vAew3MmbyxdYuogDLjIZYzSFt1ACFqo=
github.com/tikv/pd/client v0.0.0-20250213082949-e8930327be42/go.mod h1:veL5JbFL99G5cvS/Q2cLiFQklIiSrVgsBCwFnXc+Zgo=
github.com/tikv/pd/client v0.0.0-20250311030855-e245c1fb30c9 h1:11A7Hm0aU43Nik1Xr3CmGbOAstEmwyoCFsyN91VRTdE=
github.com/tikv/pd/client v0.0.0-20250311030855-e245c1fb30c9/go.mod h1:6fHHp8ecZIIkGyjxKn/oZFqX5dzrRkcHjFJPlBpigzQ=
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 h1:y4mJRFlM6fUyPhoXuFg/Yu02fg/nIPFMOY8tOqppoFg=
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=

View File

@ -107,6 +107,13 @@ func (do *Domain) setPDClientDynamicOption(name, sVal string) error {
if err != nil {
return err
}
case vardef.TiDBEnableBatchQueryRegion:
val := variable.TiDBOptOn(sVal)
err := do.updatePDClient(opt.EnableRouterClient, val)
if err != nil {
return err
}
vardef.EnableBatchQueryRegion.Store(val)
}
return nil
}

View File

@ -662,6 +662,10 @@ func TestSetVar(t *testing.T) {
tk.MustExec("set global pd_enable_follower_handle_region = 1")
tk.MustQuery("select @@pd_enable_follower_handle_region").Check(testkit.Rows("1"))
require.Error(t, tk.ExecToErr("set pd_enable_follower_handle_region = 1"))
tk.MustQuery("select @@tidb_enable_batch_query_region").Check(testkit.Rows("0"))
tk.MustExec("set global tidb_enable_batch_query_region = 1")
tk.MustQuery("select @@tidb_enable_batch_query_region").Check(testkit.Rows("1"))
require.Error(t, tk.ExecToErr("set tidb_enable_batch_query_region = 1"))
tk.MustQuery("select @@tidb_enable_historical_stats").Check(testkit.Rows("0"))
tk.MustExec("set global tidb_enable_historical_stats = 1")

View File

@ -741,8 +741,12 @@ const (
TiDBEnableTSOFollowerProxy = "tidb_enable_tso_follower_proxy"
// PDEnableFollowerHandleRegion indicates whether to enable the PD Follower handle region API.
// TODO: deprecated this variable to use a format like `tidb_enable_pd_follower_handle_region`.
PDEnableFollowerHandleRegion = "pd_enable_follower_handle_region"
// TiDBEnableBatchQueryRegion indicates whether to enable the batch query region feature.
TiDBEnableBatchQueryRegion = "tidb_enable_batch_query_region"
// TiDBEnableOrderedResultMode indicates if stabilize query results.
TiDBEnableOrderedResultMode = "tidb_enable_ordered_result_mode"
@ -1411,6 +1415,7 @@ const (
DefTiDBTSOClientBatchMaxWaitTime = 0.0 // 0ms
DefTiDBEnableTSOFollowerProxy = false
DefPDEnableFollowerHandleRegion = true
DefTiDBEnableBatchQueryRegion = false
DefTiDBEnableOrderedResultMode = false
DefTiDBEnablePseudoForOutdatedStats = false
DefTiDBRegardNULLAsPoint = true
@ -1638,6 +1643,7 @@ var (
MaxTSOBatchWaitInterval = atomic.NewFloat64(DefTiDBTSOClientBatchMaxWaitTime)
EnableTSOFollowerProxy = atomic.NewBool(DefTiDBEnableTSOFollowerProxy)
EnablePDFollowerHandleRegion = atomic.NewBool(DefPDEnableFollowerHandleRegion)
EnableBatchQueryRegion = atomic.NewBool(DefTiDBEnableBatchQueryRegion)
RestrictedReadOnly = atomic.NewBool(DefTiDBRestrictedReadOnly)
VarTiDBSuperReadOnly = atomic.NewBool(DefTiDBSuperReadOnly)
PersistAnalyzeOptions = atomic.NewBool(DefTiDBPersistAnalyzeOptions)

View File

@ -708,6 +708,11 @@ var defaultSysVars = []*SysVar{
}, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
return (*SetPDClientDynamicOption.Load())(vardef.PDEnableFollowerHandleRegion, val)
}},
{Scope: vardef.ScopeGlobal, Name: vardef.TiDBEnableBatchQueryRegion, Value: BoolToOnOff(vardef.DefTiDBEnableBatchQueryRegion), Type: vardef.TypeBool, GetGlobal: func(_ context.Context, sv *SessionVars) (string, error) {
return BoolToOnOff(vardef.EnableBatchQueryRegion.Load()), nil
}, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
return (*SetPDClientDynamicOption.Load())(vardef.TiDBEnableBatchQueryRegion, val)
}},
{Scope: vardef.ScopeGlobal, Name: vardef.TiDBEnableLocalTxn, Value: BoolToOnOff(vardef.DefTiDBEnableLocalTxn), Hidden: true, Type: vardef.TypeBool, Depended: true, GetGlobal: func(_ context.Context, sv *SessionVars) (string, error) {
return BoolToOnOff(vardef.EnableLocalTxn.Load()), nil
}, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {