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/07/09 14:57:00 UTC

[GitHub] [flink] leozhangsr opened a new pull request, #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

leozhangsr opened a new pull request, #20234:
URL: https://github.com/apache/flink/pull/20234

   ## What is the purpose of the change
   Stopping offset can be 0.When we make a zero stopping offset empty,it would be serialized to NO_STOPPING_OFFSET, which it is not expected.
   
   ## Brief change log
   change a stopping offset conditon from '>0' to '>=0'
   
   ## Verifying this change
   This change is a trivial rework / code cleanup without any test coverage.
   
   
   ## 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, 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 / docs / JavaDocs / 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] leozhangsr commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1198311063

   > Squashed and merged to master [55fc7fa](https://github.com/apache/flink/commit/55fc7fa95aae4304a8694c03adf79d0a609918b1)
   > 
   > @leozhangsr Could you create another two PRs to backport this patch to release-1.14 and release-1.15?
   
   Glad to help!
   
   [release-1.14]:https://github.com/apache/flink/pull/20387
   [release-1.15]:https://github.com/apache/flink/pull/20389


-- 
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] PatrickRen commented on a diff in pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
PatrickRen commented on code in PR #20234:
URL: https://github.com/apache/flink/pull/20234#discussion_r923098905


##########
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/split/KafkaPartitionSplitSerializerTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.connector.kafka.source.split;
+
+import org.apache.kafka.common.TopicPartition;
+import org.assertj.core.util.Lists;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link KafkaPartitionSplitSerializer}. */
+public class KafkaPartitionSplitSerializerTest {

Review Comment:
   Thanks for the reply @leozhangsr. I still think it's necessary to have a case testing stopping offset = 0 (step 3). Those cases you mentioned (`KafkaPartitionSplitReaderTest#testHandleSplitChangesAndFetch`, `#assignSplitsAndFetchUntilFinish` and `testAssignEmptySplit`) don't cover the corner case that having stopping offset = 0 in the split, and that's why we didn't catch this bug in CIs. 



-- 
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] MartijnVisser commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
MartijnVisser commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1190082771

   @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] PatrickRen commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
PatrickRen commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1197570675

   @leozhangsr You can squash them locally and force push this branch to your repository. Never mind I'll merge 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] leozhangsr commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1194373645

   > Thanks for the patch @leozhangsr ! LGTM. Could you squash all commits into one? I'll merge it then.
   
   I tried, but it seems that commits can't be squashed by me in this branch or mr.Could you use squash merging(squash and merge option ) ? Or I can squash in a new branch and make new mr, you can merge it then.


-- 
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] leozhangsr commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1182716948

   @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] PatrickRen commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
PatrickRen commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1197575778

   Squashed and merged to master 55fc7fa95aae4304a8694c03adf79d0a609918b1


-- 
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] MartijnVisser commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
MartijnVisser commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1190083331

   > I have checked the ci result, relative change and test case is passed.The ci failed with other test task.I am not sure how to handle this, any one can help? Thanks!
   
   Let's retry to get the build passing with a retry; else we can always consider merging it (after the code review process has been completed)


-- 
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] PatrickRen closed pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
PatrickRen closed pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0
URL: https://github.com/apache/flink/pull/20234


-- 
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] leozhangsr commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1181224833

   > @leozhangsr Can you add a test for this situation?
   
   ok, I will add a test later


-- 
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] leozhangsr commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1182115825

   > @leozhangsr Can you add a test for this situation?
   
   I added a test in KafkaPartitionSplitSerializerTest to make sure KafkaPartitionSplit is serialized correctly.


-- 
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 #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "21bb37c5427fa54708106c4edcf7c7d69c8cc1ca",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "21bb37c5427fa54708106c4edcf7c7d69c8cc1ca",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 21bb37c5427fa54708106c4edcf7c7d69c8cc1ca 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] MartijnVisser commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
MartijnVisser commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1189943033

   @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] mas-chen commented on a diff in pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
mas-chen commented on code in PR #20234:
URL: https://github.com/apache/flink/pull/20234#discussion_r925038355


##########
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/reader/KafkaPartitionSplitReaderTest.java:
##########
@@ -84,6 +85,7 @@ public static void setup() throws Throwable {
         KafkaSourceTestEnv.setup();
         KafkaSourceTestEnv.setupTopic(TOPIC1, true, true, KafkaSourceTestEnv::getRecordsForTopic);
         KafkaSourceTestEnv.setupTopic(TOPIC2, true, true, KafkaSourceTestEnv::getRecordsForTopic);
+        KafkaSourceTestEnv.setupTopic(TOPIC3, false, false, t -> new ArrayList<>());

Review Comment:
   nit
   ```suggestion
           KafkaSourceTestEnv.createTestTopic(TOPIC3);
   ```



-- 
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] leozhangsr commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1190076465

   ![image](https://user-images.githubusercontent.com/20127034/179953955-86f745de-656f-446e-86f2-5b9b99d43292.png)
   I have checked the ci result, relative change and test case is passed.The ci failed with other test task.I am not sure how to handle this, any one can help? Thanks!


-- 
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] leozhangsr commented on a diff in pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on code in PR #20234:
URL: https://github.com/apache/flink/pull/20234#discussion_r925103325


##########
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/split/KafkaPartitionSplitSerializerTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.connector.kafka.source.split;
+
+import org.apache.kafka.common.TopicPartition;
+import org.assertj.core.util.Lists;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link KafkaPartitionSplitSerializer}. */
+public class KafkaPartitionSplitSerializerTest {

Review Comment:
   Thanks for your suggestion.I have added a test case in KafkaPartitionSplitReaderTest#testAssignEmptySplit to validate the zero stopping offset situation.Please review this.Thanks.



-- 
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] leozhangsr commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1192461458

   @PatrickRen waiting a review from you


-- 
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] PatrickRen commented on a diff in pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
PatrickRen commented on code in PR #20234:
URL: https://github.com/apache/flink/pull/20234#discussion_r921806079


##########
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/split/KafkaPartitionSplitSerializerTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.connector.kafka.source.split;
+
+import org.apache.kafka.common.TopicPartition;
+import org.assertj.core.util.Lists;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link KafkaPartitionSplitSerializer}. */
+public class KafkaPartitionSplitSerializerTest {

Review Comment:
   I think the expected behavior of `KafkaSourceReader` should be: if the stopping offset of a split is set to 0, no message from that split will be consumed. This test case is not validating the expected behavior but only checks the functionality of split serializer. 



-- 
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] leozhangsr commented on a diff in pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on code in PR #20234:
URL: https://github.com/apache/flink/pull/20234#discussion_r922636336


##########
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/split/KafkaPartitionSplitSerializerTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.connector.kafka.source.split;
+
+import org.apache.kafka.common.TopicPartition;
+import org.assertj.core.util.Lists;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link KafkaPartitionSplitSerializer}. */
+public class KafkaPartitionSplitSerializerTest {

Review Comment:
   yes, that's what we want: if the stopping offset of a split is set to 0, no message from that split will be consumed.
   I check this code again, and make a explanation for my change and test case.
   As we know, split is defined by the driver, then is serialized and send to task manager, then handled by KafkaPartitionSplitReader.The split reader cosumes messages, and stops at the stopping offset if the stopping offset is set.
   
   To achieve this, following key steps have to be validated:
   1、split is correctly serialized and send to split reader.
   2、split reader parse the split correctly
   3、split reader consumes and stop at the stopping offset.
   
   Step 1 is validated by test case I had make.
   Step 2 and 3 , can be validated by KafkaPartitionSplitReaderTest.testHandleSplitChangesAndFetch-assignSplitsAndFetchUntilFinish. This test make sure the split reader stop at the stopping offset.This test case set the stopping offset to 10(NUM_RECORDS_PER_PARTITION).Though the stopping offset is not 0, it still can work well if the split is parse correctly. KafkaPartitionSplitReader.parseStoppingOffsets acquires stoppingOffset to be >= 0,LATEST_OFFSET,COMMITTED_OFFSET. The KafkaPartitionSplit.getStoppingOffset reachs the same conditions after my modification.
   Step 2 and 3, is also validated by KafkaPartitionSplitReaderTest.testAssignEmptySplit for empty split situation.Generally when the stopping offset is 0, the starting offset might by 0 too, which means it's a empty split,it should consume nothing  and stop.In this test case, the empty split' starting offset is LATEST_OFFSET, stopping offset is LATEST_OFFSET.
   
   I only add a test case for step 1, since it's nerver tested before.I think the existing tests can already covered the situation(if the stopping offset of a split is set to 0, no message from that split will be consumed).Do you agree? Should I add a test case just for stopping offset = 0? Would it be a little redundance?



-- 
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] leozhangsr commented on pull request #20234: [FLINK-28475] [Connector/kafka] Stopping offset can be 0

Posted by GitBox <gi...@apache.org>.
leozhangsr commented on PR #20234:
URL: https://github.com/apache/flink/pull/20234#issuecomment-1190158802

   > > I have checked the ci result, relative change and test case is passed.The ci failed with other test task.I am not sure how to handle this, any one can help? Thanks!
   > 
   > Let's retry to get the build passing with a retry; else we can always consider merging it (after the code review process has been completed)
   
   Thank, I will check the ci result later and retry when it's necessary


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