[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r400313413 ## File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/ChannelStateHandleSerializer.java ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.checkpoint.metadata; + +import org.apache.flink.runtime.checkpoint.channel.InputChannelInfo; +import org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo; +import org.apache.flink.runtime.state.AbstractChannelStateHandle; +import org.apache.flink.runtime.state.InputChannelStateHandle; +import org.apache.flink.runtime.state.ResultSubpartitionStateHandle; +import org.apache.flink.runtime.state.StreamStateHandle; +import org.apache.flink.util.function.BiConsumerWithException; +import org.apache.flink.util.function.FunctionWithException; +import org.apache.flink.util.function.TriFunctionWithException; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.apache.flink.runtime.checkpoint.metadata.MetadataV2V3SerializerBase.deserializeStreamStateHandle; +import static org.apache.flink.runtime.checkpoint.metadata.MetadataV2V3SerializerBase.serializeStreamStateHandle; + +class ChannelStateHandleSerializer { + + public void serialize(ResultSubpartitionStateHandle handle, DataOutputStream dos) throws IOException { + serializeChannelStateHandle(handle, dos, (info, dataOutputStream) -> { Review comment: rename `dataOutputStream` to `ignored` to not confuse it with `dos`? 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r397978499 ## File path: flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinatorFailureTest.java ## @@ -116,6 +122,8 @@ public void testFailingCompletedCheckpointStoreAdd() throws Exception { verify(operatorSubtaskState.getRawOperatorState().iterator().next()).discardState(); verify(operatorSubtaskState.getManagedKeyedState().iterator().next()).discardState(); verify(operatorSubtaskState.getRawKeyedState().iterator().next()).discardState(); + verify(operatorSubtaskState.getInputChannelState().iterator().next()).discardState(); + verify(operatorSubtaskState.getResultSubpartitionState().iterator().next()).discardState(); Review comment: I'm not asking to rewrite the whole test (although that would be nice ;) ). Having said that, I would prefer to have mixed test instead of increasing our dependency on the mockito, as this is adding more and more technological debt. Also we have lot's of existing tests that are mixing mockito mocked classes with proper classes, so I don't think this is an issue. But if you have really strong opposite feeling, I can drop this comment - that's just 6 lines of extra technological debt. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r397979288 ## File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV3Serializer.java ## @@ -115,4 +120,31 @@ protected OperatorState deserializeOperatorState(DataInputStream dis) throws IOE return operatorState; } + + @VisibleForTesting + @Override + public void serializeResultSubpartitionStateHandle(ResultSubpartitionStateHandle handle, DataOutputStream dos) throws IOException { + channelStateHandleSerializer.serialize(handle, dos); + } + + @VisibleForTesting + @Override + public ResultSubpartitionStateHandle deserializeResultSubpartitionStateHandle(DataInputStream dis) throws IOException { + final boolean hasResultSubpartitionStateHandle = dis.readInt() != 0; Review comment: Ok. Do we have proper test coverage for backward compatibility? Is it going to be covered by existing `***MigrationTest`? 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r397979288 ## File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV3Serializer.java ## @@ -115,4 +120,31 @@ protected OperatorState deserializeOperatorState(DataInputStream dis) throws IOE return operatorState; } + + @VisibleForTesting + @Override + public void serializeResultSubpartitionStateHandle(ResultSubpartitionStateHandle handle, DataOutputStream dos) throws IOException { + channelStateHandleSerializer.serialize(handle, dos); + } + + @VisibleForTesting + @Override + public ResultSubpartitionStateHandle deserializeResultSubpartitionStateHandle(DataInputStream dis) throws IOException { + final boolean hasResultSubpartitionStateHandle = dis.readInt() != 0; Review comment: Ok. Do we have proper test coverage for backward compatibility? 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r397978499 ## File path: flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinatorFailureTest.java ## @@ -116,6 +122,8 @@ public void testFailingCompletedCheckpointStoreAdd() throws Exception { verify(operatorSubtaskState.getRawOperatorState().iterator().next()).discardState(); verify(operatorSubtaskState.getManagedKeyedState().iterator().next()).discardState(); verify(operatorSubtaskState.getRawKeyedState().iterator().next()).discardState(); + verify(operatorSubtaskState.getInputChannelState().iterator().next()).discardState(); + verify(operatorSubtaskState.getResultSubpartitionState().iterator().next()).discardState(); Review comment: I'm not asking to rewrite the whole test (although that would be nice ;) ). Having said that, I would prefer to have mixed test instead of increasing our dependency on the mockito, as this is adding more and more technological debt. Also we have lot's of existing tests that are mixing mockito mocked classes with proper classes, so I don't think this is an 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r396988193 ## File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/api/operators/OperatorSnapshotFuturesTest.java ## @@ -64,22 +66,36 @@ public void testCancelAndCleanup() throws Exception { SnapshotResult operatorStateRawResult = SnapshotResult.of(operatorRawStateHandle); RunnableFuture> operatorStateRawFuture = spy(DoneFuture.of(operatorStateRawResult)); + InputChannelStateHandle inputChannelRawStateHandle = mock(InputChannelStateHandle.class); + SnapshotResult inputChannelStateRawResult = SnapshotResult.of(inputChannelRawStateHandle); + RunnableFuture> inputChannelStateRawFuture = spy(DoneFuture.of(inputChannelStateRawResult)); + + ResultSubpartitionStateHandle resultSubpartitionRawStateHandle = mock(ResultSubpartitionStateHandle.class); + SnapshotResult resultSubpartitionStateRawResult = SnapshotResult.of(resultSubpartitionRawStateHandle); + RunnableFuture> resultSubpartitionStateRawFuture = spy(DoneFuture.of(resultSubpartitionStateRawResult)); + operatorSnapshotResult = new OperatorSnapshotFutures( keyedStateManagedFuture, keyedStateRawFuture, operatorStateManagedFuture, - operatorStateRawFuture); + operatorStateRawFuture, + inputChannelStateRawFuture, + resultSubpartitionStateRawFuture); operatorSnapshotResult.cancel(); verify(keyedStateManagedFuture).cancel(true); verify(keyedStateRawFuture).cancel(true); verify(operatorStateManagedFuture).cancel(true); verify(operatorStateRawFuture).cancel(true); + verify(inputChannelStateRawFuture).cancel(true); + verify(resultSubpartitionStateRawFuture).cancel(true); Review comment: ditto about using mockito 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r396985220 ## File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/ChannelStateHandleSerializer.java ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.checkpoint.metadata; + +import org.apache.flink.runtime.checkpoint.channel.InputChannelInfo; +import org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo; +import org.apache.flink.runtime.state.AbstractChannelStateHandle; +import org.apache.flink.runtime.state.InputChannelStateHandle; +import org.apache.flink.runtime.state.ResultSubpartitionStateHandle; +import org.apache.flink.runtime.state.StreamStateHandle; +import org.apache.flink.util.function.BiConsumerWithException; +import org.apache.flink.util.function.FunctionWithException; +import org.apache.flink.util.function.TriFunctionWithException; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.apache.flink.runtime.checkpoint.metadata.MetadataV2V3SerializerBase.deserializeStreamStateHandle; +import static org.apache.flink.runtime.checkpoint.metadata.MetadataV2V3SerializerBase.serializeStreamStateHandle; + +class ChannelStateHandleSerializer { + + public void serialize(ResultSubpartitionStateHandle handle, DataOutputStream dos) throws IOException { Review comment: Maybe `%s/dos/out/g`? I know that this is the pre-existing convention here, so it's optional. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r396985331 ## File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/ChannelStateHandleSerializer.java ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.checkpoint.metadata; + +import org.apache.flink.runtime.checkpoint.channel.InputChannelInfo; +import org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo; +import org.apache.flink.runtime.state.AbstractChannelStateHandle; +import org.apache.flink.runtime.state.InputChannelStateHandle; +import org.apache.flink.runtime.state.ResultSubpartitionStateHandle; +import org.apache.flink.runtime.state.StreamStateHandle; +import org.apache.flink.util.function.BiConsumerWithException; +import org.apache.flink.util.function.FunctionWithException; +import org.apache.flink.util.function.TriFunctionWithException; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.apache.flink.runtime.checkpoint.metadata.MetadataV2V3SerializerBase.deserializeStreamStateHandle; +import static org.apache.flink.runtime.checkpoint.metadata.MetadataV2V3SerializerBase.serializeStreamStateHandle; + +class ChannelStateHandleSerializer { + + public void serialize(ResultSubpartitionStateHandle handle, DataOutputStream dos) throws IOException { + serializeChannelStateHandle(handle, dos, (info, dataOutputStream) -> { + dos.writeInt(info.getPartitionIdx()); + dos.writeInt(info.getSubPartitionIdx()); + }); + } + + ResultSubpartitionStateHandle deserializeResultSubpartitionStateHandle(DataInputStream dis) throws IOException { Review comment: `%s/dis/input/g || %s/dis/in/g`? I know that this is the pre-existing convention here, so it's optional. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r396985973 ## File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/ChannelStateHandleSerializer.java ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.checkpoint.metadata; + +import org.apache.flink.runtime.checkpoint.channel.InputChannelInfo; +import org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo; +import org.apache.flink.runtime.state.AbstractChannelStateHandle; +import org.apache.flink.runtime.state.InputChannelStateHandle; +import org.apache.flink.runtime.state.ResultSubpartitionStateHandle; +import org.apache.flink.runtime.state.StreamStateHandle; +import org.apache.flink.util.function.BiConsumerWithException; +import org.apache.flink.util.function.FunctionWithException; +import org.apache.flink.util.function.TriFunctionWithException; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.apache.flink.runtime.checkpoint.metadata.MetadataV2V3SerializerBase.deserializeStreamStateHandle; +import static org.apache.flink.runtime.checkpoint.metadata.MetadataV2V3SerializerBase.serializeStreamStateHandle; + +class ChannelStateHandleSerializer { + + public void serialize(ResultSubpartitionStateHandle handle, DataOutputStream dos) throws IOException { + serializeChannelStateHandle(handle, dos, (info, dataOutputStream) -> { Review comment: `dos` & `dataOutputStream`? 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r396987261 ## File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/InputChannelStateHandle.java ## @@ -16,11 +15,23 @@ * limitations under the License. */ +package org.apache.flink.runtime.state; + +import org.apache.flink.annotation.Internal; import org.apache.flink.runtime.checkpoint.channel.InputChannelInfo; +import java.util.List; + /** * {@link StateObject Handle} to an {@link org.apache.flink.runtime.io.network.partition.consumer.InputChannel InputChannel} state. */ -public interface InputChannelStateHandle extends StateObject { - InputChannelInfo getInputChannelInfo(); +@Internal +// not final for mockito +public /*final*/ class InputChannelStateHandle extends AbstractChannelStateHandle { Review comment: I would drop ``` // not final for mockito /*final*/ ``` comments. They can do 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r396984602 ## File path: flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinatorFailureTest.java ## @@ -116,6 +122,8 @@ public void testFailingCompletedCheckpointStoreAdd() throws Exception { verify(operatorSubtaskState.getRawOperatorState().iterator().next()).discardState(); verify(operatorSubtaskState.getManagedKeyedState().iterator().next()).discardState(); verify(operatorSubtaskState.getRawKeyedState().iterator().next()).discardState(); + verify(operatorSubtaskState.getInputChannelState().iterator().next()).discardState(); + verify(operatorSubtaskState.getResultSubpartitionState().iterator().next()).discardState(); Review comment: instead of using mockito you can inject test implementations 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
pnowojski commented on a change in pull request #11491: [FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata URL: https://github.com/apache/flink/pull/11491#discussion_r396993972 ## File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/metadata/MetadataV3Serializer.java ## @@ -115,4 +120,31 @@ protected OperatorState deserializeOperatorState(DataInputStream dis) throws IOE return operatorState; } + + @VisibleForTesting + @Override + public void serializeResultSubpartitionStateHandle(ResultSubpartitionStateHandle handle, DataOutputStream dos) throws IOException { + channelStateHandleSerializer.serialize(handle, dos); + } + + @VisibleForTesting + @Override + public ResultSubpartitionStateHandle deserializeResultSubpartitionStateHandle(DataInputStream dis) throws IOException { + final boolean hasResultSubpartitionStateHandle = dis.readInt() != 0; Review comment: are you sure that `dis.readInt() != 0` is good enough check to maintain backward compatibility? Do we have test coverage for that? 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: us...@infra.apache.org With regards, Apache Git Services