pnowojski commented on code in PR #27862:
URL: https://github.com/apache/flink/pull/27862#discussion_r3043542117


##########
flink-runtime/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java:
##########
@@ -913,8 +913,14 @@ private CompletableFuture<Void> restoreStateAndGates(
                                             "Input gate request partitions"));
         }
 
-        return CompletableFuture.allOf(recoveredFutures.toArray(new 
CompletableFuture[0]))
-                .thenRun(mailboxProcessor::suspend);
+        // Return allOf result instead of thenRun result.
+        // thenRun returns a NEW future that completes after the callback 
finishes.
+        // Since suspend() runs on the async thread and just sends a poison 
mail,
+        // the mailbox loop can exit before suspend() returns, causing 
isDone() to be false.
+        CompletableFuture<Void> allRecoveredFuture =
+                CompletableFuture.allOf(recoveredFutures.toArray(new 
CompletableFuture[0]));
+        allRecoveredFuture.thenRun(mailboxProcessor::suspend);
+        return allRecoveredFuture;

Review Comment:
   🤔 are you sure this can not be tested? We have 
`StreamTaskMailboxTestHarness` among other thigns for the purpose of 
reproducing race conditions. You could control when `recoveredFutures` are 
completing and you can control when mailbox process actions.



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