gaoyunhaii commented on a change in pull request #15055:
URL: https://github.com/apache/flink/pull/15055#discussion_r659736745
##########
File path:
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
##########
@@ -695,6 +697,27 @@ protected void afterInvoke() throws Exception {
// close all operators in a chain effect way
operatorChain.closeOperators(actionExecutor);
+ // If checkpoints are enabled, waits for all the records get processed
by the downstream
+ // tasks. During this process, this task could coordinate with its
downstream tasks to
+ // continue perform checkpoints.
+ if (configuration.isCheckpointingEnabled()) {
+ LOG.debug("Waiting for all the records processed by the downstream
tasks.");
+ CompletableFuture<Void> combineFuture =
+ FutureUtils.waitForAll(
+ Arrays.stream(getEnvironment().getAllWriters())
+ .map(
+ FunctionUtils.uncheckedFunction(
+ ResultPartitionWriter
+
::getAllRecordsProcessedFuture))
+ .collect(Collectors.toList()));
+
+ MailboxExecutor mailboxExecutor =
+
mailboxProcessor.getMailboxExecutor(TaskMailbox.MIN_PRIORITY);
+ while (!combineFuture.isDone()) {
Review comment:
I think it would not go for closing the task directly if the mailbox is
empty~? For each iteration, `while (mailboxExecutor.tryYield()) {}` would exit
if no mails, then `future.get(1s)` would do a blocking waiting for 1 second, if
the future still not finish, it would throws `TimeoutException` and get back to
the outer iteration, Thus it seems to be a temporary fix similar to
`sleep(1000)` that decreases the ratio of running on CPU~
--
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]