Skip to content

Commit 9d8f26f

Browse files
authored
sessionctx: fix null max value to leading wrong warning (#57898) (#57934)
close #57889
1 parent f2f8d42 commit 9d8f26f

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
@@ -479,6 +479,12 @@ func TestSetVar(t *testing.T) {
479479
tk.MustExec("set session tidb_dml_batch_size = -120")
480480
tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_dml_batch_size value: '-120'")) // without redaction
481481

482+
tk.MustExec("set global tidb_gogc_tuner_min_value=300")
483+
tk.MustQuery("show warnings").Check(testkit.Rows())
484+
tk.MustExec("set global tidb_gogc_tuner_max_value=600")
485+
tk.MustQuery("show warnings").Check(testkit.Rows())
486+
tk.MustExec("set global tidb_gogc_tuner_max_value=600000000000000000")
487+
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_gogc_tuner_max_value value: '600000000000000000'"))
482488
tk.MustExec("set @@session.tidb_dml_batch_size = 120")
483489
tk.MustExec("set @@global.tidb_dml_batch_size = 200") // now permitted due to TiDB #19809
484490
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
@@ -856,7 +856,7 @@ var defaultSysVars = []*SysVar{
856856
return nil
857857
}},
858858
{Scope: ScopeGlobal, Name: TiDBGOGCTunerMaxValue, Value: strconv.Itoa(DefTiDBGOGCMaxValue),
859-
Type: TypeInt, MinValue: 10, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
859+
Type: TypeInt, MinValue: 10, MaxValue: math.MaxInt32, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
860860
maxValue := TidbOptInt64(val, DefTiDBGOGCMaxValue)
861861
gctuner.SetMaxGCPercent(uint32(maxValue))
862862
gctuner.GlobalMemoryLimitTuner.UpdateMemoryLimit()
@@ -873,7 +873,7 @@ var defaultSysVars = []*SysVar{
873873
return origin, nil
874874
}},
875875
{Scope: ScopeGlobal, Name: TiDBGOGCTunerMinValue, Value: strconv.Itoa(DefTiDBGOGCMinValue),
876-
Type: TypeInt, MinValue: 10, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
876+
Type: TypeInt, MinValue: 10, MaxValue: math.MaxInt32, SetGlobal: func(_ context.Context, s *SessionVars, val string) error {
877877
minValue := TidbOptInt64(val, DefTiDBGOGCMinValue)
878878
gctuner.SetMinGCPercent(uint32(minValue))
879879
gctuner.GlobalMemoryLimitTuner.UpdateMemoryLimit()

0 commit comments

Comments
 (0)