zentol commented on code in PR #22169:
URL: https://github.com/apache/flink/pull/22169#discussion_r1146058411


##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveScheduler.java:
##########
@@ -1213,4 +1260,29 @@ <T extends State> T transitionToState(StateFactory<T> 
targetState) {
     State getState() {
         return state;
     }
+
+    /**
+     * Check for slots that are idle for more than {@link 
JobManagerOptions#SLOT_IDLE_TIMEOUT} and
+     * release them back to the ResourceManager.
+     */
+    private void checkIdleSlotTimeout() {
+        if (getState().getJobStatus().isGloballyTerminalState()) {
+            // Job has reached the terminal state, so we can return all slots 
to the ResourceManager
+            // to speed things up because we no longer need them. This 
optimization lets us skip
+            // waiting for the slot pool service to close.
+            for (SlotInfo slotInfo : 
declarativeSlotPool.getAllSlotsInformation()) {
+                declarativeSlotPool.releaseSlot(
+                        slotInfo.getAllocationId(),
+                        new FlinkException(
+                                "Returning slots to their owners, because the 
job has reached a globally terminal state."));
+            }
+            return;
+        }
+        declarativeSlotPool.releaseIdleSlots(System.currentTimeMillis());

Review Comment:
   its the schedulers decision whether it holds on to slots or not. It may for 
example keep slots around to allow scale up operations without having to 
request additional slots.



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

Reply via email to