Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2838,9 +2838,6 @@ public class Config extends ConfigBase {
"Should the request content be logged before each request starts, specifically the query statements"})
public static boolean enable_print_request_before_execution = false;

@ConfField(mutable = true)
public static boolean enable_cooldown_replica_affinity = true;

@ConfField
public static String spilled_profile_storage_path = System.getenv("LOG_DIR") + File.separator + "profile";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,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
Expand Down Expand Up @@ -976,6 +976,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ public class SessionVariable implements Serializable, Writable {

public static final String SKIP_CHECKING_ACID_VERSION_FILE = "skip_checking_acid_version_file";

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.
*/
Expand Down Expand Up @@ -2208,6 +2210,9 @@ public void setIgnoreShapePlanNodes(String ignoreShapePlanNodes) {
})
public boolean skipCheckingAcidVersionFile = false;

@VariableMgr.VarAttr(name = ENABLE_COOLDOWN_REPLICA_AFFINITY, needForward = true)
public boolean enableCooldownReplicaAffinity = true;

public void setEnableEsParallelScroll(boolean enableESParallelScroll) {
this.enableESParallelScroll = enableESParallelScroll;
}
Expand Down Expand Up @@ -4413,4 +4418,8 @@ public TSerdeDialect getSerdeDialect() {
public boolean isUseSerialExchange() {
return useSerialExchange && getEnableLocalExchange();
}

public boolean isEnableCooldownReplicaAffinity() {
return enableCooldownReplicaAffinity;
}
}
38 changes: 38 additions & 0 deletions regression-test/suites/show_p0/test_show_variables.groovy
Original file line number Diff line number Diff line change
@@ -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;"""

}