This is an automated email from the ASF dual-hosted git repository.

wangbo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new e4a7464fced [Improment]Reset workload group's default value (#43942)
e4a7464fced is described below

commit e4a7464fced94d34dbf56e4c1bd41a7210f0a2e8
Author: wangbo <wan...@selectdb.com>
AuthorDate: Mon Nov 18 15:29:39 2024 +0800

    [Improment]Reset workload group's default value (#43942)
    
    1 set  cpu_share and memory_limit's default value to -1.
    2 unify error message when workload group's value is invalid.
---
 be/src/runtime/workload_group/workload_group.cpp   |  12 +-
 .../resource/workloadgroup/WorkloadGroup.java      | 223 +++++++++++----------
 .../resource/workloadgroup/WorkloadGroupMgr.java   |  12 +-
 .../resource/workloadgroup/WorkloadGroupTest.java  |   4 +-
 .../data/workload_manager_p0/test_curd_wlg.out     |  26 ++-
 .../workload_manager_p0/test_curd_wlg.groovy       | 107 +++++++---
 6 files changed, 229 insertions(+), 155 deletions(-)

diff --git a/be/src/runtime/workload_group/workload_group.cpp 
b/be/src/runtime/workload_group/workload_group.cpp
index f62179273cf..4a98a4fa8d8 100644
--- a/be/src/runtime/workload_group/workload_group.cpp
+++ b/be/src/runtime/workload_group/workload_group.cpp
@@ -345,19 +345,19 @@ WorkloadGroupInfo WorkloadGroupInfo::parse_topic_info(
 
     // 4 cpu_share
     uint64_t cpu_share = CgroupCpuCtl::cpu_soft_limit_default_value();
-    if (tworkload_group_info.__isset.cpu_share) {
+    if (tworkload_group_info.__isset.cpu_share && 
tworkload_group_info.cpu_share > 0) {
         cpu_share = tworkload_group_info.cpu_share;
     }
 
     // 5 cpu hard limit
     int cpu_hard_limit = CPU_HARD_LIMIT_DEFAULT_VALUE;
-    if (tworkload_group_info.__isset.cpu_hard_limit) {
+    if (tworkload_group_info.__isset.cpu_hard_limit && 
tworkload_group_info.cpu_hard_limit > 0) {
         cpu_hard_limit = tworkload_group_info.cpu_hard_limit;
     }
 
     // 6 mem_limit
     std::string mem_limit_str = MEMORY_LIMIT_DEFAULT_VALUE;
-    if (tworkload_group_info.__isset.mem_limit) {
+    if (tworkload_group_info.__isset.mem_limit && 
tworkload_group_info.mem_limit != "-1") {
         mem_limit_str = tworkload_group_info.mem_limit;
     }
     bool is_percent = true;
@@ -410,13 +410,15 @@ WorkloadGroupInfo WorkloadGroupInfo::parse_topic_info(
 
     // 14 scan io
     int read_bytes_per_second = -1;
-    if (tworkload_group_info.__isset.read_bytes_per_second) {
+    if (tworkload_group_info.__isset.read_bytes_per_second &&
+        tworkload_group_info.read_bytes_per_second > 0) {
         read_bytes_per_second = tworkload_group_info.read_bytes_per_second;
     }
 
     // 15 remote scan io
     int remote_read_bytes_per_second = -1;
-    if (tworkload_group_info.__isset.remote_read_bytes_per_second) {
+    if (tworkload_group_info.__isset.remote_read_bytes_per_second &&
+        tworkload_group_info.remote_read_bytes_per_second > 0) {
         remote_read_bytes_per_second = 
tworkload_group_info.remote_read_bytes_per_second;
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroup.java
 
b/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroup.java
index 7d5e792ef71..0d5df7ef1cb 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroup.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroup.java
@@ -35,6 +35,7 @@ import org.apache.doris.thrift.TopicInfo;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
 import com.google.gson.annotations.SerializedName;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
@@ -105,6 +106,26 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
     public static final int SPILL_LOW_WATERMARK_DEFAULT_VALUE = 50;
     public static final int SPILL_HIGH_WATERMARK_DEFAULT_VALUE = 80;
 
+    private static final Map<String, String> ALL_PROPERTIES_DEFAULT_VALUE_MAP 
= Maps.newHashMap();
+
+    static {
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(CPU_SHARE, "-1");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(CPU_HARD_LIMIT, "-1");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(MEMORY_LIMIT, "-1");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(ENABLE_MEMORY_OVERCOMMIT, "true");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(MAX_CONCURRENCY, 
String.valueOf(Integer.MAX_VALUE));
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(MAX_QUEUE_SIZE, "0");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(QUEUE_TIMEOUT, "0");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(SCAN_THREAD_NUM, "-1");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(MAX_REMOTE_SCAN_THREAD_NUM, "-1");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(MIN_REMOTE_SCAN_THREAD_NUM, "-1");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(SPILL_THRESHOLD_LOW_WATERMARK, 
"50%");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(SPILL_THRESHOLD_HIGH_WATERMARK, 
"80%");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(TAG, "");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(READ_BYTES_PER_SECOND, "-1");
+        ALL_PROPERTIES_DEFAULT_VALUE_MAP.put(REMOTE_READ_BYTES_PER_SECOND, 
"-1");
+    }
+
     @SerializedName(value = "id")
     private long id;
 
@@ -135,9 +156,7 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
         this.properties = properties;
         this.version = version;
         if (properties.containsKey(MEMORY_LIMIT)) {
-            String memoryLimitString = properties.get(MEMORY_LIMIT);
-            this.memoryLimitPercent = Double.parseDouble(
-                    memoryLimitString.substring(0, memoryLimitString.length() 
- 1));
+            setMemLimitPercent(properties);
         }
         if (properties.containsKey(ENABLE_MEMORY_OVERCOMMIT)) {
             properties.put(ENABLE_MEMORY_OVERCOMMIT, 
properties.get(ENABLE_MEMORY_OVERCOMMIT).toLowerCase());
@@ -221,15 +240,22 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
         }
 
         if (properties.containsKey(CPU_SHARE)) {
-            String cpuShare = properties.get(CPU_SHARE);
-            if (!StringUtils.isNumeric(cpuShare) || Long.parseLong(cpuShare) 
<= 0) {
-                throw new DdlException(CPU_SHARE + " " + cpuShare + " requires 
a positive integer.");
+            String inputValue = properties.get(CPU_SHARE);
+            try {
+                int cpuShareI = Integer.parseInt(inputValue);
+                if (cpuShareI <= 0 && cpuShareI != -1) {
+                    throw new NumberFormatException();
+                }
+            } catch (NumberFormatException e) {
+                throw new DdlException(
+                        "The allowed " + CPU_SHARE + " value is -1 or a 
positive integer, but input value is "
+                                + inputValue);
             }
         }
 
         if (properties.containsKey(CPU_HARD_LIMIT)) {
-            String cpuHardLimit = properties.get(CPU_HARD_LIMIT);
-            String originValue = cpuHardLimit;
+            String inputValue = properties.get(CPU_HARD_LIMIT);
+            String cpuHardLimit = inputValue;
             try {
                 boolean endWithSign = false;
                 if (cpuHardLimit.endsWith("%")) {
@@ -246,33 +272,39 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
                 }
             } catch (NumberFormatException e) {
                 throw new DdlException(
-                        "workload group's " + WorkloadGroup.CPU_HARD_LIMIT
-                                + "  must be a positive integer[1,100] or -1, 
but input value is " + originValue);
+                        "The allowed " + WorkloadGroup.CPU_HARD_LIMIT
+                                + " value is -1 or a positive integer between 
1 and 100, but input value is "
+                                + inputValue);
             }
         }
 
         if (properties.containsKey(MEMORY_LIMIT)) {
-            String memoryLimit = properties.get(MEMORY_LIMIT);
-            if (!memoryLimit.endsWith("%")) {
-                throw new DdlException(MEMORY_LIMIT + " " + memoryLimit + " 
requires a percentage and ends with a '%'");
+            String memoryLimitStr = properties.get(MEMORY_LIMIT);
+            if (!memoryLimitStr.endsWith("%") && !"-1".equals(memoryLimitStr)) 
{
+                throw new DdlException(
+                        MEMORY_LIMIT + " requires a percentage value which 
ends with a '%' or -1, but input value is "
+                                + memoryLimitStr);
             }
-            String memLimitErr = MEMORY_LIMIT + " " + memoryLimit + " requires 
a positive floating point number.";
-            try {
-                if (Double.parseDouble(memoryLimit.substring(0, 
memoryLimit.length() - 1)) <= 0) {
-                    throw new DdlException(memLimitErr);
-                }
-            } catch (NumberFormatException e) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug(memLimitErr, e);
+            if (!"-1".equals(memoryLimitStr)) {
+                try {
+                    double memLimitD = 
Double.parseDouble(memoryLimitStr.substring(0, memoryLimitStr.length() - 1));
+                    if (memLimitD <= 0) {
+                        throw new NumberFormatException();
+                    }
+                } catch (NumberFormatException e) {
+                    throw new DdlException("The allowed " + MEMORY_LIMIT
+                            + " value is a positive floating point number, but 
input value is " + memoryLimitStr);
                 }
-                throw new DdlException(memLimitErr);
             }
         }
 
         if (properties.containsKey(ENABLE_MEMORY_OVERCOMMIT)) {
-            String value = 
properties.get(ENABLE_MEMORY_OVERCOMMIT).toLowerCase();
+            String inputValue = properties.get(ENABLE_MEMORY_OVERCOMMIT);
+            String value = inputValue.toLowerCase();
             if (!("true".equals(value) || "false".equals(value))) {
-                throw new DdlException("The value of '" + 
ENABLE_MEMORY_OVERCOMMIT + "' must be true or false.");
+                throw new DdlException(
+                        "The value of '" + ENABLE_MEMORY_OVERCOMMIT + "' must 
be true or false. but input value is "
+                                + inputValue);
             }
         }
 
@@ -285,7 +317,8 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
                 }
             } catch (NumberFormatException e) {
                 throw new DdlException(
-                        SCAN_THREAD_NUM + " must be a positive integer or -1. 
but input value is " + value);
+                        "The allowed " + SCAN_THREAD_NUM + " value is -1 or a 
positive integer. but input value is "
+                                + value);
             }
         }
 
@@ -300,7 +333,8 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
                 maxRemoteScanNum = intValue;
             } catch (NumberFormatException e) {
                 throw new DdlException(
-                        MAX_REMOTE_SCAN_THREAD_NUM + " must be a positive 
integer or -1. but input value is " + value);
+                        "The allowed " + MAX_REMOTE_SCAN_THREAD_NUM
+                                + " value is -1 or a positive integer. but 
input value is " + value);
             }
         }
 
@@ -315,7 +349,8 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
                 minRemoteScanNum = intValue;
             } catch (NumberFormatException e) {
                 throw new DdlException(
-                        MIN_REMOTE_SCAN_THREAD_NUM + " must be a positive 
integer or -1. but input value is " + value);
+                        "The allowed " + MIN_REMOTE_SCAN_THREAD_NUM
+                                + " value is -1 or a positive integer. but 
input value is " + value);
             }
         }
 
@@ -328,30 +363,42 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
 
         // check queue property
         if (properties.containsKey(MAX_CONCURRENCY)) {
+            String inputValue = properties.get(MAX_CONCURRENCY);
             try {
-                if (Integer.parseInt(properties.get(MAX_CONCURRENCY)) < 0) {
-                    throw new DdlException(MAX_CONCURRENCY + " requires a 
positive integer");
+                if (Integer.parseInt(inputValue) < 0) {
+                    throw new NumberFormatException();
                 }
             } catch (NumberFormatException e) {
-                throw new DdlException(MAX_CONCURRENCY + " requires a positive 
integer");
+                throw new DdlException(
+                        "The allowed " + MAX_CONCURRENCY
+                                + " value is an integer greater than or equal 
to 0, but input value is "
+                                + inputValue);
             }
         }
         if (properties.containsKey(MAX_QUEUE_SIZE)) {
+            String inputValue = properties.get(MAX_QUEUE_SIZE);
             try {
-                if (Integer.parseInt(properties.get(MAX_QUEUE_SIZE)) < 0) {
-                    throw new DdlException(MAX_QUEUE_SIZE + " requires a 
positive integer");
+                if (Integer.parseInt(inputValue) < 0) {
+                    throw new NumberFormatException();
                 }
             } catch (NumberFormatException e) {
-                throw new DdlException(MAX_QUEUE_SIZE + " requires a positive 
integer");
+                throw new DdlException(
+                        "The allowed " + MAX_QUEUE_SIZE
+                                + " value is an integer greater than or equal 
to 0, but input value is "
+                                + inputValue);
             }
         }
         if (properties.containsKey(QUEUE_TIMEOUT)) {
+            String inputValue = properties.get(QUEUE_TIMEOUT);
             try {
-                if (Integer.parseInt(properties.get(QUEUE_TIMEOUT)) < 0) {
-                    throw new DdlException(QUEUE_TIMEOUT + " requires a 
positive integer");
+                if (Integer.parseInt(inputValue) < 0) {
+                    throw new NumberFormatException();
                 }
             } catch (NumberFormatException e) {
-                throw new DdlException(QUEUE_TIMEOUT + " requires a positive 
integer");
+                throw new DdlException(
+                        "The allowed " + QUEUE_TIMEOUT
+                                + " value is an integer greater than or equal 
to 0, but input value is "
+                                + inputValue);
             }
         }
 
@@ -363,14 +410,14 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
             }
             try {
                 int intValue = Integer.parseInt(lowVal);
-                if ((intValue < 1 || intValue > 100) && intValue != -1) {
+                if ((intValue < 1 || intValue > 100)) {
                     throw new NumberFormatException();
                 }
                 lowWaterMark = intValue;
             } catch (NumberFormatException e) {
                 throw new DdlException(
-                        SPILL_THRESHOLD_LOW_WATERMARK
-                                + " must be a positive integer(1 ~ 100) or -1. 
but input value is "
+                        "The allowed " + SPILL_THRESHOLD_LOW_WATERMARK
+                                + " value is an integer value between 1 and 
100, but input value is "
                                 + lowVal);
             }
         }
@@ -389,7 +436,8 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
                 highWaterMark = intValue;
             } catch (NumberFormatException e) {
                 throw new DdlException(
-                        SPILL_THRESHOLD_HIGH_WATERMARK + " must be a positive 
integer(1 ~ 100). but input value is "
+                        "The allowed " + SPILL_THRESHOLD_HIGH_WATERMARK
+                                + " value is an integer value between 1 and 
100, but input value is "
                                 + highVal);
             }
         }
@@ -403,13 +451,13 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
             String readBytesVal = properties.get(READ_BYTES_PER_SECOND);
             try {
                 long longVal = Long.parseLong(readBytesVal);
-                boolean isValidValue = longVal == -1 || longVal > 0;
-                if (!isValidValue) {
+                if (longVal <= 0 && longVal != -1) {
                     throw new NumberFormatException();
                 }
             } catch (NumberFormatException e) {
                 throw new DdlException(
-                        READ_BYTES_PER_SECOND + " should be -1 or an integer 
value bigger than 0, but input value is "
+                        "The allowed " + READ_BYTES_PER_SECOND
+                                + " value should be -1 or an positive integer, 
but input value is "
                                 + readBytesVal);
             }
         }
@@ -418,13 +466,12 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
             String readBytesVal = properties.get(REMOTE_READ_BYTES_PER_SECOND);
             try {
                 long longVal = Long.parseLong(readBytesVal);
-                boolean isValidValue = longVal == -1 || longVal > 0;
-                if (!isValidValue) {
+                if (longVal <= 0 && longVal != -1) {
                     throw new NumberFormatException();
                 }
             } catch (NumberFormatException e) {
-                throw new DdlException(REMOTE_READ_BYTES_PER_SECOND
-                        + " should be -1 or an integer value bigger than 0, 
but input value is " + readBytesVal);
+                throw new DdlException("The allowed " + 
REMOTE_READ_BYTES_PER_SECOND
+                        + " value should be -1 or an positive integer, but 
input value is " + readBytesVal);
             }
         }
 
@@ -476,10 +523,6 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
         return version;
     }
 
-    public double getMemoryLimitPercent() {
-        return memoryLimitPercent;
-    }
-
     public int getMaxConcurrency() {
         return maxConcurrency;
     }
@@ -500,70 +543,36 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
         // skip id,name,running query,waiting query
         for (int i = 2; i < 
WorkloadGroupMgr.WORKLOAD_GROUP_PROC_NODE_TITLE_NAMES.size(); i++) {
             String key = 
WorkloadGroupMgr.WORKLOAD_GROUP_PROC_NODE_TITLE_NAMES.get(i);
-            if (CPU_HARD_LIMIT.equals(key)) {
-                String val = properties.get(key);
-                if (StringUtils.isEmpty(val)) { // cpu_hard_limit is not 
required
-                    row.add("-1");
-                } else if ("-1".equals(val)) {
-                    row.add(val);
-                } else {
-                    row.add(val + "%");
-                }
-            } else if (CPU_SHARE.equals(key) && !properties.containsKey(key)) {
-                row.add("-1");
-            } else if (MEMORY_LIMIT.equals(key) && 
!properties.containsKey(key)) {
-                row.add("0%");
-            } else if (ENABLE_MEMORY_OVERCOMMIT.equals(key) && 
!properties.containsKey(key)) {
-                row.add("true");
-            } else if (SCAN_THREAD_NUM.equals(key) && 
!properties.containsKey(key)) {
-                row.add("-1");
-            } else if (MAX_REMOTE_SCAN_THREAD_NUM.equals(key) && 
!properties.containsKey(key)) {
-                row.add("-1");
-            } else if (MIN_REMOTE_SCAN_THREAD_NUM.equals(key) && 
!properties.containsKey(key)) {
-                row.add("-1");
-            } else if (SPILL_THRESHOLD_LOW_WATERMARK.equals(key)) {
-                String val = properties.get(key);
-                if (StringUtils.isEmpty(val)) {
-                    row.add(SPILL_LOW_WATERMARK_DEFAULT_VALUE + "%");
-                } else if ("-1".equals(val)) {
-                    row.add("-1");
-                } else {
-                    row.add(val + "%");
-                }
-            } else if (SPILL_THRESHOLD_HIGH_WATERMARK.equals(key)) {
-                String val = properties.get(key);
-                if (StringUtils.isEmpty(val)) {
-                    row.add(SPILL_HIGH_WATERMARK_DEFAULT_VALUE + "%");
-                } else {
-                    row.add(val + "%");
-                }
-            } else if (QueryQueue.RUNNING_QUERY_NUM.equals(key)) {
+            if (QueryQueue.RUNNING_QUERY_NUM.equals(key)) {
                 row.add(queryQueueDetail == null ? "0" : 
String.valueOf(queryQueueDetail.first));
             } else if (QueryQueue.WAITING_QUERY_NUM.equals(key)) {
                 row.add(queryQueueDetail == null ? "0" : 
String.valueOf(queryQueueDetail.second));
-            } else if (TAG.equals(key)) {
-                String val = properties.get(key);
-                if (StringUtils.isEmpty(val)) {
-                    row.add("");
-                } else {
-                    row.add(val);
-                }
-            } else if (READ_BYTES_PER_SECOND.equals(key) || 
REMOTE_READ_BYTES_PER_SECOND.equals(key)) {
+            } else {
                 String val = properties.get(key);
                 if (StringUtils.isEmpty(val)) {
-                    row.add("-1");
+                    row.add(ALL_PROPERTIES_DEFAULT_VALUE_MAP.get(key));
+                } else if ((CPU_HARD_LIMIT.equals(key) && !"-1".equals(val))
+                        || SPILL_THRESHOLD_LOW_WATERMARK.equals(key)
+                        || SPILL_THRESHOLD_HIGH_WATERMARK.equals(key)) {
+                    row.add(val + "%");
                 } else {
                     row.add(val);
                 }
-            } else {
-                row.add(properties.get(key));
             }
         }
         result.addRow(row);
     }
 
-    public int getCpuHardLimit() {
-        return cpuHardLimit;
+    public int getCpuHardLimitWhenCalSum() {
+        return cpuHardLimit == -1 ? 0 : cpuHardLimit;
+    }
+
+    public double getMemoryLimitPercentWhenCalSum() {
+        return memoryLimitPercent == -1 ? 0 : memoryLimitPercent;
+    }
+
+    public double getMemoryLimitPercent() {
+        return memoryLimitPercent;
     }
 
     public Optional<Set<String>> getTag() {
@@ -684,12 +693,16 @@ public class WorkloadGroup implements Writable, 
GsonPostProcessable {
         return GsonUtils.GSON.fromJson(json, WorkloadGroup.class);
     }
 
+    void setMemLimitPercent(Map<String, String> props) {
+        String memoryLimitString = props.get(MEMORY_LIMIT);
+        this.memoryLimitPercent = "-1".equals(memoryLimitString) ? -1
+                : Double.parseDouble(memoryLimitString.substring(0, 
memoryLimitString.length() - 1));
+    }
+
     @Override
     public void gsonPostProcess() throws IOException {
         if (properties.containsKey(MEMORY_LIMIT)) {
-            String memoryLimitString = properties.get(MEMORY_LIMIT);
-            this.memoryLimitPercent = 
Double.parseDouble(memoryLimitString.substring(0,
-                    memoryLimitString.length() - 1));
+            setMemLimitPercent(properties);
         }
 
         if (properties.containsKey(CPU_HARD_LIMIT)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroupMgr.java
 
b/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroupMgr.java
index 26798bb1ec3..31da477912d 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroupMgr.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroupMgr.java
@@ -434,17 +434,17 @@ public class WorkloadGroupMgr extends MasterDaemon 
implements Writable, GsonPost
                     continue;
                 }
 
-                if (wg.getCpuHardLimit() > 0) {
-                    sumOfAllCpuHardLimit += wg.getCpuHardLimit();
+                if (wg.getCpuHardLimitWhenCalSum() > 0) {
+                    sumOfAllCpuHardLimit += wg.getCpuHardLimitWhenCalSum();
                 }
-                if (wg.getMemoryLimitPercent() > 0) {
-                    sumOfAllMemLimit += wg.getMemoryLimitPercent();
+                if (wg.getMemoryLimitPercentWhenCalSum() > 0) {
+                    sumOfAllMemLimit += wg.getMemoryLimitPercentWhenCalSum();
                 }
             }
 
             // 2 sum current wg value
-            sumOfAllMemLimit += newWg.getMemoryLimitPercent();
-            sumOfAllCpuHardLimit += newWg.getCpuHardLimit();
+            sumOfAllMemLimit += newWg.getMemoryLimitPercentWhenCalSum();
+            sumOfAllCpuHardLimit += newWg.getCpuHardLimitWhenCalSum();
 
             // 3 check total sum
             if (sumOfAllMemLimit > 100.0 + 1e-6) {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/resource/workloadgroup/WorkloadGroupTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/resource/workloadgroup/WorkloadGroupTest.java
index f99fd4f3526..121f46fe75b 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/resource/workloadgroup/WorkloadGroupTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/resource/workloadgroup/WorkloadGroupTest.java
@@ -62,7 +62,7 @@ public class WorkloadGroupTest {
             WorkloadGroup.create(name1, properties1);
             Assert.fail();
         } catch (DdlException e) {
-            Assert.assertTrue(e.getMessage().contains("requires a positive 
integer."));
+            Assert.assertTrue(e.getMessage().contains("value is -1 or a 
positive integer"));
         }
 
         properties1.put(WorkloadGroup.CPU_SHARE, "cpu");
@@ -70,7 +70,7 @@ public class WorkloadGroupTest {
             WorkloadGroup.create(name1, properties1);
             Assert.fail();
         } catch (DdlException e) {
-            Assert.assertTrue(e.getMessage().contains("requires a positive 
integer."));
+            Assert.assertTrue(e.getMessage().contains("value is -1 or a 
positive integer"));
         }
     }
 
diff --git a/regression-test/data/workload_manager_p0/test_curd_wlg.out 
b/regression-test/data/workload_manager_p0/test_curd_wlg.out
index 0914cd53ea4..aa922615dfe 100644
--- a/regression-test/data/workload_manager_p0/test_curd_wlg.out
+++ b/regression-test/data/workload_manager_p0/test_curd_wlg.out
@@ -11,7 +11,7 @@ test_group    10      10%     true    2147483647      0       
0       -1      -1              -1      -1
 
 -- !show_del_wg_1 --
 normal 20      50%     true    2147483647      0       0       1%      16      
-test_drop_wg   10      0%      true    2147483647      0       0       -1      
-1      
+test_drop_wg   10      -1      true    2147483647      0       0       -1      
-1      
 test_group     10      10%     true    2147483647      0       0       -1      
-1      
 
 -- !show_del_wg_2 --
@@ -54,24 +54,21 @@ normal      20      50%     true    2147483647      0       
0       1%      16
 test_group     10      11%     false   100     0       0       20%     -1
 
 -- !show_spill_1 --
-spill_group_test       -1      0%      true    2147483647      0       0       
-1      -1      10%     10%
-
--- !show_spill_1 --
-spill_group_test       -1      0%      true    2147483647      0       0       
-1      -1      -1      10%
+spill_group_test       -1      -1      true    2147483647      0       0       
-1      -1      10%     10%
 
 -- !show_spill_2 --
-spill_group_test       -1      0%      true    2147483647      0       0       
-1      -1      5%      10%
+spill_group_test       -1      -1      true    2147483647      0       0       
-1      -1      5%      10%
 
 -- !show_spill_3 --
-spill_group_test       -1      0%      true    2147483647      0       0       
-1      -1      5%      40%
+spill_group_test       -1      -1      true    2147483647      0       0       
-1      -1      5%      40%
 
 -- !show_wg_tag --
 tag1_mem_wg1   50%     -1      mem_tag1
 tag1_mem_wg2   49%     -1      mem_tag1
 tag1_mem_wg3   1%      -1      mem_tag1
-tag1_wg1       0%      10%     tag1
-tag1_wg2       0%      10%     tag1
-tag1_wg3       0%      80%     tag1
+tag1_wg1       -1      10%     tag1
+tag1_wg2       -1      10%     tag1
+tag1_wg3       -1      80%     tag1
 
 -- !select_remote_scan_num --
 20     10
@@ -146,3 +143,12 @@ test_wg_priv_role1 test_wg_priv_g1 Usage_priv      NO
 
 -- !select_wgp_12 --
 
+-- !select_default_val_wg_1 --
+default_val_wg -1      -1      true    2147483647      0       0       -1      
-1      -1      -1      50%     80%             -1      -1
+
+-- !select_default_val_wg_2 --
+default_val_wg 1024    1%      true    100     1       123     1%      1       
12      10      50%     80%     abc     123     10
+
+-- !select_default_val_wg_3 --
+default_val_wg -1      -1      true    2147483647      0       0       -1      
-1      -1      -1      50%     80%             -1      -1
+
diff --git a/regression-test/suites/workload_manager_p0/test_curd_wlg.groovy 
b/regression-test/suites/workload_manager_p0/test_curd_wlg.groovy
index 7807578ea81..8eb6b7d92a7 100644
--- a/regression-test/suites/workload_manager_p0/test_curd_wlg.groovy
+++ b/regression-test/suites/workload_manager_p0/test_curd_wlg.groovy
@@ -31,6 +31,7 @@ suite("test_crud_wlg") {
     sql "drop workload group if exists tag1_mem_wg1;"
     sql "drop workload group if exists tag1_mem_wg2;"
     sql "drop workload group if exists tag1_mem_wg3;"
+    sql "drop workload group if exists tag1_mem_wg4;"
     sql "drop workload group if exists bypass_group;"
 
     sql """
@@ -109,13 +110,13 @@ suite("test_crud_wlg") {
     test {
         sql "alter workload group normal properties ( 'cpu_share'='-2' );"
 
-        exception "requires a positive integer"
+        exception "The allowed cpu_share value is -1 or a positive integer"
     }
 
     test {
         sql "alter workload group normal properties ( 'scan_thread_num'='0' );"
 
-        exception "scan_thread_num must be a positive integer or -1"
+        exception "The allowed scan_thread_num value is -1 or a positive 
integer"
     }
 
     sql "drop workload group if exists test_group;"
@@ -165,7 +166,7 @@ suite("test_crud_wlg") {
     test {
         sql "alter workload group test_group properties ( 
'cpu_hard_limit'='101%' );"
 
-        exception "must be a positive integer"
+        exception "The allowed cpu_hard_limit value is -1 or a positive 
integer"
     }
 
     sql "alter workload group test_group properties ( 'cpu_hard_limit'='99%' 
);"
@@ -208,39 +209,39 @@ suite("test_crud_wlg") {
     test {
         sql "alter workload group test_group properties ( 
'max_concurrency'='-1' );"
 
-        exception "requires a positive integer"
+        exception "The allowed max_concurrency value is an integer greater 
than or equal to 0"
     }
 
     test {
         sql "alter workload group test_group properties ( 
'max_queue_size'='-1' );"
 
-        exception "requires a positive integer"
+        exception "The allowed max_queue_size value is an integer greater than 
or equal to 0"
     }
 
     test {
         sql "alter workload group test_group properties ( 'queue_timeout'='-1' 
);"
 
-        exception "requires a positive integer"
+        exception "The allowed queue_timeout value is an integer greater than 
or equal to 0"
     }
 
     test {
         sql "alter workload group test_group 
properties('read_bytes_per_second'='0')"
-        exception "an integer value bigger than"
+        exception "The allowed read_bytes_per_second value should be -1 or an 
positive integer"
     }
 
     test {
         sql "alter workload group test_group 
properties('read_bytes_per_second'='-2')"
-        exception "an integer value bigger than"
+        exception "The allowed read_bytes_per_second value should be -1 or an 
positive integer"
     }
 
     test {
         sql "alter workload group test_group 
properties('remote_read_bytes_per_second'='0')"
-        exception "an integer value bigger than"
+        exception "The allowed remote_read_bytes_per_second value should be -1 
or an positive integer"
     }
 
     test {
         sql "alter workload group test_group 
properties('remote_read_bytes_per_second'='-2')"
-        exception "an integer value bigger than"
+        exception "The allowed remote_read_bytes_per_second value should be -1 
or an positive integer"
     }
 
     sql "alter workload group test_group properties ( 'max_concurrency'='100' 
);"
@@ -254,12 +255,12 @@ suite("test_crud_wlg") {
     test {
         sql "create workload group if not exists test_group2 " +
                 "properties ( " +
-                "    'cpu_share'='-1', " +
+                "    'cpu_share'='-2', " +
                 "    'memory_limit'='1%', " +
                 "    'enable_memory_overcommit'='true' " +
                 ");"
 
-        exception "requires a positive integer"
+        exception "The allowed cpu_share value is -1 or a positive integer"
     }
 
     // failed for mem_limit
@@ -309,7 +310,7 @@ suite("test_crud_wlg") {
                 " 'cpu_hard_limit'='120%' " +
                 ");"
 
-        exception "must be a positive integer"
+        exception "a positive integer between 1 and 100"
     }
 
     test {
@@ -452,9 +453,6 @@ suite("test_crud_wlg") {
     }
 
     // 2 alter low
-    sql "alter workload group spill_group_test properties ( 
'spill_threshold_low_watermark'='-1' );"
-    qt_show_spill_1 "select 
name,cpu_share,memory_limit,enable_memory_overcommit,max_concurrency,max_queue_size,queue_timeout,cpu_hard_limit,scan_thread_num,spill_threshold_low_watermark,spill_threshold_high_watermark
 from information_schema.workload_groups where name in ('spill_group_test');"
-
     sql "alter workload group spill_group_test properties ( 
'spill_threshold_low_watermark'='5%' );"
     qt_show_spill_2 "select 
name,cpu_share,memory_limit,enable_memory_overcommit,max_concurrency,max_queue_size,queue_timeout,cpu_hard_limit,scan_thread_num,spill_threshold_low_watermark,spill_threshold_high_watermark
 from information_schema.workload_groups where name in ('spill_group_test');"
 
@@ -465,22 +463,22 @@ suite("test_crud_wlg") {
 
     test {
         sql "alter workload group spill_group_test properties ( 
'spill_threshold_low_watermark'='0%' );"
-        exception "must be a positive integer"
+        exception "value is an integer value between 1 and 100"
     }
 
     test {
         sql "alter workload group spill_group_test properties ( 
'spill_threshold_low_watermark'='101%' );"
-        exception "must be a positive integer"
+        exception "value is an integer value between 1 and 100"
     }
 
     test {
         sql "create workload group if not exists spill_group_test2 properties 
(  'spill_threshold_low_watermark'='0%')"
-        exception "must be a positive integer"
+        exception "value is an integer value between 1 and 100"
     }
 
     test {
         sql "create workload group if not exists spill_group_test2 properties 
(  'spill_threshold_low_watermark'='101%')"
-        exception "must be a positive integer"
+        exception "value is an integer value between 1 and 100"
     }
 
     // 3 alter high
@@ -493,22 +491,22 @@ suite("test_crud_wlg") {
 
     test {
         sql "alter workload group spill_group_test properties ( 
'spill_threshold_high_watermark'='0%' );"
-        exception "must be a positive integer"
+        exception "value is an integer value between 1 and 100"
     }
 
     test {
         sql "alter workload group spill_group_test properties ( 
'spill_threshold_high_watermark'='101%' );"
-        exception "must be a positive integer"
+        exception "value is an integer value between 1 and 100"
     }
 
     test {
         sql "create workload group if not exists spill_group_test2 properties 
(  'spill_threshold_high_watermark'='0%')"
-        exception "must be a positive integer"
+        exception "value is an integer value between 1 and 100"
     }
 
     test {
         sql "create workload group if not exists spill_group_test2 properties 
(  'spill_threshold_high_watermark'='101%')"
-        exception "must be a positive integer"
+        exception "value is an integer value between 1 and 100"
     }
 
     sql "drop workload group test_group;"
@@ -523,17 +521,17 @@ suite("test_crud_wlg") {
 
     test {
         sql "create workload group if not exists tag1_wg1 properties (  
'cpu_hard_limit'='101%', 'tag'='tag1')"
-        exception "must be a positive integer"
+        exception "a positive integer between 1 and 100"
     }
 
     test {
         sql "create workload group if not exists tag1_wg1 properties (  
'cpu_hard_limit'='-2%', 'tag'='tag1')"
-        exception "must be a positive integer"
+        exception "a positive integer between 1 and 100"
     }
 
     test {
         sql "create workload group if not exists tag1_wg1 properties (  
'cpu_hard_limit'='-1%', 'tag'='tag1')"
-        exception "must be a positive integer"
+        exception "a positive integer between 1 and 100"
     }
 
     sql "create workload group if not exists tag1_wg1 properties (  
'cpu_hard_limit'='10%', 'tag'='tag1');"
@@ -584,6 +582,14 @@ suite("test_crud_wlg") {
 
     sql "alter workload group tag1_mem_wg3 properties ( 'tag'='mem_tag1' );"
 
+    sql "create workload group tag1_mem_wg4 
properties('memory_limit'='-1','tag'='mem_tag1');"
+
+    test {
+        sql "alter workload group tag1_mem_wg4 properties ( 
'memory_limit'='1%' );"
+        exception "cannot be greater than 100.0%"
+    }
+
+
     qt_show_wg_tag "select name,MEMORY_LIMIT,CPU_HARD_LIMIT,TAG from 
information_schema.workload_groups where name 
in('tag1_wg1','tag1_wg2','tag2_wg1','tag1_wg3','tag1_mem_wg1','tag1_mem_wg2','tag1_mem_wg3')
 order by tag,name;"
 
     // test bypass
@@ -668,6 +674,7 @@ suite("test_crud_wlg") {
     sql "drop workload group tag1_mem_wg1;"
     sql "drop workload group tag1_mem_wg2;"
     sql "drop workload group tag1_mem_wg3;"
+    sql "drop workload group tag1_mem_wg4;"
     sql "drop workload group bypass_group;"
 
     // test workload group privilege table
@@ -734,4 +741,50 @@ suite("test_crud_wlg") {
     qt_select_wgp_12 "select 
GRANTEE,WORKLOAD_GROUP_NAME,PRIVILEGE_TYPE,IS_GRANTABLE from 
information_schema.workload_group_privileges where grantee like 
'%test_wg_priv%' order by 
GRANTEE,WORKLOAD_GROUP_NAME,PRIVILEGE_TYPE,IS_GRANTABLE; "
     sql "drop workload group test_wg_priv_g1"
 
+    // test default value
+    sql "drop workload group if exists default_val_wg"
+    sql "create workload group default_val_wg 
properties('enable_memory_overcommit'='true');"
+    qt_select_default_val_wg_1 "select 
name,cpu_share,memory_limit,enable_memory_overcommit,max_concurrency,max_queue_size,queue_timeout,cpu_hard_limit,scan_thread_num,max_remote_scan_thread_num,min_remote_scan_thread_num,spill_threshold_low_watermark,spill_threshold_high_watermark,tag,read_bytes_per_second,remote_read_bytes_per_second
 from information_schema.workload_groups where name = 'default_val_wg'"
+
+    sql """
+            alter workload group default_val_wg properties(
+                'cpu_share'='1024',
+                'memory_limit'='1%',
+                'enable_memory_overcommit'='true',
+                'max_concurrency'='100',
+                'max_queue_size'='1',
+                'queue_timeout'='123',
+                'cpu_hard_limit'='1%',
+                'scan_thread_num'='1',
+                'max_remote_scan_thread_num'='12',
+                'min_remote_scan_thread_num'='10',
+                'tag'='abc',
+                'read_bytes_per_second'='123',
+                'remote_read_bytes_per_second'='10');
+    """
+
+    qt_select_default_val_wg_2 "select 
name,cpu_share,memory_limit,enable_memory_overcommit,max_concurrency,max_queue_size,queue_timeout,cpu_hard_limit,scan_thread_num,max_remote_scan_thread_num,min_remote_scan_thread_num,spill_threshold_low_watermark,spill_threshold_high_watermark,tag,read_bytes_per_second,remote_read_bytes_per_second
 from information_schema.workload_groups where name = 'default_val_wg'"
+
+    sql """
+       alter workload group default_val_wg properties(
+        'cpu_share'='-1',
+        'memory_limit'='-1',
+        'enable_memory_overcommit'='true',
+        'max_concurrency'='2147483647',
+        'max_queue_size'='0',
+        'queue_timeout'='0',
+        'cpu_hard_limit'='-1',
+        'scan_thread_num'='-1',
+        'max_remote_scan_thread_num'='-1',
+        'min_remote_scan_thread_num'='-1',
+        'tag'='',
+        'read_bytes_per_second'='-1',
+        'remote_read_bytes_per_second'='-1'
+        );
+    """
+
+    qt_select_default_val_wg_3 "select 
name,cpu_share,memory_limit,enable_memory_overcommit,max_concurrency,max_queue_size,queue_timeout,cpu_hard_limit,scan_thread_num,max_remote_scan_thread_num,min_remote_scan_thread_num,spill_threshold_low_watermark,spill_threshold_high_watermark,tag,read_bytes_per_second,remote_read_bytes_per_second
 from information_schema.workload_groups where name = 'default_val_wg'"
+
+    sql "drop workload group if exists default_val_wg"
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org


Reply via email to