Skip to content

Commit

Permalink
sessionctx: fix TiDBGOGCTunerThreshold failing to ParseFloat (#38774)
Browse files Browse the repository at this point in the history
close #38778
  • Loading branch information
hawkingrei authored Nov 1, 2022
1 parent 7e4d759 commit cc2a038
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,7 @@ var defaultSysVars = []*SysVar{
return strconv.FormatFloat(GOGCTunerThreshold.Load(), 'f', -1, 64), nil
},
Validation: func(s *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) {
floatValue, err := strconv.ParseFloat(normalizedValue, 64)
if err != nil {
return "", err
}
floatValue := tidbOptFloat64(normalizedValue, DefTiDBGOGCTunerThreshold)
globalMemoryLimitTuner := gctuner.GlobalMemoryLimitTuner.GetPercentage()
if floatValue < 0 && floatValue > 0.9 {
return "", ErrWrongValueForVar.GenWithStackByArgs(TiDBGOGCTunerThreshold, normalizedValue)
Expand All @@ -752,10 +749,7 @@ var defaultSysVars = []*SysVar{
return strconv.FormatFloat(floatValue, 'f', -1, 64), nil
},
SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
factor, err := strconv.ParseFloat(val, 64)
if err != nil {
return err
}
factor := tidbOptFloat64(val, DefTiDBGOGCTunerThreshold)
GOGCTunerThreshold.Store(factor)
memTotal := memory.ServerMemoryLimit.Load()
threshold := float64(memTotal) * factor
Expand Down

0 comments on commit cc2a038

Please sign in to comment.