You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/06/16 11:40:17 UTC
[GitHub] [flink] 1996fanrui opened a new pull request, #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
1996fanrui opened a new pull request, #19993:
URL: https://github.com/apache/flink/pull/19993
## What is the purpose of the change
Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Currently, just call the `writer.fail(e);` and don't throw InterruptedException when caught the InterruptedException in ChannelStateWriterThread. So ChannelStateWriterThread cannot exit when meet InterruptedException. We should throw InterruptedException, and the ChannelStateWriterThread will be finished.
## Brief change log
Catch InterruptedException and throw it when caught the InterruptedException in ChannelStateWriterThread.
## Verifying this change
This change is already covered by existing tests.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): yes
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: yes
- The serializers: yes
- The runtime per-record code paths (performance sensitive): yes
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: yes
- The S3 file system connector: yes
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not documented
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899887457
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
I agree with @zentol that this doesn't look good and I would be afraid it could lead to some resource leaks.
> Why is the dataFuture not being completed in the first place? Isn't that the real issue?
It looks to me like the issue is that `dataFuture` is being cancelled from the chain: `PipelinedSubpartition#release()` <- ... <- `ResultPartition#release` <- ... <- `NettyShuffleEnvironment#close`. Which happens after `StreamTask#cleanUp` (which is waiting for this future to complete), leading to a deadlock.
We would either need to cancel the future sooner (`StreamTask#cleanUp`?)`, or do what @zentol proposed. I think the latter is indeed a good option. We don't need to blockingly wait. Let's just not completely ignore exceptions here. Logging error should be fine.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r902304184
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
Review Comment:
We have agreed to be fine with that risk. We've had several cases where tests started to fail because certain CI mechanisms triggered the timeout (e.g., time skips).
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r902363978
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
Review Comment:
We also have a global test timeout that before killing the process is printing the thread dump. Our experience shows that timeout test failure due to a deadlock without stack traces is not helpful at all, so having timeouts on the unit test level is doing more harm than good.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899906279
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
> Why should it be interrupted?
I figured that since the other code path (from the comment above) can be interrupted, the cleanup can as well.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r901496141
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -108,12 +108,15 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
bufferConsumer.accept(writer, buffer);
}
},
- throwable -> {
- try {
- CloseableIterator.fromList(dataFuture.get(), Buffer::recycleBuffer).close();
- } catch (ExecutionException ignored) {
- }
- },
+ throwable ->
+ dataFuture.thenAccept(
+ buffers -> {
+ try {
+ CloseableIterator.fromList(buffers, Buffer::recycleBuffer)
+ .close();
+ } catch (Exception ignored) {
+ }
Review Comment:
I would log the error
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on PR #19993:
URL: https://github.com/apache/flink/pull/19993#issuecomment-1157706117
AFAICT this hasn't fixed the issue; I can still reproduce it locally.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r900807989
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -98,6 +98,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
List<Buffer> buffers;
try {
buffers = dataFuture.get();
+ } catch (InterruptedException e) {
+ writer.fail(e);
+ throw e;
Review Comment:
Hi @zentol @pnowojski , after I analyzed, I found we don't need change this.
This change compared to before just calling `writer.fail(e);` when InterruptedException is caught. The previous code did not catch InterruptedException, so it will continue to throw when InterruptedException is encountered.
We don't need call the `writer.fail(e);` when InterruptedException is caught. Because the `dispatcher.fail()` will be called before ChannelStateWriteThread dead. [code link](https://github.com/apache/flink/blob/3ae4c6f5a48105d00807e8ce02e70d4c092cbf40/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImpl.java#L83).
The dispatcher.fail will call all writers's fail() method, so I think these change isn't necessary. I will revert it in next commit. We will focus on next change, that is, improve the discardAction.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r901261999
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
Hi @zentol @pnowojski , as I understand, there are four places in ChannelStateWriterThread that may be interrupted:
1. Write a file
2. deque.take() : pull request from deque
3. dataFuture.get() in action: Write the file normally.
4. dataFuture.get() in discardAction: Executed when canceling a request.
1,2 and 3 are all executed in ChannelStateWriteRequestExecutorImpl#loop, and InterruptedException is caught in the loop, so 1, 2 and 3 will not cause job InterruptedException. But case 4 may be called by ChannelStateWriteRequestExecutorImpl#cleanupRequests without catching InterruptedException, so case 4 may cause job InterruptedException(this is the root cause of FLINK-27792).
## Why FLINK-28077? Why stuck in dataFuture.get() of the discardAction?
ChannelStateWriteRequestExecutorImpl#cleanupRequests will call the discardAction of all rest requests. The thread.interrupt() takes effect only once, if there are multiple requests that need to wait for dataFuture.get(), only the first request will be interrupted, and the remaining requests will be stuck(this is the root cause of FLINK-28077).
If it is changed to the proposal of @zentol , both FLINK-27792 and FLINK-28077 will be resolved. I have updated the PR. And I improved the test: `ChannelStateWriteRequestExecutorImplTest#testCanBeClosed`. For old code, the unit-test gets stuck in the second `dataFuture.get()`. After the change, the unit-test worked fine.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899866865
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -98,6 +98,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
List<Buffer> buffers;
try {
buffers = dataFuture.get();
+ } catch (InterruptedException e) {
+ writer.fail(e);
+ throw e;
Review Comment:
does this maybe belong rather to FLINK-27792? AFAICT this isn't required for the issue at hand.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
While this will likely solve the issue I'm not sure if it is the correct solution.
We could see in the logs that this future would eventually be completed, with several buffers being contained within. Admittedly this happened after the hosting TM shut down (so I'm not sure if it can happen in production where the JVM would go with it), but I do wonder if this couldn't cause a buffer leak.
Would there be any down-side of doing the clean-up like this:
```
dataFuture.thenAccept(
buffers -> {
try {
CloseableIterator.fromList(buffers, Buffer::recycleBuffer)
.close();
} catch (Exception e) {
}
});
```
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899880554
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
Why is the dataFuture not being completed in the first place? Isn't that the real issue?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899899066
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
> Another question I would ask is why this can even result in a TM crash; shouldn't the waiting be interrupted instead.
Why should it be interrupted? We are only using interrupts to wake up user code or 3rd party libraries. Our own code should be able to shutdown cleanly without interruptions. We even explicitly disallow SIGINTs during `StreamTask` cleanup (`StreamTask#disableInterruptOnCancel`), once task thread exists from user code as otherwise this could lead to resource leaks. If we can not clean up resources, we have to relay on the `TaskCancelerWatchDog` that will fail over whole TM after a time out.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r901630411
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
+ public void testCanBeClosed() throws Exception {
+ long checkpointId = 1L;
+ ChannelStateWriteRequestDispatcher processor =
Review Comment:
Because the TestRequestDispatcher don't call the action and discardAction. It can't reproduce this bug.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
+ public void testCanBeClosed() throws Exception {
+ long checkpointId = 1L;
+ ChannelStateWriteRequestDispatcher processor =
+ new ChannelStateWriteRequestDispatcherImpl(
+ "dummy task",
+ 0,
+ getStreamFactoryFactory(),
+ new ChannelStateSerializerImpl());
try (ChannelStateWriteRequestExecutorImpl worker =
- new ChannelStateWriteRequestExecutorImpl(TASK_NAME, requestProcessor)) {
+ new ChannelStateWriteRequestExecutorImpl(TASK_NAME, processor)) {
worker.start();
+ worker.submit(
+ new CheckpointStartRequest(
+ checkpointId,
+ new ChannelStateWriter.ChannelStateWriteResult(),
+ CheckpointStorageLocationReference.getDefault()));
+ worker.submit(
+ ChannelStateWriteRequest.write(
+ checkpointId,
+ new ResultSubpartitionInfo(0, 0),
+ new CompletableFuture<>()));
+ worker.submit(
+ ChannelStateWriteRequest.write(
+ checkpointId,
+ new ResultSubpartitionInfo(0, 0),
+ new CompletableFuture<>()));
Review Comment:
It's required, I have analyzed [here](https://github.com/apache/flink/pull/19993#discussion_r901261999).
> For old code, the unit-test gets stuck in the second dataFuture.get(). After the change, the unit-test worked fine.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899884298
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
Another question I would ask is why this can even result in a TM crash; shouldn't the waiting be interrupted instead.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on PR #19993:
URL: https://github.com/apache/flink/pull/19993#issuecomment-1159477055
@flinkbot run azure
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on PR #19993:
URL: https://github.com/apache/flink/pull/19993#issuecomment-1160209026
@flinkbot run azure
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol merged pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol merged PR #19993:
URL: https://github.com/apache/flink/pull/19993
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r901499020
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
> Do you think we can handle [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792) and [FLINK-28077](https://issues.apache.org/jira/browse/FLINK-28077) by this PR?
Yes, we can fix FLINK-28077 in this PR, and then close FLINK-27792 as for example duplicate of FLINK-28077.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899992947
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
After a second thought interrupt can probably happen in this thread, when the thread was operating normally/writing something and is being cancelled (`ChannelStateWriteRequestExecutorImpl#close`). That's fine, interrupt can be used to wake up the thread doing some normal operation (especially writing to a file that can be blocked). What definitely shouldn't happen is interrupting causing some resource leak.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r900803080
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
Hi @zentol @pnowojski , I replied in [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792). And I think the root cause of FLINK-27792 is we don't have a reasonable cleanup dataFuture in discardAction, so we should improve the discardAction.
And I think the [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792) is the same root cause as [FLINK-28077](https://issues.apache.org/jira/browse/FLINK-28077). Defective discardAction resulted in FLINK-27792 and FLINK-28077. Once this PR is done, they will be resolved.
I know this change still has some bugs, it may cause network memory leak. I will think more and think about how to solve it.
Do you think we can handle FLINK-27792 and FLINK-28077 by this PR? If anything is wrong, please correct me.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -98,6 +98,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
List<Buffer> buffers;
try {
buffers = dataFuture.get();
+ } catch (InterruptedException e) {
+ writer.fail(e);
+ throw e;
Review Comment:
Hi @zentol @pnowojski , I replied in [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792). And I think the root cause of FLINK-27792 is we don't have a reasonable cleanup dataFuture in discardAction, so we should improve the discardAction.
I improved action in this change because it is also a bug, we should continue throw InterruptedException here.
And I think this change and [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792) are different. And I think the [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792) is the same root cause as [FLINK-28077](https://issues.apache.org/jira/browse/FLINK-28077), that is next change in this PR. Defective discardAction resulted in FLINK-27792 and FLINK-28077. Once this PR is done, they will be resolved.
I know next change still has some bugs, it may cause network memory leak. I will think more and think about how to solve it. What do you think? If anything is wrong, please correct me.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899904091
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -98,6 +98,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
List<Buffer> buffers;
try {
buffers = dataFuture.get();
+ } catch (InterruptedException e) {
+ writer.fail(e);
+ throw e;
Review Comment:
I'm interpreting that ticket as a more general "how to handle InterruptedException" ticket.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899887457
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
I agree with @zentol that this doesn't look good and I would be afraid it could lead to some resource leaks.
It looks to me like the issue is that `dataFuture` is being cancelled from the chain: `PipelinedSubpartition#release()` <- ... <- `ResultPartition#release` <- ... <- `NettyShuffleEnvironment#close`. Which happens after `StreamTask#cleanUp` (which is waiting for this future to complete), leading to a deadlock.
We would either need to cancel the future sooner (`StreamTask#cleanUp`?)`, or do what @zentol proposed. I think the latter is indeed a good option. We don't need to blockingly wait. Let's just not completely ignore exceptions here. Logging error should be fine.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899893420
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -98,6 +98,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
List<Buffer> buffers;
try {
buffers = dataFuture.get();
+ } catch (InterruptedException e) {
+ writer.fail(e);
+ throw e;
Review Comment:
How do you think it's related to FLINK-27792?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r902372092
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
Review Comment:
Hi @zentol @pnowojski , thanks for your clarification. I removed 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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r900755285
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -98,6 +98,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
List<Buffer> buffers;
try {
buffers = dataFuture.get();
+ } catch (InterruptedException e) {
+ writer.fail(e);
+ throw e;
Review Comment:
Hi @zentol @pnowojski , I replied in [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792). And I think the root cause of FLINK-27792 is we don't have a reasonable cleanup dataFuture in discardAction, so we should improve the discardAction.
I improved action in this change because it is also a bug, we should continue throw InterruptedException here.
And I think this change and [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792) are different. And I think the [FLINK-27792](https://issues.apache.org/jira/browse/FLINK-27792) is the same root cause as [FLINK-28077](https://issues.apache.org/jira/browse/FLINK-28077), that is next change in this PR. Defective discardAction resulted in FLINK-27792 and FLINK-28077. Once this PR is done, they will be resolved.
I know next change still has some bugs, it may cause network memory leak. I will think more and think about how to solve it. What do you think? If anything is wrong, please correct me.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899942581
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
TBF I haven't seen an interrupt there myself; that idea is purely based on the proposed change.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r901626119
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
Review Comment:
Why don't we use timeout in tests? For old code, if don't use timeout, it will be stuck forever, so I add the timeout.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] zentol commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
zentol commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r901611238
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
Review Comment:
```suggestion
@Test
```
We don't use timeouts in tests
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
+ public void testCanBeClosed() throws Exception {
+ long checkpointId = 1L;
+ ChannelStateWriteRequestDispatcher processor =
+ new ChannelStateWriteRequestDispatcherImpl(
+ "dummy task",
+ 0,
+ getStreamFactoryFactory(),
+ new ChannelStateSerializerImpl());
try (ChannelStateWriteRequestExecutorImpl worker =
- new ChannelStateWriteRequestExecutorImpl(TASK_NAME, requestProcessor)) {
+ new ChannelStateWriteRequestExecutorImpl(TASK_NAME, processor)) {
worker.start();
+ worker.submit(
+ new CheckpointStartRequest(
+ checkpointId,
+ new ChannelStateWriter.ChannelStateWriteResult(),
+ CheckpointStorageLocationReference.getDefault()));
+ worker.submit(
+ ChannelStateWriteRequest.write(
+ checkpointId,
+ new ResultSubpartitionInfo(0, 0),
+ new CompletableFuture<>()));
+ worker.submit(
+ ChannelStateWriteRequest.write(
+ checkpointId,
+ new ResultSubpartitionInfo(0, 0),
+ new CompletableFuture<>()));
Review Comment:
Is this actually required for the test or just a duplicate?
If it isn't required I would remove it.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java:
##########
@@ -128,12 +131,33 @@ public void testIgnoresInterruptsWhileRunning() throws Exception {
}
}
- @Test
- public void testCanBeClosed() throws IOException {
- TestRequestDispatcher requestProcessor = new TestRequestDispatcher();
+ @Test(timeout = 10000)
+ public void testCanBeClosed() throws Exception {
+ long checkpointId = 1L;
+ ChannelStateWriteRequestDispatcher processor =
Review Comment:
Why can we no longer use the `TestRequestDispatcher`?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899992947
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
After a second thought interrupt can probably happen in this thread, when the thread was operating normally/writing something and is being cancelled. That's fine, interrupt can be used to wake up the thread doing some normal operation (especially writing to a file that can be blocked). What definitely shouldn't happen is interrupting causing some resource leak.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
pnowojski commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r899910882
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -109,6 +112,9 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
}
},
throwable -> {
+ if (!dataFuture.isDone()) {
+ return;
+ }
Review Comment:
Huh. It looks like interrupt should never happen there. We are/should be never interrupting the `ChannelStateWriterImpl#executor` thread.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #19993:
URL: https://github.com/apache/flink/pull/19993#issuecomment-1157564071
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "cd3efdf307aa53bc23d7066271612098e5f575e8",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "cd3efdf307aa53bc23d7066271612098e5f575e8",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* cd3efdf307aa53bc23d7066271612098e5f575e8 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on a diff in pull request #19993: [FLINK-28077][checkpoint] Fix the bug that tasks get stuck during cancellation in ChannelStateWriteRequestExecutorImpl
Posted by GitBox <gi...@apache.org>.
1996fanrui commented on code in PR #19993:
URL: https://github.com/apache/flink/pull/19993#discussion_r901562645
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java:
##########
@@ -108,12 +108,15 @@ static ChannelStateWriteRequest buildFutureWriteRequest(
bufferConsumer.accept(writer, buffer);
}
},
- throwable -> {
- try {
- CloseableIterator.fromList(dataFuture.get(), Buffer::recycleBuffer).close();
- } catch (ExecutionException ignored) {
- }
- },
+ throwable ->
+ dataFuture.thenAccept(
+ buffers -> {
+ try {
+ CloseableIterator.fromList(buffers, Buffer::recycleBuffer)
+ .close();
+ } catch (Exception ignored) {
+ }
Review Comment:
Hi @pnowojski , thanks for your review, I updated.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org