Gabriel39 commented on code in PR #70697:
URL: https://github.com/apache/doris/pull/70697#discussion_r4692527090


##########
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:
   Addressed in follow-up PR #71011. Candidate membership remains shared with 
statement admission, while each ROUND_ROBIN scan initializes its own starting 
cursor. Explicit load ordering still resets the cursor to the selected first 
backend.
   
   The new deterministic regression covers 32 one-split scans over eight 
backends, verifies one candidate-membership selection and set reuse, and checks 
per-scan spreading. Additional coverage checks cursor progression across 
batches and explicit load ordering. All 67 related scheduler, load-selection 
and capability tests pass.



-- 
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]

Reply via email to