pnowojski commented on code in PR #27862:
URL: https://github.com/apache/flink/pull/27862#discussion_r3044671596
##########
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:
Synced offline and both commit message and comment has been updated to
better explain the problem - and indeed it would be difficult to test, so let's
keep it without a dedicated test coverage (ITCases can still sometimes trigger
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]