This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 2f7e0f0b761 Revert "[branch-2.1]downgrade resource tag when there is not queryabl… (#47746) 2f7e0f0b761 is described below commit 2f7e0f0b7616411a822aa20a4a1791a265ce78b4 Author: wangbo <wan...@selectdb.com> AuthorDate: Tue Feb 11 16:51:07 2025 +0800 Revert "[branch-2.1]downgrade resource tag when there is not queryabl… (#47746) revert #45387 --- .../doris/datasource/FederationBackendPolicy.java | 3 - .../org/apache/doris/httpv2/rest/LoadAction.java | 2 - .../java/org/apache/doris/mysql/MysqlProto.java | 3 +- .../org/apache/doris/mysql/privilege/Auth.java | 9 -- .../mysql/privilege/CommonUserProperties.java | 11 --- .../apache/doris/mysql/privilege/UserProperty.java | 22 ----- .../doris/mysql/privilege/UserPropertyMgr.java | 8 -- .../org/apache/doris/planner/OlapScanNode.java | 50 +---------- .../java/org/apache/doris/qe/ConnectContext.java | 8 +- .../java/org/apache/doris/qe/ConnectProcessor.java | 3 +- .../org/apache/doris/system/BeSelectionPolicy.java | 34 ++------ .../apache/doris/planner/ResourceTagQueryTest.java | 12 +-- .../apache/doris/system/SystemInfoServiceTest.java | 23 ----- .../workload_manager_p0/skip_rg_test_table.csv | 2 - .../workload_manager_p0/test_resource_tag.groovy | 99 ---------------------- 15 files changed, 16 insertions(+), 273 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/FederationBackendPolicy.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/FederationBackendPolicy.java index 666d91a5f2e..7a616d224ac 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/FederationBackendPolicy.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/FederationBackendPolicy.java @@ -155,7 +155,6 @@ public class FederationBackendPolicy { public void init(List<String> preLocations) throws UserException { Set<Tag> tags = Sets.newHashSet(); - boolean allowResourceTagDowngrade = false; if (ConnectContext.get() != null && ConnectContext.get().getCurrentUserIdentity() != null) { String qualifiedUser = ConnectContext.get().getCurrentUserIdentity().getQualifiedUser(); // Some request from stream load(eg, mysql load) may not set user info in ConnectContext @@ -165,7 +164,6 @@ public class FederationBackendPolicy { if (tags == UserProperty.INVALID_RESOURCE_TAGS) { throw new UserException("No valid resource tag for user: " + qualifiedUser); } - allowResourceTagDowngrade = Env.getCurrentEnv().getAuth().isAllowResourceTagDowngrade(qualifiedUser); } } else { if (LOG.isDebugEnabled()) { @@ -178,7 +176,6 @@ public class FederationBackendPolicy { .needQueryAvailable() .needLoadAvailable() .addTags(tags) - .setAllowResourceTagDowngrade(allowResourceTagDowngrade) .preferComputeNode(Config.prefer_compute_node_for_external_table) .assignExpectBeNum(Config.min_backend_num_for_external_table) .addPreLocations(preLocations) diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java index 5419d5cbc48..d10a3020a6a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java @@ -381,10 +381,8 @@ public class LoadAction extends RestBaseController { BeSelectionPolicy policy = null; String qualifiedUser = ConnectContext.get().getQualifiedUser(); Set<Tag> userTags = Env.getCurrentEnv().getAuth().getResourceTags(qualifiedUser); - boolean allowResourceTagDowngrade = Env.getCurrentEnv().getAuth().isAllowResourceTagDowngrade(qualifiedUser); policy = new BeSelectionPolicy.Builder() .addTags(userTags) - .setAllowResourceTagDowngrade(allowResourceTagDowngrade) .setEnableRoundRobin(true) .needLoadAvailable().build(); policy.nextRoundRobinIndex = getLastSelectedBackendIndexAndUpdate(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java index 220964c7180..79b5e6ad826 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java @@ -249,8 +249,7 @@ public class MysqlProto { } // set resource tag if has - context.setResourceTags(Env.getCurrentEnv().getAuth().getResourceTags(qualifiedUser), - Env.getCurrentEnv().getAuth().isAllowResourceTagDowngrade(qualifiedUser)); + context.setResourceTags(Env.getCurrentEnv().getAuth().getResourceTags(qualifiedUser)); return true; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java index 9bca8a2a5db..7346daddd7c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java @@ -1123,15 +1123,6 @@ public class Auth implements Writable { } } - public boolean isAllowResourceTagDowngrade(String qualifiedUser) { - readLock(); - try { - return propertyMgr.isAllowResourceTagDowngrade(qualifiedUser); - } finally { - readUnlock(); - } - } - public long getExecMemLimit(String qualifiedUser) { readLock(); try { diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CommonUserProperties.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CommonUserProperties.java index ccf3eac66b6..63365e1280c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CommonUserProperties.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CommonUserProperties.java @@ -67,9 +67,6 @@ public class CommonUserProperties implements Writable { @SerializedName("workloadGroup") private String workloadGroup = WorkloadGroupMgr.DEFAULT_GROUP_NAME; - @SerializedName(value = "ard", alternate = {"AllowResourceTagDowngrade"}) - private boolean allowResourceTagDowngrade = false; - private String[] sqlBlockRulesSplit = {}; long getMaxConn() { @@ -165,14 +162,6 @@ public class CommonUserProperties implements Writable { this.workloadGroup = workloadGroup; } - public void setAllowResourceTagDowngrade(boolean allowResourceTagDowngrade) { - this.allowResourceTagDowngrade = allowResourceTagDowngrade; - } - - public boolean isAllowResourceTagDowngrade() { - return this.allowResourceTagDowngrade; - } - public static CommonUserProperties read(DataInput in) throws IOException { String json = Text.readString(in); CommonUserProperties commonUserProperties = GsonUtils.GSON.fromJson(json, CommonUserProperties.class); 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 3714d9db2eb..2375db0d920 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 @@ -80,8 +80,6 @@ public class UserProperty implements Writable { private static final String PROP_WORKLOAD_GROUP = "default_workload_group"; - public static final String PROP_ALLOW_RESOURCE_TAG_DOWNGRADE = "allow_resource_tag_downgrade"; - // for system user public static final Set<Pattern> ADVANCED_PROPERTIES = Sets.newHashSet(); // for normal user @@ -124,8 +122,6 @@ public class UserProperty implements Writable { ADVANCED_PROPERTIES.add(Pattern.compile("^" + PROP_EXEC_MEM_LIMIT + "$", Pattern.CASE_INSENSITIVE)); ADVANCED_PROPERTIES.add(Pattern.compile("^" + PROP_USER_QUERY_TIMEOUT + "$", Pattern.CASE_INSENSITIVE)); ADVANCED_PROPERTIES.add(Pattern.compile("^" + PROP_USER_INSERT_TIMEOUT + "$", Pattern.CASE_INSENSITIVE)); - ADVANCED_PROPERTIES.add( - Pattern.compile("^" + PROP_ALLOW_RESOURCE_TAG_DOWNGRADE + "$", Pattern.CASE_INSENSITIVE)); COMMON_PROPERTIES.add(Pattern.compile("^" + PROP_QUOTA + ".", Pattern.CASE_INSENSITIVE)); COMMON_PROPERTIES.add(Pattern.compile("^" + PROP_DEFAULT_LOAD_CLUSTER + "$", Pattern.CASE_INSENSITIVE)); @@ -186,10 +182,6 @@ public class UserProperty implements Writable { return Sets.newHashSet(this.commonProperties.getResourceTags()); } - public boolean isAllowResourceTagDowngrade() { - return this.commonProperties.isAllowResourceTagDowngrade(); - } - public long getExecMemLimit() { return commonProperties.getExecMemLimit(); } @@ -210,7 +202,6 @@ public class UserProperty implements Writable { int queryTimeout = this.commonProperties.getQueryTimeout(); int insertTimeout = this.commonProperties.getInsertTimeout(); String workloadGroup = this.commonProperties.getWorkloadGroup(); - boolean allowResourceTagDowngrade = this.commonProperties.isAllowResourceTagDowngrade(); String newDefaultLoadCluster = defaultLoadCluster; Map<String, DppConfig> newDppConfigs = Maps.newHashMap(clusterToDppConfig); @@ -350,15 +341,6 @@ public class UserProperty implements Writable { throw new DdlException("workload group " + value + " not exists"); } workloadGroup = value; - } else if (keyArr[0].equalsIgnoreCase(PROP_ALLOW_RESOURCE_TAG_DOWNGRADE)) { - if (keyArr.length != 1) { - throw new DdlException(PROP_ALLOW_RESOURCE_TAG_DOWNGRADE + " format error"); - } - if (!"true".equalsIgnoreCase(value) && !"false".equalsIgnoreCase(value)) { - throw new DdlException( - "allow_resource_tag_downgrade's value must be true or false"); - } - allowResourceTagDowngrade = Boolean.parseBoolean(value); } else { if (isReplay) { // After using SET PROPERTY to modify the user property, if FE rolls back to a version without @@ -382,7 +364,6 @@ public class UserProperty implements Writable { this.commonProperties.setQueryTimeout(queryTimeout); this.commonProperties.setInsertTimeout(insertTimeout); this.commonProperties.setWorkloadGroup(workloadGroup); - this.commonProperties.setAllowResourceTagDowngrade(allowResourceTagDowngrade); if (newDppConfigs.containsKey(newDefaultLoadCluster)) { defaultLoadCluster = newDefaultLoadCluster; } else { @@ -519,9 +500,6 @@ public class UserProperty implements Writable { result.add(Lists.newArrayList(PROP_WORKLOAD_GROUP, String.valueOf(commonProperties.getWorkloadGroup()))); - result.add(Lists.newArrayList(PROP_ALLOW_RESOURCE_TAG_DOWNGRADE, - String.valueOf(commonProperties.isAllowResourceTagDowngrade()))); - // load cluster if (defaultLoadCluster != null) { result.add(Lists.newArrayList(PROP_DEFAULT_LOAD_CLUSTER, defaultLoadCluster)); diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java index 5480c70f168..c9358734d97 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPropertyMgr.java @@ -146,14 +146,6 @@ public class UserPropertyMgr implements Writable { return tags; } - public boolean isAllowResourceTagDowngrade(String qualifiedUser) { - UserProperty existProperty = propertyMap.get(qualifiedUser); - if (existProperty == null) { - return false; - } - return existProperty.isAllowResourceTagDowngrade(); - } - public Pair<String, DppConfig> getLoadClusterInfo(String qualifiedUser, String cluster) throws DdlException { Pair<String, DppConfig> loadClusterInfo = null; diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java index 994cc1e5d50..5c6b47fec71 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java @@ -857,24 +857,6 @@ public class OlapScanNode extends ScanNode { boolean tabletIsNull = true; boolean collectedStat = false; List<String> errs = Lists.newArrayList(); - - // when resource tag has no alive replica and allowResourceTagDowngrade = true, - // resource tag should be disabled, we should find at least one alive replica - boolean shouldSkipResourceTag = false; - boolean isAllowRgDowngrade = false; - ConnectContext context = ConnectContext.get(); - if (context != null) { - isAllowRgDowngrade = context.isAllowResourceTagDowngrade(); - } - if (needCheckTags && isAllowRgDowngrade && !checkTagHasAvailReplica(allowedTags, replicas)) { - shouldSkipResourceTag = true; - if (ConnectContext.get() != null && LOG.isDebugEnabled()) { - LOG.debug("query {} skip resource tag for table {}.", - DebugUtil.printId(ConnectContext.get().queryId()), - olapTable != null ? olapTable.getId() : -1); - } - } - for (Replica replica : replicas) { Backend backend = Env.getCurrentSystemInfo().getBackend(replica.getBackendId()); if (backend == null || !backend.isAlive()) { @@ -883,7 +865,7 @@ public class OlapScanNode extends ScanNode { replica.getId()); } errs.add("replica " + replica.getId() + "'s backend " + replica.getBackendId() - + " with tag " + backend.getLocationTag() + " does not exist or not alive"); + + " does not exist or not alive"); continue; } if (userSetBackendBlacklist != null && userSetBackendBlacklist.contains(backend.getId())) { @@ -899,8 +881,7 @@ public class OlapScanNode extends ScanNode { if (!backend.isMixNode()) { continue; } - if (!shouldSkipResourceTag && needCheckTags && !allowedTags.isEmpty() && !allowedTags.contains( - backend.getLocationTag())) { + if (needCheckTags && !allowedTags.isEmpty() && !allowedTags.contains(backend.getLocationTag())) { String err = String.format( "Replica on backend %d with tag %s," + " which is not in user's resource tags: %s", backend.getId(), backend.getLocationTag(), allowedTags); @@ -932,10 +913,6 @@ public class OlapScanNode extends ScanNode { } } if (tabletIsNull) { - if (needCheckTags && !isAllowRgDowngrade) { - errs.add("If user specified tag has no queryable replica, " - + "you can set property 'allow_resource_tag_downgrade'='true' to skip resource tag."); - } throw new UserException("tablet " + tabletId + " has no queryable replicas. err: " + Joiner.on(", ").join(errs)); } @@ -955,29 +932,6 @@ public class OlapScanNode extends ScanNode { } } - private boolean checkTagHasAvailReplica(Set<Tag> allowedTags, List<Replica> replicas) { - try { - for (Replica replica : replicas) { - long backendId = replica.getBackendId(); - Backend backend = Env.getCurrentSystemInfo().getBackend(backendId); - - if (backend == null || !backend.isAlive()) { - continue; - } - if (!backend.isMixNode()) { - continue; - } - if (!allowedTags.isEmpty() && allowedTags.contains(backend.getLocationTag())) { - return true; - } - } - return false; - } catch (Throwable t) { - LOG.warn("error happens when check resource tag has avail replica ", t); - return true; - } - } - private boolean isEnableCooldownReplicaAffinity() { ConnectContext connectContext = ConnectContext.get(); if (connectContext != null) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java index d462a4e8eec..99a770a7efa 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java @@ -197,7 +197,6 @@ public class ConnectContext { // the query resources. // If set to false, the system will not restrict query resources. private boolean isResourceTagsSet = false; - private boolean allowResourceTagDowngrade = false; private PlSqlOperation plSqlOperation = null; @@ -1002,14 +1001,9 @@ public class ConnectContext { return resourceTags; } - public boolean isAllowResourceTagDowngrade() { - return allowResourceTagDowngrade; - } - - public void setResourceTags(Set<Tag> resourceTags, boolean allowResourceTagDowngrade) { + public void setResourceTags(Set<Tag> resourceTags) { this.resourceTags = resourceTags; this.isResourceTagsSet = !this.resourceTags.isEmpty(); - this.allowResourceTagDowngrade = allowResourceTagDowngrade; } public void setCurrentConnectedFEIp(String ip) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java index 6e0f07ec3b8..d2b69e3798b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java @@ -687,8 +687,7 @@ public abstract class ConnectProcessor { } // set resource tag - ctx.setResourceTags(Env.getCurrentEnv().getAuth().getResourceTags(ctx.qualifiedUser), - Env.getCurrentEnv().getAuth().isAllowResourceTagDowngrade(ctx.qualifiedUser)); + ctx.setResourceTags(Env.getCurrentEnv().getAuth().getResourceTags(ctx.qualifiedUser)); ctx.setThreadLocalInfo(); StmtExecutor executor = null; diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/BeSelectionPolicy.java b/fe/fe-core/src/main/java/org/apache/doris/system/BeSelectionPolicy.java index dd70589f698..8c823eb75ee 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/system/BeSelectionPolicy.java +++ b/fe/fe-core/src/main/java/org/apache/doris/system/BeSelectionPolicy.java @@ -44,7 +44,6 @@ public class BeSelectionPolicy { public boolean needLoadAvailable = false; // Resource tag. Empty means no need to consider resource tag. public Set<Tag> resourceTags = Sets.newHashSet(); - public boolean allowResourceTagDowngrade = false; // storage medium. null means no need to consider storage medium. public TStorageMedium storageMedium = null; // Check if disk usage reaches limit. false means no need to check. @@ -93,11 +92,6 @@ public class BeSelectionPolicy { return this; } - public Builder setAllowResourceTagDowngrade(boolean allowResourceTagDowngrade) { - policy.allowResourceTagDowngrade = allowResourceTagDowngrade; - return this; - } - public Builder setStorageMedium(TStorageMedium medium) { policy.storageMedium = medium; return this; @@ -143,7 +137,7 @@ public class BeSelectionPolicy { } } - private boolean isMatch(Backend backend, boolean needResourceTagAvail) { + private boolean isMatch(Backend backend) { // Compute node is only used when preferComputeNode is set. if (!preferComputeNode && backend.isComputeNode()) { if (LOG.isDebugEnabled()) { @@ -152,11 +146,10 @@ public class BeSelectionPolicy { return false; } - if (needScheduleAvailable && !backend.isScheduleAvailable() - || needQueryAvailable && !backend.isQueryAvailable() - || needLoadAvailable && !backend.isLoadAvailable() - || (needResourceTagAvail && !resourceTags.isEmpty() && !resourceTags.contains(backend.getLocationTag())) - || storageMedium != null && !backend.hasSpecifiedStorageMedium(storageMedium)) { + if (needScheduleAvailable && !backend.isScheduleAvailable() || needQueryAvailable && !backend.isQueryAvailable() + || needLoadAvailable && !backend.isLoadAvailable() || !resourceTags.isEmpty() && !resourceTags.contains( + backend.getLocationTag()) || storageMedium != null && !backend.hasSpecifiedStorageMedium( + storageMedium)) { if (LOG.isDebugEnabled()) { LOG.debug("Backend [{}] is not match by Other rules, policy: [{}]", backend.getHost(), this); } @@ -183,16 +176,7 @@ public class BeSelectionPolicy { } public List<Backend> getCandidateBackends(ImmutableCollection<Backend> backends) { - boolean needResourceTagAvail = !this.allowResourceTagDowngrade || backends.stream() - .filter(backend -> resourceTags.contains(backend.getLocationTag()) && backend.isAlive()) - .count() != 0; - List<Backend> filterBackends = new ArrayList<>(); - for (Backend be : backends) { - if (this.isMatch(be, needResourceTagAvail)) { - filterBackends.add(be); - } - } - + List<Backend> filterBackends = backends.stream().filter(this::isMatch).collect(Collectors.toList()); List<Backend> preLocationFilterBackends = filterBackends.stream() .filter(iterm -> preferredLocations.contains(iterm.getHost())).collect(Collectors.toList()); // If preLocations were chosen, use the preLocation backends. Otherwise we just ignore this filter. @@ -237,10 +221,8 @@ public class BeSelectionPolicy { @Override public String toString() { - return String.format("computeNode=%s | query=%s | load=%s | schedule=%s | tags=%s |" - + "resource_downgrade=%s | medium=%s", + return String.format("computeNode=%s | query=%s | load=%s | schedule=%s | tags=%s | medium=%s", preferComputeNode, needQueryAvailable, needLoadAvailable, needScheduleAvailable, - resourceTags.stream().map(tag -> tag.toString()).collect(Collectors.joining(",")), - this.allowResourceTagDowngrade, storageMedium); + resourceTags.stream().map(tag -> tag.toString()).collect(Collectors.joining(",")), storageMedium); } } 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 36c7bc577cf..5afe9c3b39b 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 @@ -205,7 +205,7 @@ public class ResourceTagQueryTest { Assert.assertEquals(1, userTags.size()); // update connection context and query - connectContext.setResourceTags(userTags, false); + connectContext.setResourceTags(userTags); String queryStr = "explain select * from test.tbl1"; String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, queryStr); System.out.println(explainString); @@ -221,7 +221,7 @@ public class ResourceTagQueryTest { } // update connection context and query, it will failed because no zone1 backend - connectContext.setResourceTags(userTags, false); + connectContext.setResourceTags(userTags); Assert.assertTrue(connectContext.isResourceTagsSet()); queryStr = "explain select * from test.tbl1"; String error = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, queryStr); @@ -280,13 +280,7 @@ public class ResourceTagQueryTest { Assert.assertEquals(1000000, execMemLimit); List<List<String>> userProps = Env.getCurrentEnv().getAuth().getUserProperties(Auth.ROOT_USER); - Assert.assertEquals(12, userProps.size()); - - // set resource tag downgrade - String setResourceTagDownStr = "set property for 'root' 'allow_resource_tag_downgrade' = 'false';"; - ExceptionChecker.expectThrowsNoException(() -> setProperty(setResourceTagDownStr)); - boolean tagDowngrade = Env.getCurrentEnv().getAuth().isAllowResourceTagDowngrade(Auth.ROOT_USER); - Assert.assertTrue(!tagDowngrade); + Assert.assertEquals(11, userProps.size()); // now : // be1 be2 be3 ==>tag1; diff --git a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java index b6db48e1e69..d14cdd2a865 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java @@ -333,29 +333,6 @@ public class SystemInfoServiceTest { Assert.assertEquals(3, infoService.selectBackendIdsByPolicy(policy07, 3).size()); } - @Test - public void testResourceTagDowngrade() throws Exception { - Tag taga = Tag.create(Tag.TYPE_LOCATION, "taga"); - addBackend(10001, "192.168.1.1", 9050); - Backend be1 = infoService.getBackend(10001); - be1.setTagMap(taga.toMap()); - be1.setAlive(true); - - addBackend(10002, "192.168.1.2", 9050); - Backend be2 = infoService.getBackend(10002); - be2.setAlive(true); - - BeSelectionPolicy policy1 = new BeSelectionPolicy.Builder().addTags(Sets.newHashSet(taga)).build(); - Assert.assertEquals(1, infoService.selectBackendIdsByPolicy(policy1, 1).size()); - - be1.setAlive(false); - Assert.assertEquals(0, infoService.selectBackendIdsByPolicy(policy1, 1).size()); - - BeSelectionPolicy policy2 = new BeSelectionPolicy.Builder().setAllowResourceTagDowngrade(true) - .addTags(Sets.newHashSet(taga)).build(); - Assert.assertEquals(1, infoService.selectBackendIdsByPolicy(policy2, 1).size()); - } - @Test public void testPreferLocationsSelect() throws Exception { Tag taga = Tag.create(Tag.TYPE_LOCATION, "taga"); diff --git a/regression-test/data/workload_manager_p0/skip_rg_test_table.csv b/regression-test/data/workload_manager_p0/skip_rg_test_table.csv deleted file mode 100644 index edcc00b603a..00000000000 --- a/regression-test/data/workload_manager_p0/skip_rg_test_table.csv +++ /dev/null @@ -1,2 +0,0 @@ -1|2 -3|4 \ No newline at end of file diff --git a/regression-test/suites/workload_manager_p0/test_resource_tag.groovy b/regression-test/suites/workload_manager_p0/test_resource_tag.groovy deleted file mode 100644 index fa7ba680143..00000000000 --- a/regression-test/suites/workload_manager_p0/test_resource_tag.groovy +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -suite("test_resource_tag") { - sql "drop user if exists test_rg;" - sql "create user test_rg" - sql "GRANT SELECT_PRIV,LOAD_PRIV,ALTER_PRIV,CREATE_PRIV,DROP_PRIV ON *.*.* TO test_rg;" - sql "set property for test_rg 'resource_tags.location' = 'c3p0';" - //cloud-mode - if (isCloudMode()) { - def clusters = sql " SHOW CLUSTERS; " - assertTrue(!clusters.isEmpty()) - def validCluster = clusters[0][0] - sql """GRANT USAGE_PRIV ON CLUSTER ${validCluster} TO test_rg"""; - } - - // test query - connect('test_rg', '', context.config.jdbcUrl) { - sql "drop table if exists test_skip_rg_bad_replica_tab;" - sql """ - CREATE TABLE test_skip_rg_bad_replica_tab - ( - k1 int, - k2 int, - )ENGINE=OLAP - duplicate KEY(k1) - DISTRIBUTED BY HASH (k1) BUCKETS 1 - PROPERTIES( - 'replication_allocation' = 'tag.location.default: 1' - ); - """ - sql """ - insert into test_skip_rg_bad_replica_tab values - (9,10), - (1,2) - """ - test { - sql "select count(1) as t1 from test_skip_rg_bad_replica_tab;" - exception "which is not in user's resource tags: [{\"location\" : \"c3p0\"}], If user specified tag has no queryable replica, you can set property 'allow_resource_tag_downgrade'='true' to skip resource tag." - } - } - sql "set property for test_rg 'allow_resource_tag_downgrade' = 'true';" - - connect('test_rg', '', context.config.jdbcUrl) { - sql "select count(1) as t2 from test_skip_rg_bad_replica_tab;" - sql "drop table test_skip_rg_bad_replica_tab"; - } - - - // test stream load - sql "set property for test_rg 'allow_resource_tag_downgrade' = 'false';" - sql """ DROP TABLE IF EXISTS ${context.config.defaultDb}.skip_rg_test_table """ - sql """ - CREATE TABLE IF NOT EXISTS ${context.config.defaultDb}.skip_rg_test_table ( - `k1` int NULL, - `k2` int NULL - ) ENGINE=OLAP - DISTRIBUTED BY HASH(`k1`) BUCKETS 1 - PROPERTIES ("replication_allocation" = "tag.location.default: 1"); - """ - - def test_failed_command = "curl --location-trusted -u test_rg: -H column_separator:| -H Transfer-Encoding:chunked -H columns:k1,k2 -T ${context.dataPath}/skip_rg_test_table.csv http://${context.config.feHttpAddress}/api/${context.config.defaultDb}/skip_rg_test_table/_stream_load" - log.info("stream load skip_rg_test_table failed test cmd: ${test_failed_command}") - def process = test_failed_command.execute() - def code1 = process.waitFor() - def out1 = process.text - log.info("stream load skip_rg_test_table failed test result, ${out1}".toString()) - assertTrue("${out1}".toString().contains("No backend load available") || "${out1}".toString().contains("No available backends")) - - sql "set property for test_rg 'allow_resource_tag_downgrade' = 'true';" - - def test_succ_command = "curl --location-trusted -u test_rg: -H column_separator:| -H Transfer-Encoding:chunked -H columns:k1,k2 -T ${context.dataPath}/skip_rg_test_table.csv http://${context.config.feHttpAddress}/api/${context.config.defaultDb}/skip_rg_test_table/_stream_load" - def process2 = test_succ_command.execute() - def code2 = process2.waitFor() - def out2 = process2.text - def jsonRet = parseJson(out2) - log.info("stream load skip_rg_test_table succ test result, ${out2}".toString()) - assertFalse("${out2}".toString().contains("No backend load available")) - assertTrue(jsonRet['Status'] == 'Success') - - - // clear - sql "drop user test_rg" - sql "drop table ${context.config.defaultDb}.skip_rg_test_table" -} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org