tdas commented on a change in pull request #23324: [SPARK-26267][SS]Retry when
detecting incorrect offsets from Kafka
URL: https://github.com/apache/spark/pull/23324#discussion_r241928870
##########
File path:
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaOffsetReader.scala
##########
@@ -144,16 +145,22 @@ private[kafka010] class KafkaOffsetReader(
s"Specified: ${partitionOffsets.keySet} Assigned:
${partitions.asScala}")
logDebug(s"Partitions assigned to consumer: $partitions. Seeking to
$partitionOffsets")
- partitionOffsets.foreach {
- case (tp, KafkaOffsetRangeLimit.LATEST) =>
- consumer.seekToEnd(ju.Arrays.asList(tp))
- case (tp, KafkaOffsetRangeLimit.EARLIEST) =>
- consumer.seekToBeginning(ju.Arrays.asList(tp))
- case (tp, off) => consumer.seek(tp, off)
- }
- partitionOffsets.map {
- case (tp, _) => tp -> consumer.position(tp)
+ def _fetchOffsets(): PartitionOffsetMap = {
+ partitionOffsets.foreach {
+ case (tp, KafkaOffsetRangeLimit.LATEST) =>
+ consumer.seekToEnd(ju.Arrays.asList(tp))
+ case (tp, KafkaOffsetRangeLimit.EARLIEST) =>
+ consumer.seekToBeginning(ju.Arrays.asList(tp))
+ case (tp, off) => consumer.seek(tp, off)
+ }
+ partitionOffsets.map {
+ case (tp, _) => tp -> consumer.position(tp)
+ }
}
+
+ // Fetch the offsets twice to reduce the chance to hit KAFKA-7703.
Review comment:
Add more info why calling this twice works.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]