924060929 commented on code in PR #70697:
URL: https://github.com/apache/doris/pull/70697#discussion_r4689130052
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/scan/FederationBackendPolicy.java:
##########
@@ -177,32 +180,48 @@ public void init() throws UserException {
}
public void init(List<String> preLocations) throws UserException {
+ ComputeGroup computeGroup = queryComputeGroup();
+ init(computeGroup, preLocations.isEmpty() ?
getQueryAvailableBackends(computeGroup)
+ :
queryBackendPolicy(preLocations).getCandidateBackends(computeGroup.getBackendList()));
+ }
+
+ public static List<Backend> getQueryAvailableBackends() throws
UserException {
+ return getQueryAvailableBackends(queryComputeGroup());
+ }
+
+ private static List<Backend> getQueryAvailableBackends(ComputeGroup
computeGroup) {
+ ConnectContext context = ConnectContext.get();
+ StatementContext statement = context == null ? null :
context.getStatementContext();
+ ConnectorStatementScope scope = statement == null ?
ConnectorStatementScope.NONE
+ : statement.getOrCreateConnectorStatementScope();
+ // The untagged root/admin group has no addressable ID, but is one
stable selection domain.
+ String groupId = computeGroup instanceof AllBackendComputeGroup
+ ? AllBackendComputeGroup.class.getSimpleName() :
computeGroup.getId();
+ String key = "engine:external-scan-backends:" +
computeGroup.getClass().getName() + ":" + groupId;
+ // Selection can randomly fill a compute-node deficit with mixed
nodes. Admission and every default
+ // scan must reuse that result within the statement, while capability
checks continue to read live state.
+ return scope.computeIfAbsentForPlanning(key, () ->
List.copyOf(queryBackendPolicy(Collections.emptyList())
Review Comment:
[P2] Give each round-robin scan its own starting backend
Caching this list also freezes its order. Each scan starts with `nextBe =
0`, so when a query has several one-split scans, every scan assigns its split
to the first BE. This affects plaintext external tables too.
I compared the FE scheduler before and after this change with eight eligible
BEs and 32 distinct, remotely readable files, one split per scan in the same
statement. With file cache and consistent hashing disabled and
`external_scan_consistent_hash_spread_num=1`, the previous code used all eight
BEs. At `30385c4`, all 32 splits went to one BE.
Could we keep the selected membership shared with admission and vary the
starting index per scan? The reuse test can compare backend IDs as a set so it
still catches resampling while allowing round-robin scans to spread the work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]