Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variable: fix data race in the variable.SetPDClientDynamicOption #38374

Merged
merged 3 commits into from Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions br/pkg/restore/BUILD.bazel
Expand Up @@ -111,6 +111,8 @@ go_test(
],
embed = [":restore"],
flaky = True,
race = "on",
Copy link
Member Author

Choose a reason for hiding this comment

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

Enable data race test because the case is found by this case.

shard_count = 20,
deps = [
"//br/pkg/backup",
"//br/pkg/conn",
Expand Down
3 changes: 2 additions & 1 deletion domain/domain_sysvars.go
Expand Up @@ -31,7 +31,8 @@ import (
// which is overwritten here.
func (do *Domain) initDomainSysVars() {
variable.SetStatsCacheCapacity.Store(do.setStatsCacheCapacity)
variable.SetPDClientDynamicOption = do.setPDClientDynamicOption
pdClientDynamicOptionFunc := do.setPDClientDynamicOption
variable.SetPDClientDynamicOption.Store(&pdClientDynamicOptionFunc)
}

// setStatsCacheCapacity sets statsCache cap
Expand Down
4 changes: 2 additions & 2 deletions sessionctx/variable/sysvar.go
Expand Up @@ -496,13 +496,13 @@ var defaultSysVars = []*SysVar{
return strconv.FormatFloat(MaxTSOBatchWaitInterval.Load(), 'f', -1, 64), nil
},
SetGlobal: func(s *SessionVars, val string) error {
SetPDClientDynamicOption(TiDBTSOClientBatchMaxWaitTime, val)
(*SetPDClientDynamicOption.Load())(TiDBTSOClientBatchMaxWaitTime, val)
return nil
}},
{Scope: ScopeGlobal, Name: TiDBEnableTSOFollowerProxy, Value: BoolToOnOff(DefTiDBEnableTSOFollowerProxy), Type: TypeBool, GetGlobal: func(sv *SessionVars) (string, error) {
return BoolToOnOff(EnableTSOFollowerProxy.Load()), nil
}, SetGlobal: func(s *SessionVars, val string) error {
SetPDClientDynamicOption(TiDBEnableTSOFollowerProxy, val)
(*SetPDClientDynamicOption.Load())(TiDBEnableTSOFollowerProxy, val)
return nil
}},
{Scope: ScopeGlobal, Name: TiDBEnableLocalTxn, Value: BoolToOnOff(DefTiDBEnableLocalTxn), Hidden: true, Type: TypeBool, GetGlobal: func(sv *SessionVars) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/tidb_vars.go
Expand Up @@ -1117,7 +1117,7 @@ var (
// SetStatsCacheCapacity is the func registered by domain to set statsCache memory quota.
SetStatsCacheCapacity atomic.Value
// SetPDClientDynamicOption is the func registered by domain
SetPDClientDynamicOption func(string, string) = nil
SetPDClientDynamicOption atomic.Pointer[func(string, string)]
// SwitchConcurrentDDL is the func registered by DDL to switch concurrent DDL.
SwitchConcurrentDDL func(bool) error = nil
// SwitchMDL is the func registered by DDL to switch MDL.
Expand Down