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/05/30 05:32:47 UTC

[GitHub] [flink] zou-can commented on pull request #19828: [FLINK-27762][connector/kafka] KafkaPartitionSplitReader#wakeup should only unblock KafkaConsumer#poll invocation

zou-can commented on PR #19828:
URL: https://github.com/apache/flink/pull/19828#issuecomment-1140717266

   As i commented on https://issues.apache.org/jira/browse/FLINK-27762
   
   The exception we met is in method **KafkaPartitionSplitReader#removeEmptySplits**. But i can't find any action for handling this exception in that method.
   ```
   // KafkaPartitionSplitReader#removeEmptySplits
   
   private void removeEmptySplits() {
       List<TopicPartition> emptyPartitions = new ArrayList<>();
      
       for (TopicPartition tp : consumer.assignment()) {
           // WakeUpException is thrown here.
           // since KafkaConsumer#wakeUp is called before, if execute KafkaConsumer#postion in 'if statement' above, it will throw WakeUpException.   
           if (consumer.position(tp) >= getStoppingOffset(tp)) {
               emptyPartitions.add(tp);
           }
       }
   
      // ignore irrelevant code...     
   } 
   ```
   What I'm focus is **how to handle WakeUpException** after it was thrown.
   
   As what is done in **KafkaPartitionSplitReader#fetch**
   ```
   // KafkaPartitionSplitReader#fetch
   
   public RecordsWithSplitIds<ConsumerRecord<byte[], byte[]>> fetch() throws IOException {
       ConsumerRecords<byte[], byte[]> consumerRecords;
       try {
           consumerRecords = consumer.poll(Duration.ofMillis(POLL_TIMEOUT));
       } catch (WakeupException we) {
           // catch exception and return empty result.
           return new KafkaPartitionSplitRecords(
                   ConsumerRecords.empty(), kafkaSourceReaderMetrics);
       }
   
      // ignore irrelevant code...     
   }
   ```
   Maybe we should catch this exception in **KafkaPartitionSplitReader#removeEmptySplits**, and retry **KafkaConsumer#postion** again.
   
   


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