diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java index 3d95e69cb673548..1b47dc8bc27b133 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java @@ -1630,7 +1630,7 @@ private static Map rewriteReplicaAllocationProperties( private static Map rewriteReplicaAllocationPropertiesByDatabase( String ctl, String database, Map properties) { - // if table contain `replication_allocation` or `replication_allocation`,not need rewrite by db + // if table contain `replication_allocation` or `replication_num`,not need rewrite by db if (properties != null && (properties.containsKey(PropertyAnalyzer.PROPERTIES_REPLICATION_ALLOCATION) || properties.containsKey(PropertyAnalyzer.PROPERTIES_REPLICATION_NUM))) { return properties; diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java b/fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java index 5398fcc4a00dfaf..815aa983ad81c2c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java @@ -190,10 +190,19 @@ public Backend selectBackendForGroupCommit(long tableId, ConnectContext context) throws LoadException, DdlException { // If a group commit request is sent to the follower FE, we will send this request to the master FE. master FE // can select a BE and return this BE id to follower FE. + String clusterName = ""; + if (Config.isCloudMode()) { + try { + clusterName = context.getCloudCluster(); + } catch (Exception e) { + LOG.warn("failed to get cluster name", e); + throw new LoadException(e.getMessage()); + } + } if (!Env.getCurrentEnv().isMaster()) { try { long backendId = new MasterOpExecutor(context) - .getGroupCommitLoadBeId(tableId, context.getCloudCluster()); + .getGroupCommitLoadBeId(tableId, clusterName); return Env.getCurrentSystemInfo().getBackend(backendId); } catch (Exception e) { throw new LoadException(e.getMessage()); @@ -202,7 +211,7 @@ public Backend selectBackendForGroupCommit(long tableId, ConnectContext context) try { // Master FE will select BE by itself. return Env.getCurrentSystemInfo() - .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster())); + .getBackend(selectBackendForGroupCommitInternal(tableId, clusterName)); } catch (Exception e) { LOG.warn("get backend failed, tableId: {}, exception", tableId, e); throw new LoadException(e.getMessage()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java index 46e9a3602f06a0f..3b878a7593078cf 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java @@ -177,7 +177,9 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme CatalogIf catalog = ctx.getCurrentCatalog(); String cloudCluster = ""; try { - cloudCluster = ctx.getCloudCluster(); + if (Config.isCloudMode()) { + cloudCluster = ctx.getCloudCluster(); + } } catch (ClusterException e) { LOG.warn("Failed to get cloud cluster", e); } @@ -212,7 +214,9 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme MetricRepo.COUNTER_QUERY_ALL.increase(1L); MetricRepo.USER_COUNTER_QUERY_ALL.getOrAdd(ctx.getQualifiedUser()).increase(1L); try { - cloudCluster = ctx.getCloudCluster(false); + if (Config.isCloudMode()) { + cloudCluster = ctx.getCloudCluster(false); + } } catch (ClusterException e) { LOG.warn("Failed to get cloud cluster", e); return; 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 88e00cd908cfc04..6b0a26cce17e854 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 @@ -34,7 +34,6 @@ import org.apache.doris.catalog.FunctionRegistry; import org.apache.doris.catalog.TableIf; import org.apache.doris.catalog.Type; -import org.apache.doris.cloud.proto.Cloud; import org.apache.doris.cloud.qe.ClusterException; import org.apache.doris.cloud.system.CloudSystemInfoService; import org.apache.doris.cluster.ClusterNamespace; @@ -1154,30 +1153,6 @@ public String toString() { } } - public static String cloudNoBackendsReason() throws ClusterException { - StringBuilder sb = new StringBuilder(); - if (ConnectContext.get() != null) { - String clusterName = ConnectContext.get().getCloudCluster(); - String hits = "or you may not have permission to access the current cluster = "; - sb.append(" "); - if (Strings.isNullOrEmpty(clusterName)) { - return sb.append(hits).append("cluster name empty").toString(); - } - String clusterStatus = ((CloudSystemInfoService) Env.getCurrentSystemInfo()) - .getCloudStatusByName(clusterName); - if (!Strings.isNullOrEmpty(clusterStatus) - && Cloud.ClusterStatus.valueOf(clusterStatus) - == Cloud.ClusterStatus.MANUAL_SHUTDOWN) { - LOG.warn("auto start cluster {} in manual shutdown status", clusterName); - sb.append("cluster ").append(clusterName) - .append(" is shutdown manually, please start it first"); - } else { - sb.append(hits).append(clusterName); - } - } - return sb.toString(); - } - // can't get cluster from context, use the following strategy to obtain the cluster name // 当用户有多个集群的权限时,会按照如下策略进行拉取: // 如果当前mysql用户没有指定cluster(没有default 或者 use), 选择有权限的cluster。 @@ -1302,52 +1277,6 @@ public String getDefaultCloudCluster() { return null; } - public String getAuthorizedCloudCluster() throws ClusterException { - List cloudClusterNames = ((CloudSystemInfoService) Env.getCurrentSystemInfo()).getCloudClusterNames(); - // get all available cluster of the user - boolean hasAuthCluster = false; - AtomicBoolean selectedClusterHasAliveBe = new AtomicBoolean(false); - String selectedCluster = null; - for (String cloudClusterName : cloudClusterNames) { - if (!Env.getCurrentEnv().getAuth().checkCloudPriv(getCurrentUserIdentity(), - cloudClusterName, PrivPredicate.USAGE, ResourceTypeEnum.CLUSTER)) { - continue; - } - hasAuthCluster = true; - // find a cluster has more than one alive be - selectedCluster = cloudClusterName; - List bes = ((CloudSystemInfoService) Env.getCurrentSystemInfo()) - .getBackendsByClusterName(cloudClusterName); - - bes.stream().filter(Backend::isAlive).findAny().ifPresent(backend -> { - if (LOG.isDebugEnabled()) { - LOG.debug("get a clusterName {}, it's has more than one alive be {}", cloudClusterName, backend); - } - selectedClusterHasAliveBe.set(true); - }); - if (selectedClusterHasAliveBe.get()) { - if (LOG.isDebugEnabled()) { - LOG.debug("set context cluster name {}", cloudClusterName); - } - return cloudClusterName; - } - } - if (!hasAuthCluster) { - throw new ClusterException("the user is not granted permission to the cluster", - ClusterException.FailedTypeEnum.CURRENT_USER_NO_AUTH_TO_USE_ANY_CLUSTER); - } - - if (!selectedClusterHasAliveBe.get()) { - throw new ClusterException( - String.format("All the Backend nodes in the current cluster %s are in an abnormal state", - selectedCluster), - ClusterException.FailedTypeEnum.CLUSTERS_NO_ALIVE_BE); - } - - throw new ClusterException("There are no clusters registered in the current system", - ClusterException.FailedTypeEnum.SYSTEM_NOT_HAVE_CLUSTER); - } - public StatsErrorEstimator getStatsErrorEstimator() { return statsErrorEstimator; } diff --git a/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HiveDDLAndDMLPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HiveDDLAndDMLPlanTest.java index 9d91ead5d4cccca..02334b6ef91e691 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HiveDDLAndDMLPlanTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HiveDDLAndDMLPlanTest.java @@ -338,8 +338,8 @@ public void testCreateAndDropWithSql() throws Exception { + "PROPERTIES (\n" + " 'location'='hdfs://loc/db/tbl',\n" + " 'file_format'='orc')"; - ExceptionChecker.expectThrowsWithMsg(org.apache.doris.common.UserException.class, - "errCode = 2, detailMessage = errCode = 2," + ExceptionChecker.expectThrowsWithMsg(org.apache.doris.nereids.exceptions.AnalysisException.class, + "errCode = 2," + " detailMessage = Create hive bucket table need set enable_create_hive_bucket_table to true", () -> createTable(createBucketedTableErr, true));