Skip to content

Commit

Permalink
Make reading getsysvar list concurrency safe
Browse files Browse the repository at this point in the history
  • Loading branch information
morgo committed May 13, 2021
1 parent cddb747 commit 46d5b31
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,15 @@ func SetSysVar(name string, value string) {
sysVars[name].Value = value
}

// GetSysVars returns the sysVars list under a RWLock
// GetSysVars deep copies the sysVars list under a RWLock
func GetSysVars() map[string]*SysVar {
sysVarsLock.RLock()
defer sysVarsLock.RUnlock()
return sysVars
copy := make(map[string]*SysVar, len(sysVars))
for name, sv := range sysVars {
copy[name] = sv
}
return copy
}

// PluginVarNames is global plugin var names set.
Expand Down

0 comments on commit 46d5b31

Please sign in to comment.