Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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 @@ -7032,13 +7032,13 @@ def go_deps():
name = "com_github_tikv_pd_client",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/pd/client",
sha256 = "8b0b78d6aca161df84144b2c0481088f2fdb4aca6772a23576f6ab8eeafd13e0",
strip_prefix = "github.com/tikv/pd/[email protected]20231227120157-cee6e63b9f06",
sha256 = "aac6fe491f2e2ef2ddc9ef5c4874ccef91a9fb2586a308334e29c11f94ddd1c6",
strip_prefix = "github.com/tikv/pd/[email protected]20231229094228-a67ccbb8165f",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231227120157-cee6e63b9f06.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231227120157-cee6e63b9f06.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231227120157-cee6e63b9f06.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231227120157-cee6e63b9f06.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231229094228-a67ccbb8165f.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231229094228-a67ccbb8165f.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231229094228-a67ccbb8165f.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231229094228-a67ccbb8165f.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ require (
github.com/tdakkota/asciicheck v0.2.0
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tikv/client-go/v2 v2.0.8-0.20231227070846-61c486af13a5
github.com/tikv/pd/client v0.0.0-20231227120157-cee6e63b9f06
github.com/tikv/pd/client v0.0.0-20231229094228-a67ccbb8165f
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966
github.com/twmb/murmur3 v1.1.6
github.com/uber/jaeger-client-go v2.22.1+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,8 @@ github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
github.com/tikv/client-go/v2 v2.0.8-0.20231227070846-61c486af13a5 h1:UldBK/txpUdWwPlxfNJKLTrciZ8BUzhYtXj0RY0uliY=
github.com/tikv/client-go/v2 v2.0.8-0.20231227070846-61c486af13a5/go.mod h1:byff6zglNXgereADRRJmKQnurwy1Z9hthX2I5ObKMNE=
github.com/tikv/pd/client v0.0.0-20231227120157-cee6e63b9f06 h1:YpiwCMSX+UoV4VOn2quaMzkgYZg9fCwpSqO6EUjaKD0=
github.com/tikv/pd/client v0.0.0-20231227120157-cee6e63b9f06/go.mod h1:ZilHJZR8wgqENRi26gtnPoKIXAB1EqytFweUhzxetx0=
github.com/tikv/pd/client v0.0.0-20231229094228-a67ccbb8165f h1:6jTe0MtKovVgQDDi1tcKLHvqeYr7ukNV9CHA0FqwBOE=
github.com/tikv/pd/client v0.0.0-20231229094228-a67ccbb8165f/go.mod h1:ZilHJZR8wgqENRi26gtnPoKIXAB1EqytFweUhzxetx0=
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M=
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966/go.mod h1:27bSVNWSBOHm+qRp1T9qzaIpsWEP6TbUnei/43HK+PQ=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
Expand Down
9 changes: 9 additions & 0 deletions pkg/domain/domain_sysvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ func (do *Domain) setPDClientDynamicOption(name, sVal string) {
break
}
variable.EnableTSOFollowerProxy.Store(val)
case variable.PDEnableFollowerHandleRegion:
val := variable.TiDBOptOn(sVal)
// Note: EnableFollowerHandle is only used for region API now.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be EnableFollowerHandleRegion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed in pr, the variable names of pd client will not change for now. At present, we only need to define the names directly exposed to users in TiDB.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I remember that.

// If pd support more APIs in follower, the pd option may be changed.
err := do.updatePDClient(pd.EnableFollowerHandle, val)
if err != nil {
break
}
variable.EnablePDFollowerHandleRegion.Store(val)
}
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,12 @@ func TestSetVar(t *testing.T) {
tk.MustExec("set global tidb_enable_tso_follower_proxy = 0")
tk.MustQuery("select @@tidb_enable_tso_follower_proxy").Check(testkit.Rows("0"))
require.Error(t, tk.ExecToErr("set tidb_enable_tso_follower_proxy = 1"))
tk.MustQuery("select @@pd_enable_follower_handle_region").Check(testkit.Rows("0"))
tk.MustExec("set global pd_enable_follower_handle_region = 1")
tk.MustQuery("select @@pd_enable_follower_handle_region").Check(testkit.Rows("1"))
tk.MustExec("set global pd_enable_follower_handle_region = 0")
tk.MustQuery("select @@pd_enable_follower_handle_region").Check(testkit.Rows("0"))
require.Error(t, tk.ExecToErr("set pd_enable_follower_handle_region = 1"))

tk.MustQuery("select @@tidb_enable_historical_stats").Check(testkit.Rows("1"))
tk.MustExec("set global tidb_enable_historical_stats = 1")
Expand Down
6 changes: 6 additions & 0 deletions pkg/sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,12 @@ var defaultSysVars = []*SysVar{
(*SetPDClientDynamicOption.Load())(TiDBEnableTSOFollowerProxy, val)
return nil
}},
{Scope: ScopeGlobal, Name: PDEnableFollowerHandleRegion, Value: BoolToOnOff(DefPDEnableFollowerHandleRegion), Type: TypeBool, GetGlobal: func(_ context.Context, sv *SessionVars) (string, error) {
return BoolToOnOff(EnablePDFollowerHandleRegion.Load()), nil
}, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
(*SetPDClientDynamicOption.Load())(PDEnableFollowerHandleRegion, val)
return nil
}},
{Scope: ScopeGlobal, Name: TiDBEnableLocalTxn, Value: BoolToOnOff(DefTiDBEnableLocalTxn), Hidden: true, Type: TypeBool, Depended: true, GetGlobal: func(_ context.Context, sv *SessionVars) (string, error) {
return BoolToOnOff(EnableLocalTxn.Load()), nil
}, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
Expand Down
5 changes: 5 additions & 0 deletions pkg/sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@ const (
// TiDBEnableTSOFollowerProxy indicates whether to enable the TSO Follower Proxy feature of PD client.
TiDBEnableTSOFollowerProxy = "tidb_enable_tso_follower_proxy"

// PDEnableFollowerHandleRegion indicates whether to enable the PD Follower handle region API.
PDEnableFollowerHandleRegion = "pd_enable_follower_handle_region"

// TiDBEnableOrderedResultMode indicates if stabilize query results.
TiDBEnableOrderedResultMode = "tidb_enable_ordered_result_mode"

Expand Down Expand Up @@ -1290,6 +1293,7 @@ const (
DefTiDBEnableLocalTxn = false
DefTiDBTSOClientBatchMaxWaitTime = 0.0 // 0ms
DefTiDBEnableTSOFollowerProxy = false
DefPDEnableFollowerHandleRegion = false
DefTiDBEnableOrderedResultMode = false
DefTiDBEnablePseudoForOutdatedStats = false
DefTiDBRegardNULLAsPoint = true
Expand Down Expand Up @@ -1476,6 +1480,7 @@ var (
EnableLocalTxn = atomic.NewBool(DefTiDBEnableLocalTxn)
MaxTSOBatchWaitInterval = atomic.NewFloat64(DefTiDBTSOClientBatchMaxWaitTime)
EnableTSOFollowerProxy = atomic.NewBool(DefTiDBEnableTSOFollowerProxy)
EnablePDFollowerHandleRegion = atomic.NewBool(DefPDEnableFollowerHandleRegion)
RestrictedReadOnly = atomic.NewBool(DefTiDBRestrictedReadOnly)
VarTiDBSuperReadOnly = atomic.NewBool(DefTiDBSuperReadOnly)
PersistAnalyzeOptions = atomic.NewBool(DefTiDBPersistAnalyzeOptions)
Expand Down
11 changes: 11 additions & 0 deletions tests/integrationtest/r/session/vars.result
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ set global tidb_enable_tso_follower_proxy = off;
select @@tidb_enable_tso_follower_proxy;
@@tidb_enable_tso_follower_proxy
0
select @@pd_enable_follower_handle_region;
@@pd_enable_follower_handle_region
0
set global pd_enable_follower_handle_region = on;
select @@pd_enable_follower_handle_region;
@@pd_enable_follower_handle_region
1
set global pd_enable_follower_handle_region = off;
select @@pd_enable_follower_handle_region;
@@pd_enable_follower_handle_region
0
set tidb_tso_client_batch_max_wait_time = 0;
Error 1229 (HY000): Variable 'tidb_tso_client_batch_max_wait_time' is a GLOBAL variable and should be set with SET GLOBAL
set global tidb_enable_tso_follower_proxy = default;
Expand Down
5 changes: 5 additions & 0 deletions tests/integrationtest/t/session/vars.test
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ set global tidb_enable_tso_follower_proxy = on;
select @@tidb_enable_tso_follower_proxy;
set global tidb_enable_tso_follower_proxy = off;
select @@tidb_enable_tso_follower_proxy;
select @@pd_enable_follower_handle_region;
set global pd_enable_follower_handle_region = on;
select @@pd_enable_follower_handle_region;
set global pd_enable_follower_handle_region = off;
select @@pd_enable_follower_handle_region;
-- error 1229
set tidb_tso_client_batch_max_wait_time = 0;
set global tidb_enable_tso_follower_proxy = default;
Expand Down