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 2020/05/22 09:06:24 UTC

[GitHub] [flink] rkhachatryan opened a new pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

rkhachatryan opened a new pull request #12292:
URL: https://github.com/apache/flink/pull/12292


   ## What is the purpose of the change
   
   If Unaligned checkpoints are enabled, channel state is written as state handles. Each channel has a handle and each such handle references the same underlying `streamStateHandle` (this is done to have a single file per subtask).
   But, if the state is less then `state.backend.fs.memory-threshold`, the data is sent directly to JM as a byteStreamHandle. This causes each channel state handle to hold the whole subtask state. 
   
   This PR solves this by extracting relevant potions of the underlying handles if they are `byteStreamHandle`s.
   
   Another approach would be to move the underlying state handle one level up (`OperatorSubtaskState`) and not store references to it in `channelStateHandles`. It would be more effective (less data duplication) but also more error-prone (implicit structure), less flexible (re-scaling), and require more changes.
   
   ## Verifying this change
   
   This change is already covered by existing tests, such as:
    - `ChannelStateCheckpointWriterTest.testRecordingOffsets` (the test was corrected)
    - `ChannelPersistenceITCase`
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632589110


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2037",
       "triggerID" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5 UNKNOWN
   * 14a727ce1da1b9694b27db841548cdee4b7a145c Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2037) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] rkhachatryan commented on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
rkhachatryan commented on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-633727252


   
   Thanks for the feedback @pnowojski ,
   
   I've addressed the issues (except [this one](https://github.com/apache/flink/pull/12292#discussion_r429887132)).
   
   Answering your question:
   > Could you elaborate a bit more? What's the alternative? How would it avoid more data duplication? Are we still duplicating data with this PR?
   
   Current structure is the following (this PR doesn't change it):
   ```
   Each subtask reports to JM TaskStateSnapshot, 
       each with zero ore more OperatorSubtaskState,
           each with zero or more InputChannelStateHandle and ResultSubpartitionStateHandle
               each referencing an underlying StreamStateHandle
   ```
   The underlying `StreamStateHandle` duplicates filename (`ByteStreamStateHandle` has it too at least because of `equals/hashcode` I guess).
   
   An alternative would be something like 
   ```
   Each subtask reports to JM TaskStateSnapshot, 
       each with zero ore more OperatorSubtaskState,
           each with zero or one StreamStateHandle for channel state handles
               each with zero or more InputChannelStateHandle and ResultSubpartitionStateHandle
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] rkhachatryan edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
rkhachatryan edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-633727252


   Thanks for the feedback @pnowojski ,
   
   I've addressed the issues (except [this one](https://github.com/apache/flink/pull/12292#discussion_r429887132)).
   
   Answering your question:
   > Could you elaborate a bit more? What's the alternative? How would it avoid more data duplication? Are we still duplicating data with this PR?
   
   Current structure is the following (this PR doesn't change it):
   ```
   Each subtask reports to JM TaskStateSnapshot, 
       each with zero ore more OperatorSubtaskState,
           each with zero or more InputChannelStateHandle and ResultSubpartitionStateHandle
               each referencing an underlying StreamStateHandle
   ```
   The underlying `StreamStateHandle` duplicates filename (`ByteStreamStateHandle` has it too at least because of `equals/hashcode` I guess).
   
   An alternative would be something like 
   ```
   Each subtask reports to JM TaskStateSnapshot, 
       each with zero ore more OperatorSubtaskState,
           each with zero or one StreamStateHandle (for channel state)
           each with zero or more InputChannelStateHandle and ResultSubpartitionStateHandle
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] rkhachatryan commented on a change in pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
rkhachatryan commented on a change in pull request #12292:
URL: https://github.com/apache/flink/pull/12292#discussion_r431115232



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -180,17 +177,33 @@ private void doComplete(boolean precondition, RunnableWithException complete, Ru
 	}
 
 	private <I, H extends AbstractChannelStateHandle<I>> void complete(
+			StreamStateHandle underlying,
 			CompletableFuture<Collection<H>> future,
 			Map<I, List<Long>> offsets,
-			BiFunction<I, List<Long>, H> buildHandle) {
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle) throws IOException {
 		final Collection<H> handles = new ArrayList<>();
 		for (Map.Entry<I, List<Long>> e : offsets.entrySet()) {
-			handles.add(buildHandle.apply(e.getKey(), e.getValue()));
+			handles.add(createHandle(underlying, buildHandle, e));
 		}
 		future.complete(handles);
 		LOG.debug("channel state write completed, checkpointId: {}, handles: {}", checkpointId, handles);
 	}
 
+	private <I, H extends AbstractChannelStateHandle<I>> H createHandle(
+			StreamStateHandle underlying,
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle,
+			Map.Entry<I, List<Long>> e) throws IOException {
+		if (underlying instanceof ByteStreamStateHandle) {
+			ByteStreamStateHandle byteHandle = (ByteStreamStateHandle) underlying;
+			return buildHandle.apply(
+				e.getKey(),
+				new ByteStreamStateHandle(randomUUID().toString(), serializer.extractAndMerge(byteHandle.getData(), e.getValue())),
+				singletonList(serializer.getHeaderLength()));
+		} else {

Review comment:
       Sure. Created a JIRA ticket: https://issues.apache.org/jira/browse/FLINK-17972




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632589110


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2037",
       "triggerID" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1d9ab48b4bd4f2b3716395ff957219d19bf31406",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2164",
       "triggerID" : "1d9ab48b4bd4f2b3716395ff957219d19bf31406",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c9a38feee02d024ec7b7b0c802d719dd87be5768",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2165",
       "triggerID" : "c9a38feee02d024ec7b7b0c802d719dd87be5768",
       "triggerType" : "PUSH"
     }, {
       "hash" : "38147507364719598ec876a350e4e647c09c5eec",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2235",
       "triggerID" : "38147507364719598ec876a350e4e647c09c5eec",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7cbe552521e89e29402da14b4f5437f365514b0c",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2290",
       "triggerID" : "7cbe552521e89e29402da14b4f5437f365514b0c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5 UNKNOWN
   * 7cbe552521e89e29402da14b4f5437f365514b0c Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2290) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] pnowojski commented on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
pnowojski commented on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-634609613


   My questions probing in the direction of single channel state handle seems to be going in a very similar direction as the alternate solution that you proposed: moving the shared `StreamStateHandle` one level up, but also additionally encapsulating them into something, for example:
   
   ```
   Each subtask reports to JM TaskStateSnapshot, 
       each with zero ore more OperatorSubtaskState,
           each with zero or one InFlightDataStateHandle
               each with one StreamStateHandle
               each with zero or more InputChannelStateHandle and ResultSubpartitionStateHandle
   ```
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] pnowojski commented on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
pnowojski commented on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-635128589


   Merging from https://github.com/apache/flink/pull/12362 . Build was successful there, here e2e timed out because of getting artefacts from mvn cache took very long time


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] rkhachatryan commented on a change in pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
rkhachatryan commented on a change in pull request #12292:
URL: https://github.com/apache/flink/pull/12292#discussion_r430065985



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -25,8 +25,10 @@
 import org.apache.flink.runtime.state.InputChannelStateHandle;

Review comment:
       > some more elaborate explanation what was the underlying problem
   
   I've updated PR description since then, does it look good to you now?

##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriterTest.java
##########
@@ -149,8 +152,8 @@ public void testRecordingOffsets() throws Exception {
 	}
 
 	private void write(ChannelStateCheckpointWriter writer, InputChannelInfo channelInfo, byte[] data) throws Exception {
-		NetworkBuffer buffer = new NetworkBuffer(HeapMemorySegment.FACTORY.allocateUnpooledSegment(data.length, null), FreeingBufferRecycler.INSTANCE);
-		buffer.setBytes(0, data);
+		MemorySegment segment = wrap(data);
+		NetworkBuffer buffer = new NetworkBuffer(segment, FreeingBufferRecycler.INSTANCE, Buffer.DataType.DATA_BUFFER, segment.size());

Review comment:
       Writer position of `NetworkBuffer` wasn't updated.This change updates it by passing `segment.size()` to constructor.
   
   Updated commit message.

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -180,17 +177,33 @@ private void doComplete(boolean precondition, RunnableWithException complete, Ru
 	}
 
 	private <I, H extends AbstractChannelStateHandle<I>> void complete(
+			StreamStateHandle underlying,
 			CompletableFuture<Collection<H>> future,
 			Map<I, List<Long>> offsets,
-			BiFunction<I, List<Long>, H> buildHandle) {
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle) throws IOException {

Review comment:
       Totally agree.
   Extracted `HandleFactory` interface and replaced `Map.Entry` with two arguments.

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -180,17 +177,33 @@ private void doComplete(boolean precondition, RunnableWithException complete, Ru
 	}
 
 	private <I, H extends AbstractChannelStateHandle<I>> void complete(
+			StreamStateHandle underlying,
 			CompletableFuture<Collection<H>> future,
 			Map<I, List<Long>> offsets,
-			BiFunction<I, List<Long>, H> buildHandle) {
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle) throws IOException {
 		final Collection<H> handles = new ArrayList<>();
 		for (Map.Entry<I, List<Long>> e : offsets.entrySet()) {
-			handles.add(buildHandle.apply(e.getKey(), e.getValue()));
+			handles.add(createHandle(underlying, buildHandle, e));
 		}
 		future.complete(handles);
 		LOG.debug("channel state write completed, checkpointId: {}, handles: {}", checkpointId, handles);
 	}
 
+	private <I, H extends AbstractChannelStateHandle<I>> H createHandle(
+			StreamStateHandle underlying,
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle,
+			Map.Entry<I, List<Long>> e) throws IOException {
+		if (underlying instanceof ByteStreamStateHandle) {
+			ByteStreamStateHandle byteHandle = (ByteStreamStateHandle) underlying;
+			return buildHandle.apply(
+				e.getKey(),
+				new ByteStreamStateHandle(randomUUID().toString(), serializer.extractAndMerge(byteHandle.getData(), e.getValue())),
+				singletonList(serializer.getHeaderLength()));
+		} else {

Review comment:
       Added `StreamStateHandle.asBytesIfInMemory` that returns `Optional<byte[]>` (better names are welcomed ;)
   
   > Why is this issue new for spilled channel state? What's different for operators state?
   
   Operators don't share state handles with each other so they don't have this problem.

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -180,17 +177,33 @@ private void doComplete(boolean precondition, RunnableWithException complete, Ru
 	}
 
 	private <I, H extends AbstractChannelStateHandle<I>> void complete(
+			StreamStateHandle underlying,
 			CompletableFuture<Collection<H>> future,
 			Map<I, List<Long>> offsets,
-			BiFunction<I, List<Long>, H> buildHandle) {
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle) throws IOException {
 		final Collection<H> handles = new ArrayList<>();
 		for (Map.Entry<I, List<Long>> e : offsets.entrySet()) {
-			handles.add(buildHandle.apply(e.getKey(), e.getValue()));
+			handles.add(createHandle(underlying, buildHandle, e));
 		}
 		future.complete(handles);
 		LOG.debug("channel state write completed, checkpointId: {}, handles: {}", checkpointId, handles);
 	}
 
+	private <I, H extends AbstractChannelStateHandle<I>> H createHandle(
+			StreamStateHandle underlying,
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle,
+			Map.Entry<I, List<Long>> e) throws IOException {
+		if (underlying instanceof ByteStreamStateHandle) {
+			ByteStreamStateHandle byteHandle = (ByteStreamStateHandle) underlying;
+			return buildHandle.apply(
+				e.getKey(),
+				new ByteStreamStateHandle(randomUUID().toString(), serializer.extractAndMerge(byteHandle.getData(), e.getValue())),
+				singletonList(serializer.getHeaderLength()));
+		} else {

Review comment:
       There is only one `InputChannelStateHandle` per channel.
   Putting multiple channels could make recovery (rescaling) more difficult.

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -25,8 +25,10 @@
 import org.apache.flink.runtime.state.InputChannelStateHandle;

Review comment:
       Done.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] pnowojski edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
pnowojski edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-634609613


   My questions probing in the direction of single channel state handle seems to be going in a very similar direction as the alternate solution that you proposed: moving the shared `StreamStateHandle` one level up, but also additionally encapsulating them into something, for example:
   
   ```
   Each subtask reports to JM TaskStateSnapshot, 
       each with zero ore more OperatorSubtaskState,
           each with zero or one InFlightDataStateHandle
               each with one (or more for rescaling) StreamStateHandle
               each with zero or more InputChannelStateHandle and ResultSubpartitionStateHandle
   ```
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] pnowojski closed pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
pnowojski closed pull request #12292:
URL: https://github.com/apache/flink/pull/12292


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632589110


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5 UNKNOWN
   * 14a727ce1da1b9694b27db841548cdee4b7a145c UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632589110






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632589110


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2037",
       "triggerID" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5 UNKNOWN
   * 14a727ce1da1b9694b27db841548cdee4b7a145c Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2037) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632589110


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632589110


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2037",
       "triggerID" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1d9ab48b4bd4f2b3716395ff957219d19bf31406",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2164",
       "triggerID" : "1d9ab48b4bd4f2b3716395ff957219d19bf31406",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c9a38feee02d024ec7b7b0c802d719dd87be5768",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2165",
       "triggerID" : "c9a38feee02d024ec7b7b0c802d719dd87be5768",
       "triggerType" : "PUSH"
     }, {
       "hash" : "38147507364719598ec876a350e4e647c09c5eec",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2235",
       "triggerID" : "38147507364719598ec876a350e4e647c09c5eec",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7cbe552521e89e29402da14b4f5437f365514b0c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7cbe552521e89e29402da14b4f5437f365514b0c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5 UNKNOWN
   * 38147507364719598ec876a350e4e647c09c5eec Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2235) 
   * 7cbe552521e89e29402da14b4f5437f365514b0c UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] rkhachatryan commented on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
rkhachatryan commented on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-634976057


   @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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632589110


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2037",
       "triggerID" : "14a727ce1da1b9694b27db841548cdee4b7a145c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1d9ab48b4bd4f2b3716395ff957219d19bf31406",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2164",
       "triggerID" : "1d9ab48b4bd4f2b3716395ff957219d19bf31406",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c9a38feee02d024ec7b7b0c802d719dd87be5768",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2165",
       "triggerID" : "c9a38feee02d024ec7b7b0c802d719dd87be5768",
       "triggerType" : "PUSH"
     }, {
       "hash" : "38147507364719598ec876a350e4e647c09c5eec",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2235",
       "triggerID" : "38147507364719598ec876a350e4e647c09c5eec",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7cbe552521e89e29402da14b4f5437f365514b0c",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2290",
       "triggerID" : "7cbe552521e89e29402da14b4f5437f365514b0c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5 UNKNOWN
   * 38147507364719598ec876a350e4e647c09c5eec Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2235) 
   * 7cbe552521e89e29402da14b4f5437f365514b0c Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2290) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] pnowojski commented on a change in pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
pnowojski commented on a change in pull request #12292:
URL: https://github.com/apache/flink/pull/12292#discussion_r431057780



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -180,17 +177,33 @@ private void doComplete(boolean precondition, RunnableWithException complete, Ru
 	}
 
 	private <I, H extends AbstractChannelStateHandle<I>> void complete(
+			StreamStateHandle underlying,
 			CompletableFuture<Collection<H>> future,
 			Map<I, List<Long>> offsets,
-			BiFunction<I, List<Long>, H> buildHandle) {
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle) throws IOException {
 		final Collection<H> handles = new ArrayList<>();
 		for (Map.Entry<I, List<Long>> e : offsets.entrySet()) {
-			handles.add(buildHandle.apply(e.getKey(), e.getValue()));
+			handles.add(createHandle(underlying, buildHandle, e));
 		}
 		future.complete(handles);
 		LOG.debug("channel state write completed, checkpointId: {}, handles: {}", checkpointId, handles);
 	}
 
+	private <I, H extends AbstractChannelStateHandle<I>> H createHandle(
+			StreamStateHandle underlying,
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle,
+			Map.Entry<I, List<Long>> e) throws IOException {
+		if (underlying instanceof ByteStreamStateHandle) {
+			ByteStreamStateHandle byteHandle = (ByteStreamStateHandle) underlying;
+			return buildHandle.apply(
+				e.getKey(),
+				new ByteStreamStateHandle(randomUUID().toString(), serializer.extractAndMerge(byteHandle.getData(), e.getValue())),
+				singletonList(serializer.getHeaderLength()));
+		} else {

Review comment:
       After an offline discussion, we decided to keep it for now as it is. Could you create a JIRA ticket to revisit this issue later (linked to how to handle rescaling) and linked it as `TODO` here? 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] pnowojski commented on a change in pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
pnowojski commented on a change in pull request #12292:
URL: https://github.com/apache/flink/pull/12292#discussion_r430645868



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -25,8 +25,10 @@
 import org.apache.flink.runtime.state.InputChannelStateHandle;

Review comment:
       Thanks, now it's better :) Could you copy this updated description  to commit message and jira ticket?

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -180,17 +177,33 @@ private void doComplete(boolean precondition, RunnableWithException complete, Ru
 	}
 
 	private <I, H extends AbstractChannelStateHandle<I>> void complete(
+			StreamStateHandle underlying,
 			CompletableFuture<Collection<H>> future,
 			Map<I, List<Long>> offsets,
-			BiFunction<I, List<Long>, H> buildHandle) {
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle) throws IOException {
 		final Collection<H> handles = new ArrayList<>();
 		for (Map.Entry<I, List<Long>> e : offsets.entrySet()) {
-			handles.add(buildHandle.apply(e.getKey(), e.getValue()));
+			handles.add(createHandle(underlying, buildHandle, e));
 		}
 		future.complete(handles);
 		LOG.debug("channel state write completed, checkpointId: {}, handles: {}", checkpointId, handles);
 	}
 
+	private <I, H extends AbstractChannelStateHandle<I>> H createHandle(
+			StreamStateHandle underlying,
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle,
+			Map.Entry<I, List<Long>> e) throws IOException {
+		if (underlying instanceof ByteStreamStateHandle) {
+			ByteStreamStateHandle byteHandle = (ByteStreamStateHandle) underlying;
+			return buildHandle.apply(
+				e.getKey(),
+				new ByteStreamStateHandle(randomUUID().toString(), serializer.extractAndMerge(byteHandle.getData(), e.getValue())),
+				singletonList(serializer.getHeaderLength()));
+		} else {

Review comment:
       I think it's better now, but I still can not put a finger on a feeling that something might not be entirely correct. 
   
   Why do we have multiple handles per channel, instead of a single handle that has multiple channels?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] pnowojski commented on a change in pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
pnowojski commented on a change in pull request #12292:
URL: https://github.com/apache/flink/pull/12292#discussion_r429886453



##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriterTest.java
##########
@@ -149,8 +152,8 @@ public void testRecordingOffsets() throws Exception {
 	}
 
 	private void write(ChannelStateCheckpointWriter writer, InputChannelInfo channelInfo, byte[] data) throws Exception {
-		NetworkBuffer buffer = new NetworkBuffer(HeapMemorySegment.FACTORY.allocateUnpooledSegment(data.length, null), FreeingBufferRecycler.INSTANCE);
-		buffer.setBytes(0, data);
+		MemorySegment segment = wrap(data);
+		NetworkBuffer buffer = new NetworkBuffer(segment, FreeingBufferRecycler.INSTANCE, Buffer.DataType.DATA_BUFFER, segment.size());

Review comment:
       What was the problem here? Could you explain it in the commit message?

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -25,8 +25,10 @@
 import org.apache.flink.runtime.state.InputChannelStateHandle;

Review comment:
       Please copy the PR description to the commit message of this (last one) commit.
   
   Could you also extend both those descriptions and JIRA ticket description (copy/paste) with some more elaborate explanation what was the underlying problem? 
   
   > That the buffered bytes in `StreamStateHandle underlying` (if it's a `ByteStreamStateHandle`) would be referenced many times, one per each input channel and result partition by respective `InputChannelStateHandle` and `ResultSubpartitionStateHandle` handles. Each of those handles would thus duplicate and contain all of the data for every channel, while using only a small portion of it.

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -180,17 +177,33 @@ private void doComplete(boolean precondition, RunnableWithException complete, Ru
 	}
 
 	private <I, H extends AbstractChannelStateHandle<I>> void complete(
+			StreamStateHandle underlying,
 			CompletableFuture<Collection<H>> future,
 			Map<I, List<Long>> offsets,
-			BiFunction<I, List<Long>, H> buildHandle) {
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle) throws IOException {

Review comment:
       Those two functions (`complete` and `createHandle` are) quite difficult to understand/read. For example by looking at the signature 
   
   ```
   	private <I, H extends AbstractChannelStateHandle<I>> H createHandle(
   			StreamStateHandle underlying,
   			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle,
   			Map.Entry<I, List<Long>> e)
   ```
   
   I have no idea what's happening here.
   
   I would at the very least:
   1. either extract `buildHandle` to some factory/builder or just replace it by a boolean flag `boolean buildInputHandles`/enum  `INPUT_HANDLE`/`OUTPUT_HANDLE` and just if/switch inside.
   2. do not pass `Map.Entry`, but convert it to a POJO or named variables ASAP

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateCheckpointWriter.java
##########
@@ -180,17 +177,33 @@ private void doComplete(boolean precondition, RunnableWithException complete, Ru
 	}
 
 	private <I, H extends AbstractChannelStateHandle<I>> void complete(
+			StreamStateHandle underlying,
 			CompletableFuture<Collection<H>> future,
 			Map<I, List<Long>> offsets,
-			BiFunction<I, List<Long>, H> buildHandle) {
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle) throws IOException {
 		final Collection<H> handles = new ArrayList<>();
 		for (Map.Entry<I, List<Long>> e : offsets.entrySet()) {
-			handles.add(buildHandle.apply(e.getKey(), e.getValue()));
+			handles.add(createHandle(underlying, buildHandle, e));
 		}
 		future.complete(handles);
 		LOG.debug("channel state write completed, checkpointId: {}, handles: {}", checkpointId, handles);
 	}
 
+	private <I, H extends AbstractChannelStateHandle<I>> H createHandle(
+			StreamStateHandle underlying,
+			TriFunction<I, StreamStateHandle, List<Long>, H> buildHandle,
+			Map.Entry<I, List<Long>> e) throws IOException {
+		if (underlying instanceof ByteStreamStateHandle) {
+			ByteStreamStateHandle byteHandle = (ByteStreamStateHandle) underlying;
+			return buildHandle.apply(
+				e.getKey(),
+				new ByteStreamStateHandle(randomUUID().toString(), serializer.extractAndMerge(byteHandle.getData(), e.getValue())),
+				singletonList(serializer.getHeaderLength()));
+		} else {

Review comment:
       It doesn't look like a generic/error prone solution. It looks like something should be extracted to the `StreamStateHandle`. `boolean StreamStateHandle#isDirectlyHoldingData()`? Or we are missing some kind of different abstraction of shared state handles.
   
   Why is this issue new for spilled channel state? What's different for operators state?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #12292: [FLINK-17861][task][checkpointing] Split channel state handles sent to JM

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12292:
URL: https://github.com/apache/flink/pull/12292#issuecomment-632585735


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit 96bfb4fb2ba3bb8d147055d6d67125d0ca43edf5 (Fri May 22 09:08:06 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org