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

[GitHub] [flink] dawidwys opened a new pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

dawidwys opened a new pull request #12018:
URL: https://github.com/apache/flink/pull/12018


   
   ## What is the purpose of the change
   
   This PR adds a way to emit multiple records from
   KafkaDeserializationSchema. This is possible through a collector, which
   will buffer deserialized records in a queue and then emit all records
   atomically. The queue is reused for all incoming Kafka records to
   minimize creating new objects on the hot path.
   
   
   ## Verifying this change
   All existing kafka tests should pass. 
   Added:
   * org.apache.flink.streaming.connectors.kafka.KafkaConsumerTestBase#runCollectingSchemaTest
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (**yes** / no)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (**yes** / no / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (**yes** / 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.

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



[GitHub] [flink] dawidwys commented on pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   cc @aljoscha 


----------------------------------------------------------------
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] dawidwys commented on a change in pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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



##########
File path: flink-connectors/flink-connector-kafka-base/src/test/java/org/apache/flink/streaming/connectors/kafka/internals/AbstractFetcherTest.java
##########
@@ -108,13 +112,13 @@ public void testSkipCorruptedRecord() throws Exception {
 
 		final KafkaTopicPartitionState<Object> partitionStateHolder = fetcher.subscribedPartitionStates().get(0);
 
-		fetcher.emitRecord(1L, partitionStateHolder, 1L);
-		fetcher.emitRecord(2L, partitionStateHolder, 2L);
+		emitRecord(fetcher, 1L, partitionStateHolder, 1L);

Review comment:
       There are two related changes:
   * I changed a bit the way no results are emitted (null before/empty queue now)
   * I changed one test case slightly to emit multiple results in a single `emitRecordsWithTimestamps`
   
   I think after extracting the refactoring to a separate commit it is visible more clearly.




----------------------------------------------------------------
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 #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=736",
       "triggerID" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e7e6890ac5b32caacc424dd8cf7417d4569873e9",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "e7e6890ac5b32caacc424dd8cf7417d4569873e9",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9cf30a56133e39d0e895f99796201d99a8447249 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=736) 
   * e7e6890ac5b32caacc424dd8cf7417d4569873e9 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] aljoscha commented on a change in pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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



##########
File path: flink-connectors/flink-connector-kafka-0.10/src/main/java/org/apache/flink/streaming/connectors/kafka/internal/Kafka010Fetcher.java
##########
@@ -228,4 +226,33 @@ protected void doCommitInternalOffsetsToKafka(
 		// record the work to be committed by the main consumer thread and make sure the consumer notices that
 		consumerThread.setOffsetsToCommit(offsetsToCommit, commitCallback);
 	}
+
+	private class KafkaCollector implements Collector<T> {
+		private final Queue<T> records = new ArrayDeque<>();
+
+		private boolean endOfStreamSignalled = false;
+
+		@Override
+		public void collect(T record) {
+			// do not emit subsequent elements if the end of the stream reached

Review comment:
       So we're not emitting all the records of the batch after one of them signals "end of stream"? I recall that an initial version still emitted all records.

##########
File path: flink-connectors/flink-connector-kafka-base/src/test/java/org/apache/flink/streaming/connectors/kafka/internals/AbstractFetcherTest.java
##########
@@ -108,13 +112,13 @@ public void testSkipCorruptedRecord() throws Exception {
 
 		final KafkaTopicPartitionState<Object> partitionStateHolder = fetcher.subscribedPartitionStates().get(0);
 
-		fetcher.emitRecord(1L, partitionStateHolder, 1L);
-		fetcher.emitRecord(2L, partitionStateHolder, 2L);
+		emitRecord(fetcher, 1L, partitionStateHolder, 1L);

Review comment:
       The changes in this file are purely an orthogonal refactoring, right? Could you put these in a separate commit, along with the removal of the `emitRecord()` method on the fetcher that is only used in tests?




----------------------------------------------------------------
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 #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=736",
       "triggerID" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9cf30a56133e39d0e895f99796201d99a8447249 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=736) 
   
   <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 #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=736",
       "triggerID" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9cf30a56133e39d0e895f99796201d99a8447249 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=736) 
   
   <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] begginghard commented on pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   @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] aljoscha commented on pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   @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 commented on pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9cf30a56133e39d0e895f99796201d99a8447249 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 commented on pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   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 9cf30a56133e39d0e895f99796201d99a8447249 (Thu May 07 09:17:48 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



[GitHub] [flink] flinkbot edited a comment on pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=736",
       "triggerID" : "9cf30a56133e39d0e895f99796201d99a8447249",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e7e6890ac5b32caacc424dd8cf7417d4569873e9",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=997",
       "triggerID" : "e7e6890ac5b32caacc424dd8cf7417d4569873e9",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9cf30a56133e39d0e895f99796201d99a8447249 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=736) 
   * e7e6890ac5b32caacc424dd8cf7417d4569873e9 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=997) 
   
   <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] dawidwys commented on pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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


   @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] dawidwys commented on a change in pull request #12018: [FLINK-17307] Add collector to deserialize in KafkaDeserializationSchema

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



##########
File path: flink-connectors/flink-connector-kafka-0.10/src/main/java/org/apache/flink/streaming/connectors/kafka/internal/Kafka010Fetcher.java
##########
@@ -228,4 +226,33 @@ protected void doCommitInternalOffsetsToKafka(
 		// record the work to be committed by the main consumer thread and make sure the consumer notices that
 		consumerThread.setOffsetsToCommit(offsetsToCommit, commitCallback);
 	}
+
+	private class KafkaCollector implements Collector<T> {
+		private final Queue<T> records = new ArrayDeque<>();
+
+		private boolean endOfStreamSignalled = false;
+
+		@Override
+		public void collect(T record) {
+			// do not emit subsequent elements if the end of the stream reached

Review comment:
       Actually, that is the behaviour I had from the very beginning. Do you think it makes more sense to emit all but the end of the stream record?
   
   Side note. I find this method very confusing. I just realized that there is no cross partition alignment on this method. The whole task will be brought down if any of the assigned partitions signals the end of stream, irrespective of the state of the remaining partitions. Honestly I'd be in favour of dropping this method at some point in the future.




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