zhijiangW commented on a change in pull request #11687:
URL: https://github.com/apache/flink/pull/11687#discussion_r422028066
##########
File path:
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
##########
@@ -477,14 +477,18 @@ protected void beforeInvoke() throws Exception {
// output can request more floating buffers from global
firstly.
InputGate[] inputGates =
getEnvironment().getAllInputGates();
if (inputGates != null) {
- for (InputGate inputGate : inputGates) {
-
inputGate.readRecoveredState(channelIOExecutor,
getEnvironment().getTaskStateManager().getChannelStateReader());
+ CompletableFuture[] futures = new
CompletableFuture[inputGates.length];
+ for (int i = 0; i < inputGates.length; i++) {
+ futures[i] =
inputGates[i].readRecoveredState(
+ channelIOExecutor,
getEnvironment().getTaskStateManager().getChannelStateReader());
}
- // Note that we must request partition after
all the single gate finishes recovery.
- for (InputGate inputGate : inputGates) {
-
inputGate.requestPartitions(channelIOExecutor);
- }
+ // Note that we must request partition after
all the single gates finished recovery.
+
CompletableFuture.allOf(futures).thenRun(ThrowingRunnable.unchecked(() -> {
+ for (InputGate inputGate : inputGates) {
+ inputGate.requestPartitions();
+ }
+ }));
Review comment:
Yeah I assume it should be completed by task thread, actually my initial
version was `mailboxProcessor.getMainMailboxExecutor().execute()`.
I can add a `checkState` here to guarantee that the current thread is
mailbox thread and then give some note comments.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]