From 6921a1348e93c36b9974a7190edefe36bd80660b Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Tue, 1 Nov 2022 00:43:00 +0800 Subject: [PATCH] sessionctx: fix TiDBGOGCTunerThreshold failing to ParseFloat Signed-off-by: Weizhen Wang --- sessionctx/variable/sysvar.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 6e156f3aed68a..0e82a45a3d967 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -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) @@ -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