Skip to content

Commit bf9ec52

Browse files
authored
sessionctx: fix null max value to leading wrong warning (#57898) (#57933)
close #57889
1 parent 7723772 commit bf9ec52

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pkg/executor/set_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ func TestSetVar(t *testing.T) {
473473
tk.MustExec("set session tidb_dml_batch_size = -120")
474474
tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_dml_batch_size value: '-120'")) // without redaction
475475

476+
tk.MustExec("set global tidb_gogc_tuner_min_value=300")
477+
tk.MustQuery("show warnings").Check(testkit.Rows())
478+
tk.MustExec("set global tidb_gogc_tuner_max_value=600")
479+
tk.MustQuery("show warnings").Check(testkit.Rows())
480+
tk.MustExec("set global tidb_gogc_tuner_max_value=600000000000000000")
481+
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_gogc_tuner_max_value value: '600000000000000000'"))
476482
tk.MustExec("set @@session.tidb_dml_batch_size = 120")
477483
tk.MustExec("set @@global.tidb_dml_batch_size = 200") // now permitted due to TiDB #19809
478484
tk.MustQuery("select @@tidb_dml_batch_size;").Check(testkit.Rows("120")) // global only applies to new sessions

pkg/sessionctx/variable/sysvar.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ var defaultSysVars = []*SysVar{
830830
return nil
831831
}},
832832
{Scope: ScopeGlobal, Name: TiDBGOGCTunerMaxValue, Value: strconv.Itoa(DefTiDBGOGCMaxValue),
833-
Type: TypeInt, MinValue: 10, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
833+
Type: TypeInt, MinValue: 10, MaxValue: math.MaxInt32, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
834834
maxValue := TidbOptInt64(val, DefTiDBGOGCMaxValue)
835835
gctuner.SetMaxGCPercent(uint32(maxValue))
836836
gctuner.GlobalMemoryLimitTuner.UpdateMemoryLimit()
@@ -847,7 +847,7 @@ var defaultSysVars = []*SysVar{
847847
return origin, nil
848848
}},
849849
{Scope: ScopeGlobal, Name: TiDBGOGCTunerMinValue, Value: strconv.Itoa(DefTiDBGOGCMinValue),
850-
Type: TypeInt, MinValue: 10, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
850+
Type: TypeInt, MinValue: 10, MaxValue: math.MaxInt32, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
851851
minValue := TidbOptInt64(val, DefTiDBGOGCMinValue)
852852
gctuner.SetMinGCPercent(uint32(minValue))
853853
gctuner.GlobalMemoryLimitTuner.UpdateMemoryLimit()

0 commit comments

Comments
 (0)