From 78a1dea19d5717eb366e08d1fdbb4315cfe0b806 Mon Sep 17 00:00:00 2001 From: Zhengguo Yang <780531911@qq.com> Date: Mon, 13 Jul 2020 20:54:14 +0800 Subject: [PATCH] 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 --- docs/en/administrator-guide/variables.md | 2 +- docs/zh-CN/administrator-guide/variables.md | 2 +- fe/src/main/java/org/apache/doris/qe/VariableMgr.java | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/en/administrator-guide/variables.md b/docs/en/administrator-guide/variables.md index c5da687f32..5091be45e0 100644 --- a/docs/en/administrator-guide/variables.md +++ b/docs/en/administrator-guide/variables.md @@ -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. diff --git a/docs/zh-CN/administrator-guide/variables.md b/docs/zh-CN/administrator-guide/variables.md index c592fc8c96..3d21575458 100644 --- a/docs/zh-CN/administrator-guide/variables.md +++ b/docs/zh-CN/administrator-guide/variables.md @@ -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 节点上的内存使用。具体需要根据生成的查询计划判断。 diff --git a/fe/src/main/java/org/apache/doris/qe/VariableMgr.java b/fe/src/main/java/org/apache/doris/qe/VariableMgr.java index 26e4d14461..3574ae5cd6 100644 --- a/fe/src/main/java/org/apache/doris/qe/VariableMgr.java +++ b/fe/src/main/java/org/apache/doris/qe/VariableMgr.java @@ -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);