Support using B/K/KB/M/MB/G/GB/T/TB/P/PB as unit in session variable exec_mem_limit (#4063)

Support using B/K/KB/M/MB/G/GB/T/TB/P/PB as unit in  session variable exec_mem_limit
This commit is contained in:
Zhengguo Yang
2020-07-13 20:54:14 +08:00
committed by GitHub
parent 2e460f581c
commit 78a1dea19d
3 changed files with 12 additions and 2 deletions

View File

@ -159,7 +159,7 @@ SET forward_to_master = concat('tr', 'u', 'e');
* `exec_mem_limit`
Used to set the memory limit for a single query. The default is 2GB, in bytes.
Used to set the memory limit for a single query. The default is 2GB, you can set it in B/K/KB/M/MB/G/GB/T/TB/P/PB, the default is B.
This parameter is used to limit the memory that can be used by an instance of a single query fragment in a query plan. A query plan may have multiple instances, and a BE node may execute one or more instances. Therefore, this parameter does not accurately limit the memory usage of a query across the cluster, nor does it accurately limit the memory usage of a query on a single BE node. The specific needs need to be judged according to the generated query plan.

View File

@ -159,7 +159,7 @@ SET forward_to_master = concat('tr', 'u', 'e');
* `exec_mem_limit`
用于设置单个查询的内存限制。默认为 2GB,单位为字节
用于设置单个查询的内存限制。默认为 2GB,单位为B/K/KB/M/MB/G/GB/T/TB/P/PB, 默认为B
该参数用于限制一个查询计划中,单个查询计划的实例所能使用的内存。一个查询计划可能有多个实例,一个 BE 节点可能执行一个或多个实例。所以该参数并不能准确限制一个查询在整个集群的内存使用,也不能准确限制一个查询在单一 BE 节点上的内存使用。具体需要根据生成的查询计划判断。

View File

@ -28,6 +28,7 @@ import org.apache.doris.common.DdlException;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.PatternMatcher;
import org.apache.doris.common.util.ParseUtil;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.persist.EditLog;
@ -220,6 +221,15 @@ public class VariableMgr {
setVar.getType(), setVar.getVariable(),
new StringLiteral(TimeUtils.checkTimeZoneValidAndStandardize(setVar.getValue().getStringValue())));
}
if (setVar.getVariable().toLowerCase().equals("exec_mem_limit")) {
try {
setVar = new SetVar(
setVar.getType(), setVar.getVariable(),
new StringLiteral(Long.toString(ParseUtil.analyzeDataVolumn(setVar.getValue().getStringValue()))));
} catch (AnalysisException e) {
throw new DdlException(e.getMessage());
}
}
// To modify to default value.
VarAttr attr = ctx.getField().getAnnotation(VarAttr.class);