Skip to content

Commit

Permalink
[enhance](Cooldown) add SessionVariable for enableCooldownReplicaAffi…
Browse files Browse the repository at this point in the history
…nity
  • Loading branch information
cjj2010 committed Oct 12, 2024
1 parent e6607b8 commit 1ecb7b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2813,9 +2813,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 @@ -668,6 +668,8 @@ public class SessionVariable implements Serializable, Writable {

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.
*/
Expand Down Expand Up @@ -2195,6 +2197,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;
}
Expand Down Expand Up @@ -4376,4 +4381,8 @@ public TSerdeDialect getSerdeDialect() {
throw new IllegalArgumentException("Unknown serde dialect: " + serdeDialect);
}
}

public boolean isEnableCooldownReplicaAffinity() {
return enableCooldownReplicaAffinity;
}
}

0 comments on commit 1ecb7b8

Please sign in to comment.