From d44fc7e872251ea0408e964e0192791b1b1286c8 Mon Sep 17 00:00:00 2001 From: cjj2010 <2449402815@qq.com> Date: Sat, 12 Oct 2024 10:10:56 +0800 Subject: [PATCH 1/5] [cherry-pick](branch-2.1)add SessionVariable for enableCooldownReplicaAffinity --- .../src/main/java/org/apache/doris/common/Config.java | 3 --- .../java/org/apache/doris/planner/OlapScanNode.java | 10 +++++++++- .../main/java/org/apache/doris/qe/SessionVariable.java | 7 +++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java index cac5355a9705ed..630d76ad7d3639 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java +++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java @@ -2808,9 +2808,6 @@ public static boolean isNotCloudMode() { "Stream_Load When importing, the maximum length of label is limited"}) public static int label_regex_length = 128; - @ConfField(mutable = true) - public static boolean enable_cooldown_replica_affinity = true; - //========================================================================== // end of cloud config //========================================================================== 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 4ffa12e8f05b8b..5c6b47fec71547 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 @@ -830,7 +830,7 @@ private void addScanRangeLocations(Partition partition, } } - if (Config.enable_cooldown_replica_affinity) { + if (isEnableCooldownReplicaAffinity()) { final long coolDownReplicaId = tablet.getCooldownReplicaId(); // we prefer to query using cooldown replica to make sure the cache is fully utilized // for example: consider there are 3BEs(A,B,C) and each has one replica for tablet X. and X @@ -932,6 +932,14 @@ private void addScanRangeLocations(Partition partition, } } + private boolean isEnableCooldownReplicaAffinity() { + ConnectContext connectContext = ConnectContext.get(); + if (connectContext != null) { + return connectContext.getSessionVariable().isEnableCooldownReplicaAffinity(); + } + return true; + } + private void computePartitionInfo() throws AnalysisException { long start = System.currentTimeMillis(); // Step1: compute partition ids diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java index b545b1c620dd70..e502af905759a5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java @@ -2111,6 +2111,9 @@ public void setIgnoreShapePlanNodes(String ignoreShapePlanNodes) { }) public boolean requireSequenceInInsert = true; + @VariableMgr.VarAttr(name = ENABLE_COOLDOWN_REPLICA_AFFINITY, needForward = true) + public boolean enableCooldownReplicaAffinity = true; + public void setEnableEsParallelScroll(boolean enableESParallelScroll) { this.enableESParallelScroll = enableESParallelScroll; } @@ -4254,4 +4257,8 @@ public TSerdeDialect getSerdeDialect() { throw new IllegalArgumentException("Unknown serde dialect: " + serdeDialect); } } + + public boolean isEnableCooldownReplicaAffinity() { + return enableCooldownReplicaAffinity; + } } From d4e288e015f592ee4435a322896e5a9e954b13c6 Mon Sep 17 00:00:00 2001 From: cjj2010 <2449402815@qq.com> Date: Sun, 13 Oct 2024 17:47:13 +0800 Subject: [PATCH 2/5] [enhance](Cooldown) add SessionVariable for enableCooldownReplicaAffinity --- .../suites/show_p0/test_show_tranction.groovy | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 regression-test/suites/show_p0/test_show_tranction.groovy diff --git a/regression-test/suites/show_p0/test_show_tranction.groovy b/regression-test/suites/show_p0/test_show_tranction.groovy new file mode 100644 index 00000000000000..6de8075b63092b --- /dev/null +++ b/regression-test/suites/show_p0/test_show_tranction.groovy @@ -0,0 +1,38 @@ +// 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. + +import org.apache.doris.regression.util.Http + +suite("test_show_variables", "p0") { + + def result = sql """show variables like "enable_cooldown_replica_affinity%";""" + assertTrue(result[0][1]=="true") + + result = sql """set enable_cooldown_replica_affinity=false;""" + result = sql """show variables like "enable_cooldown_replica_affinity%";""" + assertTrue(result[0][1]=="false") + + result = sql """set enable_cooldown_replica_affinity=true;""" + result = sql """show variables like "enable_cooldown_replica_affinity%";""" + assertTrue(result[0][1]=="true") + + result = sql """set GLOBAL enable_cooldown_replica_affinity=false;""" + result = sql """show variables like "enable_cooldown_replica_affinity%";""" + assertTrue(result[0][1]=="false") + result = sql """set GLOBAL enable_cooldown_replica_affinity=true;""" + +} From 792ff3881baa44ed0c9d43337251f8d848b92b40 Mon Sep 17 00:00:00 2001 From: cjj2010 <2449402815@qq.com> Date: Mon, 14 Oct 2024 09:49:19 +0800 Subject: [PATCH 3/5] [enhance](Cooldown) add SessionVariable for enableCooldownReplicaAffinity --- .../{test_show_tranction.groovy => test_show_variables.groovy} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename regression-test/suites/show_p0/{test_show_tranction.groovy => test_show_variables.groovy} (100%) diff --git a/regression-test/suites/show_p0/test_show_tranction.groovy b/regression-test/suites/show_p0/test_show_variables.groovy similarity index 100% rename from regression-test/suites/show_p0/test_show_tranction.groovy rename to regression-test/suites/show_p0/test_show_variables.groovy From 3247cf7e69f3dcf4e446428a1e43789ce1528279 Mon Sep 17 00:00:00 2001 From: cjj2010 <2449402815@qq.com> Date: Tue, 29 Oct 2024 12:09:52 +0800 Subject: [PATCH 4/5] [cherry-pick](branch-2.1)add SessionVariable for enableCooldownReplicaAffinity --- .../src/main/java/org/apache/doris/qe/SessionVariable.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java index e502af905759a5..18bd89f8ce6743 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java @@ -642,6 +642,10 @@ public class SessionVariable implements Serializable, Writable { "adaptive_pipeline_task_serial_read_on_limit"; public static final String REQUIRE_SEQUENCE_IN_INSERT = "require_sequence_in_insert"; + public static final String ENABLE_PHRASE_QUERY_SEQUENYIAL_OPT = "enable_phrase_query_sequential_opt"; + + public static final String ENABLE_COOLDOWN_REPLICA_AFFINITY = + "enable_cooldown_replica_affinity"; /** * If set false, user couldn't submit analyze SQL and FE won't allocate any related resources. */ From a0da74d150f74de12738ba07e982c60bd16c5b34 Mon Sep 17 00:00:00 2001 From: kkop Date: Tue, 29 Oct 2024 12:39:40 +0800 Subject: [PATCH 5/5] [cherry-pick](branch-2.1)add SessionVariable for enableCooldownReplicaAffinity --- .../src/main/java/org/apache/doris/qe/SessionVariable.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java index 18bd89f8ce6743..26bd2d2668f001 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java @@ -642,8 +642,6 @@ public class SessionVariable implements Serializable, Writable { "adaptive_pipeline_task_serial_read_on_limit"; public static final String REQUIRE_SEQUENCE_IN_INSERT = "require_sequence_in_insert"; - public static final String ENABLE_PHRASE_QUERY_SEQUENYIAL_OPT = "enable_phrase_query_sequential_opt"; - public static final String ENABLE_COOLDOWN_REPLICA_AFFINITY = "enable_cooldown_replica_affinity"; /**