From d82c138a605dcd13e0fcf8ad18e25ccb232398cf Mon Sep 17 00:00:00 2001 From: Mingyu Chen Date: Tue, 29 Mar 2022 10:03:33 +0800 Subject: [PATCH] [fix](user-property) Fix bug that can not set exec_mem_limit at user level (#8710) --- .../apache/doris/mysql/privilege/UserProperty.java | 8 +++++++- .../apache/doris/planner/ResourceTagQueryTest.java | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java index 45a81be8a4..547257f952 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserProperty.java @@ -329,7 +329,7 @@ public class UserProperty implements Writable { this.commonProperties.setCpuResourceLimit(cpuResourceLimit); this.commonProperties.setResourceTags(resourceTags); this.commonProperties.setExecMemLimit(execMemLimit); - this.commonProperties.setExecMemLimit(loadMemLimit); + this.commonProperties.setLoadMemLimit(loadMemLimit); resource = newResource; if (newDppConfigs.containsKey(newDefaultLoadCluster)) { defaultLoadCluster = newDefaultLoadCluster; @@ -452,6 +452,12 @@ public class UserProperty implements Writable { // cpu resource limit result.add(Lists.newArrayList(PROP_CPU_RESOURCE_LIMIT, String.valueOf(commonProperties.getCpuResourceLimit()))); + // exec mem limit + result.add(Lists.newArrayList(PROP_EXEC_MEM_LIMIT, String.valueOf(commonProperties.getExecMemLimit()))); + + // load mem limit + result.add(Lists.newArrayList(PROP_LOAD_MEM_LIMIT, String.valueOf(commonProperties.getLoadMemLimit()))); + // resource tag result.add(Lists.newArrayList(PROP_RESOURCE_TAGS, Joiner.on(", ").join(commonProperties.getResourceTags()))); diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/ResourceTagQueryTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/ResourceTagQueryTest.java index 8ab9ab72e9..e43c672c93 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/ResourceTagQueryTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/ResourceTagQueryTest.java @@ -271,6 +271,20 @@ public class ResourceTagQueryTest { explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, queryStr); System.out.println(explainString); Assert.assertTrue(explainString.contains("tabletRatio=30/30")); + + // set user exec mem limit + String setExecMemLimitStr = "set property for 'root' 'exec_mem_limit' = '1000000';"; + ExceptionChecker.expectThrowsNoException(() -> setProperty(setExecMemLimitStr)); + long execMemLimit = Catalog.getCurrentCatalog().getAuth().getExecMemLimit(PaloAuth.ROOT_USER); + Assert.assertEquals(1000000, execMemLimit); + + String setLoadMemLimitStr = "set property for 'root' 'load_mem_limit' = '2000000';"; + ExceptionChecker.expectThrowsNoException(() -> setProperty(setLoadMemLimitStr)); + long loadMemLimit = Catalog.getCurrentCatalog().getAuth().getLoadMemLimit(PaloAuth.ROOT_USER); + Assert.assertEquals(2000000, loadMemLimit); + + List> userProps = Catalog.getCurrentCatalog().getAuth().getUserProperties(PaloAuth.ROOT_USER); + Assert.assertEquals(17, userProps.size()); } private void checkTableReplicaAllocation(OlapTable tbl) throws InterruptedException {