Skip to content

Commit

Permalink
use config
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteYue committed Jul 10, 2024
1 parent d146faf commit 7cd3eb0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2900,6 +2900,9 @@ public static int metaServiceRpcRetryTimes() {
"streamload route policy in cloud mode, availale options are public-private and empty string"})
public static String streamload_redirect_policy = "";

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

//==========================================================================
// end of cloud config
//==========================================================================
Expand Down
43 changes: 23 additions & 20 deletions fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -864,28 +864,31 @@ private void addScanRangeLocations(Partition partition,
}
}

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
// is now under cooldown
// first time we choose BE A, and A will download data into cache while the other two's cache is empty
// second time we choose BE B, this time B will be cached, C is still empty
// third time we choose BE C, after this time all replica is cached
// but it means we will do 3 S3 IO to get the data which will bring 3 slow query
if (-1L != coolDownReplicaId) {
final Optional<Replica> replicaOptional = replicas.stream()
.filter(r -> r.getId() == coolDownReplicaId).findAny();
replicaOptional.ifPresent(
r -> {
Backend backend = Env.getCurrentSystemInfo()
.getBackend(r.getBackendId());
if (backend != null && backend.isAlive()) {
replicas.clear();
replicas.add(r);
if (Config.cool_query_replica_affinity) {
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
// is now under cooldown
// first time we choose BE A, and A will download data into cache while the other two's cache is empty
// second time we choose BE B, this time B will be cached, C is still empty
// third time we choose BE C, after this time all replica is cached
// but it means we will do 3 S3 IO to get the data which will bring 3 slow query
if (-1L != coolDownReplicaId) {
final Optional<Replica> replicaOptional = replicas.stream()
.filter(r -> r.getId() == coolDownReplicaId).findAny();
replicaOptional.ifPresent(
r -> {
Backend backend = Env.getCurrentSystemInfo()
.getBackend(r.getBackendId());
if (backend != null && backend.isAlive()) {
replicas.clear();
replicas.add(r);
}
}
}
);
);
}
}

boolean tabletIsNull = true;
boolean collectedStat = false;
List<String> errs = Lists.newArrayList();
Expand Down

0 comments on commit 7cd3eb0

Please sign in to comment.