You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "eric666666 (via GitHub)" <gi...@apache.org> on 2026/07/03 08:04:02 UTC

[PR] [FLINK-40059][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

eric666666 opened a new pull request, #28626:
URL: https://github.com/apache/flink/pull/28626

   
   ## What is the purpose of the change
   
   When the cluster runs in application mode and
   `JobManagerOptions#SCHEDULER_PREFER_MINIMAL_TASKMANAGERS_ENABLED` is enabled,
   `DefaultSlotAssigner` tries to satisfy the requested slots from as few
   TaskManagers as possible so that the remaining TaskManagers can be released.
   
   `pickSlotsInMinimalTaskExecutors` walks the TaskManagers in descending order of
   their free-slot count and adds **all** slots of each one until the request is
   met. Since the last (boundary) TaskManager is always added in full via
   `addAll`, the method can return **more** slots than requested. For example, with
   `requestedGroups = 5` and two TaskManagers offering 4 and 3 free slots, it
   returns 7 slots instead of 5.
   
   The surplus does not corrupt the final assignment — `SimpleSlotMatchingResolver`
   only consumes the first `requestedGroups` slots — but the returned "minimal"
   set pulls in extra slots from the boundary TaskManager that were never needed,
   which works against the method's own goal of minimizing the involved
   TaskManagers and the fragmentation on the boundary TaskManager. The loop also
   has no `hasNext()` guard and relies solely on the caller's pre-check for
   termination.
   
   This PR makes the method return exactly the requested number of slots and
   removes the unguarded loop, while keeping the "prefer the fewest TaskManagers"
   behavior unchanged.
   
   ## Brief change log
   
   - Rewrite `DefaultSlotAssigner#pickSlotsInMinimalTaskExecutors` to flatten the
     sorted TaskManagers' slots into a single stream and keep only the first
     `requestedGroups` via `Stream#limit`. Because `limit` is lazy and
     short-circuiting, TaskManagers beyond the boundary one are never materialized,
     and the boundary TaskManager contributes exactly the slots still needed.
   - Change `getSortedTaskExecutors` to return a `Stream<ResourceID>` instead of an
     `Iterator<ResourceID>` so its result can feed the `flatMap` pipeline directly.
   - Strengthen `DefaultSlotAssignerTest`: assert the exact total slot count and
     the per-TaskManager slot contribution (instead of only which TaskManagers are
     involved), and add regression cases for single-TaskManager over-pick, the
     cumulative boundary trim, and the smallest TaskManager being left untouched.
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40057][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "eric666666 (via GitHub)" <gi...@apache.org>.
eric666666 commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-4901074014

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40057][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "eric666666 (via GitHub)" <gi...@apache.org>.
eric666666 commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-4874177593

   > Hey @eric666666, Can you add the correct JIRA, I believe it is https://issues.apache.org/jira/browse/FLINK-40057
   
   Thanks, i corrected it. 


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40057][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-4874206621

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "6fa9fcca2830d3d5be614ba511d524a8fb10443a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "6fa9fcca2830d3d5be614ba511d524a8fb10443a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 6fa9fcca2830d3d5be614ba511d524a8fb10443a UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40057][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "eric666666 (via GitHub)" <gi...@apache.org>.
eric666666 commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-4880808804

   > * @flinkbot run azure
   
   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40057][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "eric666666 (via GitHub)" <gi...@apache.org>.
eric666666 commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-4910774233

   Thanks @davidradl! Addressed your test-coverage comment in e3c2143 — added `testPickSlotsIfNeededReturnsFullFreeSlotsWhenMinimizationBypassed` to cover the bypass branch where `freeSlots` is returned unchanged. Latest CI (8902196f) is green. PTAL when you get a chance.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40057][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "eric666666 (via GitHub)" <gi...@apache.org>.
eric666666 commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-4901289642

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40057][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-6010923076

   This PR is being marked as stale since it has not had any activity in the last 90 days. 
   If you would like to keep this PR alive, please leave a comment asking for a review. 
   If the PR has merge conflicts, update it with the latest from the base branch.
   
   If you are having difficulty finding a reviewer, please reach out to the 
   community, contact details can be found here: https://flink.apache.org/what-is-flink/community/
   
   If this PR is no longer valid or desired, please feel free to close it. 
   If no activity occurs in the next 30 days, it will be automatically closed.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40057][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "eric666666 (via GitHub)" <gi...@apache.org>.
eric666666 commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-4900823966

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40059][runtime] Avoid over-picking slots in DefaultSlotAssigner [flink]

Posted by "spuru9 (via GitHub)" <gi...@apache.org>.
spuru9 commented on PR #28626:
URL: https://github.com/apache/flink/pull/28626#issuecomment-4874147397

   Hey @eric666666, Can you add the correct JIRA, I believe it is https://issues.apache.org/jira/browse/FLINK-40057


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org