-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[FLINK-26803][checkpoint] Merging channel state files #20151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fb29b1e
to
8ac3bf9
Compare
dfa1eec
to
396ab99
Compare
9e347ea
to
f560e5f
Compare
Hi @pnowojski , please help take a look in your free time, thanks a lot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, and again sorry for the delay.
I've started reviewing the code trying to understand the big picture (I've left a couple of a minor side comments in the process), and began to wonder what's the actual threading model here?
- Each subtask has its own
ChannelStateWriter
. Created once at the start of theStreamTask
. ChannelStateWriter
is used to start, write input and output data asynchronously. Currently both, from the task thread and netty thread (that's unfortunate, it's more of a technological debt - all writes should be happening from the task thread)ChannelStateWriter
delegates all of the writes, to an instance ofChannelStateWriteRequestExecutor
- Currently a new
ChannelStateWriteRequestExecutorImpl
is created for eachChannelStateWriter
. ChannelStateWriteRequestExecutorImpl
has it's own thread doing the actual writes.ChannelStateWriteRequestExecutorImpl
is doing the writes indirectly through theChannelStateWriteRequestDispatcherImpl
. This dispatcher is wholly owned by the request executor.ChannelStateWriteRequestDispatcherImpl
actually owns theChannelStateCheckpointWriter
s, that finally encapsulate the actual data streamCheckpointStateOutputStream
.
(side note this stack is probably a bit over-engineered)
Now underneath all of that @1996fanrui, you are adding ChannelStateCheckpointStreamManager
that's binding a selected number of ChannelStateCheckpointWriter
to use a single instance of CheckpointStateOutputStream
.
Does this design make sense? Wouldn't it be simpler if instead we would limit the number of ChannelStateWriteRequestExecutorImpl
and allow various (sub)tasks to share the same ChannelStateWriteRequestExecutorImpl
instance?
In your current proposal, there is already a pre-existing thread synchronisation between ChannelStateWriterImpl
and ChannelStateWriteRequestExecutorImpl
, and you are adding another synchronisation on the lower layer between different instances of ChannelStateCheckpointWriter
. With a shared ChannelStateWriteRequestExecutorImpl
there would be no need for the second level of the synchornisation. Making the code more efficient (due to fewer synchronisation and also keeping the one writing thread per file) and also simpler with fewer opportunities for race conditions/deadlocks.
WDYT? Am I missing something?
|
||
public static final ConfigOption<Integer> CHANNEL_STATE_NUMBER_OF_TASKS_SHARE_FILE = | ||
ConfigOptions.key("execution.checkpointing.channel-state.number-of-tasks-share-file") | ||
.intType() | ||
.defaultValue(5) | ||
.withDescription( | ||
"Defines the maximum number of tasks that share the same channel state file. " | ||
+ "It can reduce the number of small files when enable unaligned checkpoint. " | ||
+ "Each task will create a new channel state file when this is configured to 1."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
task
-> subtask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that this has been actually fixed? Note, most likely also the config option should be renamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I just changed the description, I will change the config key later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
BTW, I squashed commits this time due to rebased the master branch and fixed some conflicts. I will use the separate commits when addressing comments in the future.
...time/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java
Outdated
Show resolved
Hide resolved
Hi @pnowojski , thanks for your hard review. Currently, there is one As I understand, you mean that multiple Your proposal should be clearer. I will try to refactor the code according to your proposal. Thanks again~ |
Yes, that's what I had in mind.
Great! But please keep in mind that I haven't thought it fully through and I haven't tried to implement it myself, so if you encounter some obstacles, feel free to reach out to me before going too deep! |
f560e5f
to
e00eb2a
Compare
Hi @pnowojski , I have updated the PR according to your great suggestion. |
try (ChannelStateWriteRequestExecutorImpl worker = | ||
new ChannelStateWriteRequestExecutorImpl(TASK_NAME, requestProcessor, deque)) { | ||
ChannelStateWriteRequestExecutorImpl worker = | ||
new ChannelStateWriteRequestExecutorImpl(requestProcessor, deque, JOB_ID, 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pnowojski , I'm not sure should these channel state
classes be moved to the flink-streaming-java
module?
All checkpoint-related configurations are defined in the flink-streaming-java
module, and these channel state
classes are defined in the flink-runtime
module.
These classes didn't read any configuration before, so they are well. However, It's hard to read some configurations during unit test due to flink-runtime
doesn't depend on the flink-streaming-java
module.
e00eb2a
to
33f3d53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience @1996fanrui , I've looked through most of the production code and I've left some comments. But I think I haven't spotted anything major.
.../src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
Show resolved
Hide resolved
...ime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStatePendingResult.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
Outdated
Show resolved
Hide resolved
...time/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequest.java
Outdated
Show resolved
Hide resolved
...java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestDispatcherImpl.java
Show resolved
Hide resolved
...java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestDispatcherImpl.java
Outdated
Show resolved
Hide resolved
...java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestDispatcherImpl.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorFactory.java
Outdated
Show resolved
Hide resolved
...n/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImpl.java
Outdated
Show resolved
Hide resolved
Hi @pnowojski , thanks a lot for your review, I have updated. |
8d11f65
to
2c33368
Compare
.../src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
Outdated
Show resolved
Hide resolved
7a673e9
to
ff09320
Compare
325b708
to
19d104f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates @1996fanrui. I think I have only a one or two last minor comments (this one #20151 (comment) and the while (true)
question). Could you squash the fixup commits before me doing the last pass and merging?
...n/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImpl.java
Outdated
Show resolved
Hide resolved
👍 Thanks, it looks good. Once you squash fixup commits I will do the last pass and hopefully merge. |
fb1cc52
to
cc2613c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % one comment
.../src/main/java/org/apache/flink/streaming/api/environment/ExecutionCheckpointingOptions.java
Outdated
Show resolved
Hide resolved
fixup! Address comments fixup! fixup! Address comments 1. Add some job docs 2. Using the lock to refactor the ChannelStateWriteRequestExecutorImpl fixup! fixup! fixup! Address comments
cc2613c
to
0b46716
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks a lot for your efforts @1996fanrui and your patience :)
What is the purpose of the change
Merging channel state files to reduce the pressure on DFS.
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation