Skip to content

Commit

Permalink
sql: disallow distsql_workmem of less than 2B
Browse files Browse the repository at this point in the history
This commit disallows users to set `distsql_workmem` session variable
(as well as the corresponding cluster setting) to a value lower than 2B.
The rationale is that internally we treat 1B as "force disk spilling"
testing scenario and have some places where the setting is ignored if
it is 1B. Non-positive values don't make sense too. It shouldn't really
be a problem to users since nobody should be setting this value this low.

Release note: None
  • Loading branch information
yuzefovich committed Aug 5, 2022
1 parent 033c911 commit 0999b14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@ var settingWorkMemBytes = settings.RegisterByteSizeSetting(
"sql.distsql.temp_storage.workmem",
"maximum amount of memory in bytes a processor can use before falling back to temp storage",
execinfra.DefaultMemoryLimit, /* 64MiB */
func(v int64) error {
if v <= 1 {
return errors.Errorf("can only be set to a value greater than 1: %d", v)
}
return nil
},
).WithPublic()

// ExperimentalDistSQLPlanningClusterSettingName is the name for the cluster
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ var varGen = map[string]sessionVar{
if err != nil {
return err
}
if limit <= 0 {
return errors.New("distsql_workmem can only be set to a positive value")
if limit <= 1 {
return errors.New("distsql_workmem can only be set to a value greater than 1")
}
m.SetDistSQLWorkMem(limit)
return nil
Expand Down

0 comments on commit 0999b14

Please sign in to comment.