Java Samza 0.14.1未正确处理OffsetAutoFrangeException异常?

Java Samza 0.14.1未正确处理OffsetAutoFrangeException异常?,java,apache-kafka,apache-samza,Java,Apache Kafka,Apache Samza,我们面临的问题与本文中描述的相同 此处-Samza请求的Kafka分区偏移量太旧,即Kafka日志已向前移动。我们正在设置属性 consumer.auto.offset.reset 最小,因此期望Samza在这种情况下将其检查点重置为最早可用的分区偏移量。但事实并非如此,我们不断收到这种形式的例外情况: INFO [2018-08-21 19:26:20,924] [U:669,F:454,T:1,123,M:2,658] kafka.producer.SyncProducer:[Logging

我们面临的问题与本文中描述的相同

此处-Samza请求的Kafka分区偏移量太旧,即Kafka日志已向前移动。我们正在设置属性 consumer.auto.offset.reset 最小,因此期望Samza在这种情况下将其检查点重置为最早可用的分区偏移量。但事实并非如此,我们不断收到这种形式的例外情况:

INFO [2018-08-21 19:26:20,924] [U:669,F:454,T:1,123,M:2,658]
kafka.producer.SyncProducer:[Logging_class:info:66] - [main] -
Disconnecting from vrni-platform-release:9092
INFO [2018-08-21 19:26:20,924] [U:669,F:454,T:1,123,M:2,658]
system.kafka.GetOffset:[Logging_class:info:63] - [main] - Validating offset
56443499 for topic and partition Topic3-0
WARN [2018-08-21 19:26:20,925] [U:669,F:454,T:1,123,M:2,658]
system.kafka.KafkaSystemConsumer:[Logging_class:warn:74] - [main] - While
refreshing brokers for Topic3-0:
org.apache.kafka.common.errors.OffsetOutOfRangeException: The requested
offset is not within the range of offsets maintained by the server..
Retrying
版本详细信息

萨姆萨:2.11-0.14.1 卡夫卡客户端:1.1.0 卡夫卡服务器:1.1.0 Scala 2.11 浏览代码,GetOffset::isValidOffset应该能够捕获异常OffsetAutoFrangeException并将其转换为假值。但这似乎没有发生。异常包中是否存在不匹配?全班都在赶火车 异常导入kafka.common.OffsetOutOfRangeException,但从日志来看,此类的包似乎不同。这可能是原因吗

def isValidOffset(consumer: DefaultFetchSimpleConsumer, topicAndPartition: TopicAndPartition, offset: String) = {
    info("Validating offset %s for topic and partition %s" format (offset, topicAndPartition))

    try {
      val messages = consumer.defaultFetch((topicAndPartition, offset.toLong))

      if (messages.hasError) {
        KafkaUtil.maybeThrowException(messages.error(topicAndPartition.topic, topicAndPartition.partition).exception())
      }

      info("Able to successfully read from offset %s for topic and partition %s. Using it to instantiate consumer." format (offset, topicAndPartition))

      true
    } catch {
      case e: OffsetOutOfRangeException => false
    }
}
另外,类-GetOffset的调用方将打印一个日志,似乎。。。如果它得到一个假值,但它没有记录这一行,这表明GetOffset方法中生成的某些异常正在取消捕获并向上传播:

def addTopicPartition(tp: TopicAndPartition, nextOffset: Option[String]) = {
    debug("Adding new topic and partition %s to queue for %s" format (tp, host))

    if (nextOffsets.asJava.containsKey(tp)) {
      toss("Already consuming TopicPartition %s" format tp)
    }

    val offset = if (nextOffset.isDefined && offsetGetter.isValidOffset(simpleConsumer, tp, nextOffset.get)) {
      nextOffset
        .get
        .toLong
    } else {
      warn("It appears that we received an invalid or empty offset %s for %s. Attempting to use Kafka's auto.offset.reset setting. This can result in data loss if processing continues." format (nextOffset, tp))

      offsetGetter.getResetOffset(simpleConsumer, tp)
    }

    debug("Got offset %s for new topic and partition %s." format (offset, tp))

    nextOffsets += tp -> offset

    metrics.topicPartitions.get((host, port)).set(nextOffsets.size)
  }
这可能是因为我们正在使用的Kafka客户端库版本不匹配吗? 假设Kafka服务器为1.x,我们是否应该在Samza 0.14.1中使用推荐的Kafka客户端版本


如果您对此有任何帮助,我们将不胜感激。

以上是samza 0.14.0和0.14.1中的一个错误。是错误id

samza中也讨论了这一点