XComp commented on code in PR #25027:
URL: https://github.com/apache/flink/pull/25027#discussion_r1668650443


##########
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DefaultJobManagerRunnerRegistry.java:
##########
@@ -85,7 +85,16 @@ public Collection<JobManagerRunner> getJobManagerRunners() {
     @Override
     public CompletableFuture<Void> localCleanupAsync(JobID jobId, Executor 
unusedExecutor) {
         if (isRegistered(jobId)) {
-            return unregister(jobId).closeAsync();
+            CompletableFuture<Void> resultFuture = 
this.jobManagerRunners.get(jobId).closeAsync();
+
+            resultFuture.whenComplete(
+                    (result, throwable) -> {
+                        if (throwable == null) {
+                            unregister(jobId);

Review Comment:
   you're correct - that's what happens in the general scenario (there's an 
edge case where the `CompletableFuture` is already completed when chaining the 
callback to the future instance). 
   
   Executing the `unregister(JobID)` in the thread that executed `closeAsync` 
is something we don't want to do (for the reasons around main thread execution 
which I outlined in my comment above), though.



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