This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 4b3aa2e9661 [cherry-pick](branch-2.0)add SessionVariable for
enableCooldownReplicaAffinity (#42683)
4b3aa2e9661 is described below
commit 4b3aa2e966199a25a43609a897f26216a76ad18e
Author: kkop <[email protected]>
AuthorDate: Fri Nov 8 16:20:20 2024 +0800
[cherry-pick](branch-2.0)add SessionVariable for
enableCooldownReplicaAffinity (#42683)
pick from master:https://github.com/apache/doris/pull/41741
---
.../main/java/org/apache/doris/common/Config.java | 3 --
.../org/apache/doris/planner/OlapScanNode.java | 11 ++++++-
.../java/org/apache/doris/qe/SessionVariable.java | 9 +++++
.../suites/show_p0/test_show_variables.groovy | 38 ++++++++++++++++++++++
4 files changed, 57 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 92eedf4ab71..954dde05005 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
@@ -2501,9 +2501,6 @@ public class Config extends ConfigBase {
@ConfField(mutable = true)
public static boolean fix_tablet_partition_id_eq_0 = false;
- @ConfField(mutable = true)
- public static boolean enable_cooldown_replica_affinity = true;
-
@ConfField(mutable = true, description = {
"设置为 true,root 和 admin 将跳过 sql block rule", "Set to true, root and
admin will skip SQL block rule"})
public static boolean sql_block_rule_ignore_admin = false;
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 6342e8bdb50..a24ce4375e9 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
@@ -797,7 +797,8 @@ public class OlapScanNode extends ScanNode {
replicas.clear();
replicas.add(replica);
}
- 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
@@ -886,6 +887,14 @@ public class OlapScanNode extends ScanNode {
}
}
+ 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 129bf172e3e..515f90cd81f 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
@@ -483,6 +483,8 @@ public class SessionVariable implements Serializable,
Writable {
public static final String REQUIRE_SEQUENCE_IN_INSERT =
"require_sequence_in_insert";
+ 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.
*/
@@ -1510,6 +1512,9 @@ public class SessionVariable implements Serializable,
Writable {
})
public boolean requireSequenceInInsert = true;
+ @VariableMgr.VarAttr(name = ENABLE_COOLDOWN_REPLICA_AFFINITY, needForward
= true)
+ public boolean enableCooldownReplicaAffinity = true;
+
public boolean isEnableESShardScroll() {
return enableESShardScroll;
}
@@ -3070,5 +3075,9 @@ public class SessionVariable implements Serializable,
Writable {
return this.maxMsgSizeOfResultReceiver;
}
+ public boolean isEnableCooldownReplicaAffinity() {
+ return enableCooldownReplicaAffinity;
+ }
+
}
diff --git a/regression-test/suites/show_p0/test_show_variables.groovy
b/regression-test/suites/show_p0/test_show_variables.groovy
new file mode 100644
index 00000000000..6de8075b630
--- /dev/null
+++ b/regression-test/suites/show_p0/test_show_variables.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;"""
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]