Copilot commented on code in PR #65407:
URL: https://github.com/apache/doris/pull/65407#discussion_r3549896633


##########
fe/fe-core/src/main/java/org/apache/doris/load/routineload/RoutineLoadManager.java:
##########
@@ -144,8 +144,13 @@ public void 
removeMultiLoadTaskTxnIdToRoutineLoadJobId(long txnId) {
     }
 
     public void updateBeIdToMaxConcurrentTasks() {
-        beIdToMaxConcurrentTasks = 
Env.getCurrentSystemInfo().getAllBackendIds(true).stream().collect(
-                Collectors.toMap(beId -> beId, beId -> 
Config.max_routine_load_task_num_per_be));
+        beIdToMaxConcurrentTasks = 
Env.getCurrentSystemInfo().getAllBackendIds(true).stream()
+                .filter(beId -> {
+                    Backend backend = 
Env.getCurrentSystemInfo().getBackend(beId);
+                    return backend != null && backend.isLoadAvailable()
+                            && !backend.isDecommissioned() && 
!backend.isDecommissioning();

Review Comment:
   `updateBeIdToMaxConcurrentTasks()` calls `Env.getCurrentSystemInfo()` inside 
the stream for every element. Capturing it once avoids repeated lookups and 
eliminates any possibility of observing different `systemInfo` instances 
mid-collection if the Env is swapped in tests.



##########
fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java:
##########
@@ -190,13 +190,17 @@ public void testSelectBackendIdsByPolicy() throws 
Exception {
         Assert.assertEquals(0, infoService.selectBackendIdsByPolicy(policy4, 
3).size());
 
         BeSelectionPolicy policy5 = new 
BeSelectionPolicy.Builder().needLoadAvailable().build();
+        
Assert.assertTrue(policy5.toString().contains("nonDecommissioned=true"));

Review Comment:
   The test asserts behavior via `policy5.toString()` which makes the test 
brittle to future formatting changes in `BeSelectionPolicy.toString()`. Since 
the policy fields are public, assert the actual flag instead (this is what the 
test is really validating).



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