You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2021/02/18 09:14:51 UTC

[flink] 03/12: [hotfix][coordination] Assert that return of logical slot does not fail

This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit f7dbe99955d4bcb0c6f88ef2918d01e308eafe7c
Author: Chesnay Schepler <ch...@apache.org>
AuthorDate: Mon Feb 8 20:23:51 2021 +0100

    [hotfix][coordination] Assert that return of logical slot does not fail
---
 .../jobmaster/slotpool/SingleLogicalSlot.java      | 26 ++++++++++------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlot.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlot.java
index 798b50d..21e14f9 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlot.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlot.java
@@ -20,6 +20,7 @@ package org.apache.flink.runtime.jobmaster.slotpool;
 
 import org.apache.flink.annotation.VisibleForTesting;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
+import org.apache.flink.runtime.concurrent.FutureUtils;
 import org.apache.flink.runtime.jobmanager.scheduler.Locality;
 import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
@@ -195,20 +196,17 @@ public class SingleLogicalSlot implements LogicalSlot, PhysicalSlot.Payload {
     }
 
     private void returnSlotToOwner(CompletableFuture<?> terminalStateFuture) {
-        terminalStateFuture.whenComplete(
-                (Object ignored, Throwable throwable) -> {
-                    if (state == State.RELEASING) {
-                        slotOwner.returnLogicalSlot(this);
-                    }
-
-                    markReleased();
-
-                    if (throwable != null) {
-                        releaseFuture.completeExceptionally(throwable);
-                    } else {
-                        releaseFuture.complete(null);
-                    }
-                });
+        FutureUtils.assertNoException(
+                terminalStateFuture.thenRun(
+                        () -> {
+                            if (state == State.RELEASING) {
+                                slotOwner.returnLogicalSlot(this);
+                            }
+
+                            markReleased();
+
+                            releaseFuture.complete(null);
+                        }));
     }
 
     private void markReleased() {