From e66584205e1b126d3862891e5dd190fd61ac481f Mon Sep 17 00:00:00 2001 From: deardeng <565620795@qq.com> Date: Fri, 9 Aug 2024 19:34:44 +0800 Subject: [PATCH] fix ut p0 --- .../doris/common/util/PropertyAnalyzer.java | 2 +- .../apache/doris/load/GroupCommitManager.java | 21 +++++++++++-------- .../org/apache/doris/qe/AuditLogHelper.java | 8 +++++-- .../hive/HiveDDLAndDMLPlanTest.java | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) 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 3d1ab7c895100dc..a9ff48dc2c08da0 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 @@ -1601,7 +1601,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 a6a7cc65e3bba37..01e1e6477780bd9 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,23 +190,26 @@ 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. - if (!Env.getCurrentEnv().isMaster()) { + String clusterName = ""; + if (isCloud) { try { - long backendId = new MasterOpExecutor(context) - .getGroupCommitLoadBeId(tableId, context.getCloudCluster(), isCloud); - return Env.getCurrentSystemInfo().getBackend(backendId); + clusterName = context.getCloudCluster(); } catch (Exception e) { + LOG.warn("failed to get cluster name", e); throw new LoadException(e.getMessage()); } - } else { + } + if (!Env.getCurrentEnv().isMaster()) { try { - // Master FE will select BE by itself. - return Env.getCurrentSystemInfo() - .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster(), isCloud)); + long backendId = new MasterOpExecutor(context) + .getGroupCommitLoadBeId(tableId, clusterName, isCloud); + return Env.getCurrentSystemInfo().getBackend(backendId); } catch (Exception e) { - LOG.warn("get backend failed, tableId: {}, exception", tableId, e); throw new LoadException(e.getMessage()); } + } else { + return Env.getCurrentSystemInfo() + .getBackend(selectBackendForGroupCommitInternal(tableId, clusterName, isCloud)); } } 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 e8f947099d13c9b..7fa740674c9d7bf 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/test/java/org/apache/doris/datasource/hive/HiveDDLAndDMLPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HiveDDLAndDMLPlanTest.java index a40a4fed3855209..b6ce845948c13d4 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 @@ -340,7 +340,7 @@ public void testCreateAndDropWithSql() throws Exception { + " 'location'='hdfs://loc/db/tbl',\n" + " 'file_format'='orc')"; ExceptionChecker.expectThrowsWithMsg(org.apache.doris.nereids.exceptions.AnalysisException.class, - "errCode = 2, detailMessage = errCode = 2," + "errCode = 2," + " detailMessage = Create hive bucket table need set enable_create_hive_bucket_table to true", () -> createTable(createBucketedTableErr, true));