leilinen commented on a change in pull request #650: HUDI-105 : Fix up offsets 
not available on leader exception
URL: https://github.com/apache/incubator-hudi/pull/650#discussion_r280761847
 
 

 ##########
 File path: 
hoodie-utilities/src/main/java/com/uber/hoodie/utilities/sources/helpers/KafkaOffsetGen.java
 ##########
 @@ -204,8 +204,10 @@ public KafkaOffsetGen(TypedProperties props) {
 
     // Determine the offset ranges to read from
     HashMap<TopicAndPartition, KafkaCluster.LeaderOffset> fromOffsets;
+    HashMap<TopicAndPartition, KafkaCluster.LeaderOffset> checkpointOffsets;
     if (lastCheckpointStr.isPresent()) {
-      fromOffsets = CheckpointUtils.strToOffsets(lastCheckpointStr.get());
+      checkpointOffsets = 
CheckpointUtils.strToOffsets(lastCheckpointStr.get());
+      fromOffsets = checkupValidOffsets(cluster, checkpointOffsets, 
topicPartitions);
 
 Review comment:
   the exception is thrown in KafkaUtils 
   ```
    /** Make sure offsets are available in kafka, or throw an exception */
     private def checkOffsets(
         kc: KafkaCluster,
         offsetRanges: Array[OffsetRange]): Unit = {
       val topics = offsetRanges.map(_.topicAndPartition).toSet
       val result = for {
         low <- kc.getEarliestLeaderOffsets(topics).right
         high <- kc.getLatestLeaderOffsets(topics).right
       } yield {
         offsetRanges.filterNot { o =>
           low(o.topicAndPartition).offset <= o.fromOffset &&
           o.untilOffset <= high(o.topicAndPartition).offset
         }
       }
       val badRanges = KafkaCluster.checkErrors(result)
       if (!badRanges.isEmpty) {
        throw new SparkException("Offsets not available on leader: " + 
badRanges.mkString(","))
       }
     }
   ``` 
   which is called in AvroKafkaSource class and cannot get the exception 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to