From 9b5e6a782a26dbc699db46ef8353d2facfe0a3fa Mon Sep 17 00:00:00 2001 From: deardeng <565620795@qq.com> Date: Thu, 12 Sep 2024 22:04:58 +0800 Subject: [PATCH] rebase and fix case --- .../java/org/apache/doris/cloud/catalog/CloudReplica.java | 8 +++++++- .../apache/doris/cloud/catalog/CloudTabletRebalancer.java | 2 +- .../src/main/java/org/apache/doris/qe/AuditLogHelper.java | 2 +- .../src/main/java/org/apache/doris/qe/ConnectContext.java | 8 ++++---- .../suites/cloud_p0/multi_cluster/test_auto_start.groovy | 2 +- .../cloud_p0/multi_cluster/test_no_cluster_hits.groovy | 6 ++++-- .../cloud_p0/multi_cluster/test_warmup_rebalance.groovy | 2 +- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java index bd1b6613becb8d7..657786cdcbdaac6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java @@ -174,12 +174,18 @@ public long getBackendId() throws ClusterException { private long getBackendIdImpl(String cluster) throws ClusterException { // if cluster is SUSPENDED, wait + String wakeUPCluster = ""; try { - cluster = ((CloudSystemInfoService) Env.getCurrentSystemInfo()).waitForAutoStart(cluster); + wakeUPCluster = ((CloudSystemInfoService) Env.getCurrentSystemInfo()).waitForAutoStart(cluster); } catch (DdlException e) { // this function cant throw exception. so just log it LOG.warn("cant resume cluster {}, exception", cluster, e); } + if (!Strings.isNullOrEmpty(wakeUPCluster) && !cluster.equals(wakeUPCluster)) { + cluster = wakeUPCluster; + LOG.warn("get backend input cluster {} useless, so auto start choose a new one cluster {}", + cluster, wakeUPCluster); + } // check default cluster valid. if (Strings.isNullOrEmpty(cluster)) { LOG.warn("failed to get available be, clusterName: {}", cluster); diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java index d22ff06c251b2ef..da771b1206ac6c7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java @@ -510,11 +510,11 @@ private void completeRouteInfo() { LOG.warn("failed to hash replica to be {}", cluster, e); beId = -1; } - ((CloudReplica) replica).updateClusterToBe(cluster, beId, true); if (beId <= 0) { assignedErrNum++; continue; } + ((CloudReplica) replica).updateClusterToBe(cluster, beId, true); List bes = new ArrayList(); bes.add(beId); primaryClusterToBackends.put(cluster, bes); 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 3b878a7593078cf..4628fc2452bc1e6 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 @@ -178,7 +178,7 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme String cloudCluster = ""; try { if (Config.isCloudMode()) { - cloudCluster = ctx.getCloudCluster(); + cloudCluster = ctx.getCloudCluster(false); } } catch (ClusterException e) { LOG.warn("Failed to get cloud cluster", e); 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 6b0a26cce17e854..f1039c4dcb27553 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 @@ -1251,12 +1251,12 @@ public String getCloudCluster(boolean updateErr) throws ClusterException { if (Strings.isNullOrEmpty(cluster)) { LOG.warn("cant get a valid cluster for user {} to use", getCurrentUserIdentity()); + ClusterException exception = new ClusterException("the user is not granted permission to the cluster", + ClusterException.FailedTypeEnum.CURRENT_USER_NO_AUTH_TO_USE_ANY_CLUSTER); if (updateErr) { - getState().setError(ErrorCode.ERR_NO_CLUSTER_ERROR, - "Cant get a Valid cluster for you to use, plz connect admin"); + getState().setError(ErrorCode.ERR_CLOUD_CLUSTER_ERROR, exception.getMessage()); } - throw new ClusterException("the user is not granted permission to the cluster", - ClusterException.FailedTypeEnum.CURRENT_USER_NO_AUTH_TO_USE_ANY_CLUSTER); + throw exception; } else { this.cloudCluster = cluster; LOG.info("finally set context cluster name {} for user {} with chose way '{}'", diff --git a/regression-test/suites/cloud_p0/multi_cluster/test_auto_start.groovy b/regression-test/suites/cloud_p0/multi_cluster/test_auto_start.groovy index 2ce9a9d8f4b5314..d1834ed72f03a7f 100644 --- a/regression-test/suites/cloud_p0/multi_cluster/test_auto_start.groovy +++ b/regression-test/suites/cloud_p0/multi_cluster/test_auto_start.groovy @@ -22,7 +22,7 @@ import org.awaitility.Awaitility; import org.apache.doris.regression.util.Http import static java.util.concurrent.TimeUnit.SECONDS; -suite('test_auto_start_in_cloud', 'multi_cluster') { +suite('test_auto_start_in_cloud', 'multi_cluster, docker') { if (!isCloudMode()) { return; } diff --git a/regression-test/suites/cloud_p0/multi_cluster/test_no_cluster_hits.groovy b/regression-test/suites/cloud_p0/multi_cluster/test_no_cluster_hits.groovy index acb6f29062cf234..031b46e2e2b3540 100644 --- a/regression-test/suites/cloud_p0/multi_cluster/test_no_cluster_hits.groovy +++ b/regression-test/suites/cloud_p0/multi_cluster/test_no_cluster_hits.groovy @@ -20,7 +20,7 @@ import groovy.json.JsonSlurper import org.awaitility.Awaitility; import static java.util.concurrent.TimeUnit.SECONDS; -suite('test_no_cluster_hits', 'multi_cluster') { +suite('test_no_cluster_hits', 'multi_cluster, docker') { if (!isCloudMode()) { return; } @@ -28,7 +28,8 @@ suite('test_no_cluster_hits', 'multi_cluster') { options.feConfigs += [ 'cloud_cluster_check_interval_second=1', 'sys_log_verbose_modules=org', - 'max_query_retry_time=2000' + 'max_query_retry_time=2000', + 'heartbeat_interval_second=1' ] options.setFeNum(3) options.setBeNum(3) @@ -106,6 +107,7 @@ suite('test_no_cluster_hits', 'multi_cluster') { } cluster.startBackends(1, 2, 3) + Thread.sleep(3000) result = sql """insert into $table values (3, 3)""" result = sql """select * from $table""" log.info("result = {}", result) diff --git a/regression-test/suites/cloud_p0/multi_cluster/test_warmup_rebalance.groovy b/regression-test/suites/cloud_p0/multi_cluster/test_warmup_rebalance.groovy index 7e12d9f81f8ae93..71ee67076b6917e 100644 --- a/regression-test/suites/cloud_p0/multi_cluster/test_warmup_rebalance.groovy +++ b/regression-test/suites/cloud_p0/multi_cluster/test_warmup_rebalance.groovy @@ -21,7 +21,7 @@ import org.awaitility.Awaitility; import static java.util.concurrent.TimeUnit.SECONDS; import org.codehaus.groovy.runtime.IOGroovyMethods -suite('test_warmup_rebalance_in_cloud', 'multi_cluster') { +suite('test_warmup_rebalance_in_cloud', 'multi_cluster, docker') { if (!isCloudMode()) { return; }