【问题标题】:getting error:Batch containing 3 record(s) expired due to timeout while requesting metadata from brokers for test2R2P2-1出现错误:包含 3 条记录的批次因超时而过期,同时从代理请求 test2R2P2-1 的元数据
【发布时间】:2017-05-24 15:51:08
【问题描述】:

运行生产者客户端时出现以下错误,该客户端从输入文件kafka_message.log 获取消息。此日志文件每秒包含 100000 条长度为 4096 的消息的记录

错误 -

[2017-01-09 14:45:24,813] ERROR Error when sending message to topic test2R2P2 with key: null, value: 4096 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 3 record(s) expired due to timeout while requesting metadata from brokers for test2R2P2-0
[2017-01-09 14:45:24,816] ERROR Error when sending message to topic test2R2P2 with key: null, value: 4096 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 3 record(s) expired due to timeout while requesting metadata from brokers for test2R2P2-0
[2017-01-09 14:45:24,816] ERROR Error when sending message to topic test2R2P2 with key: null, value: 4096 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 3 record(s) expired due to timeout while requesting metadata from brokers for test2R2P2-0
[2017-01-09 14:45:24,816] ERROR Error when sending message to topic test2R2P2 with key: null, value: 4096 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 3 record(s) expired due to timeout while requesting metadata from brokers for test2R2P2-0
[2017-01-09 14:45:24,816] ERROR Error when sending message to topic test2R2P2 with key: null, value: 4096 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 3 record(s) expired due to timeout while requesting metadata from brokers for test2R2P2-0

我运行的命令:

$ bin/kafka-console-producer.sh --broker-list x.x.x.x:xxxx,x.x.x.x:xxxx --batch-size 1000 --message-send-max-retries 10 --request-required-acks 1 --topic test2R2P2 <~/kafka_message.log

有 2 个代理在运行,主题有 partitions = 2replication factor = 2

有人可以帮我理解这个错误的含义吗?我还看到消息丢失意味着不是输入文件中的所有消息都放入主题中?

单独说明:我在运行 kafka-producer-perf-test.sh 并在测试运行时杀死一个代理(在 3 节点集群中)时看到数据丢失。这是预期的行为吗?我看到多次测试的结果相同。

我运行的命令:

描述主题:

 $ bin/kafka-topics.sh  --zookeeper x.x.x.x:2181/kafka-framework --describe |grep test4
Topic:test4R2P2 PartitionCount:2        ReplicationFactor:2     Configs:
        Topic: test4R2P2        Partition: 0    Leader: 0       Replicas: 1,0   Isr: 0,1
        Topic: test4R2P2        Partition: 1    Leader: 0       Replicas: 0,1   Isr: 0,1

运行性能测试:

$ bin/kafka-producer-perf-test.sh --num-records 100000 --record-size 4096  --throughput 1000  --topic test4R2P2 --producer-props bootstrap.servers=x.x.x.x:xxxx,x.x.x.x:xxxx

消费者命令:

$ bin/kafka-console-consumer.sh --zookeeper x.x.x.x:2181/kafka-framework --topic test4R2P2 1>~/kafka_message.log

检查消息数:

$ wc -l ~/kafka_message.log
399418 /home/montana/kafka_message.log

我在主题 test4R2P2 中只看到 399418 条消息,因为我通过运行 perf test 4 次总共放置了 400000 条消息。

perf 命令引发的异常

org.apache.kafka.common.errors.NetworkException: The server disconnected before a response was received.
org.apache.kafka.common.errors.NetworkException: The server disconnected before a response was received.

消费者命令引发的异常

[2017-01-10 07:40:07,246] WARN [ConsumerFetcherThread-console-consumer-46599_node-44a8422fe1a0-1484033822261-f07d33d7-0-1], Error in fetch kafka.consumer.ConsumerFetcherThread$FetchRequest@695be565 (kafka.consumer.ConsumerFetcherThread)
[2017-01-10 07:40:07,472] WARN Fetching topic metadata with correlation id 1 for topics [Set(test4R2P2)] from broker [BrokerEndPoint(1,10.105.26.1,31052)] failed (kafka.client.ClientUtils$)
java.nio.channels.ClosedChannelException
[2017-01-10 07:42:23,073] WARN [ConsumerFetcherThread-console-consumer-46599_node-44a8422fe1a0-1484033822261-f07d33d7-0-0], Error in fetch kafka.consumer.ConsumerFetcherThread$FetchRequest@7bd94073 (kafka.consumer.ConsumerFetcherThread)
[2017-01-10 07:44:58,195] WARN [ConsumerFetcherThread-console-consumer-46599_node-44a8422fe1a0-1484033822261-f07d33d7-0-1], Error in fetch kafka.consumer.ConsumerFetcherThread$FetchRequest@2855ee73 (kafka.consumer.ConsumerFetcherThread)
[2017-01-10 07:44:58,404] WARN Fetching topic metadata with correlation id 3 for topics [Set(test4R2P2)] from broker [BrokerEndPoint(1,10.105.26.1,31052)] failed (kafka.client.ClientUtils$)
java.nio.channels.ClosedChannelException
[2017-01-10 07:45:47,127] WARN [ConsumerFetcherThread-console-consumer-46599_node-44a8422fe1a0-1484033822261-f07d33d7-0-0], Error in fetch kafka.consumer.ConsumerFetcherThread$FetchRequest@f8887da (kafka.consumer.ConsumerFetcherThread)
[2017-01-10 07:50:56,291] ERROR [ConsumerFetcherThread-console-consumer-46599_node-44a8422fe1a0-1484033822261-f07d33d7-0-1], Error for partition [test4R2P2,1] to broker 1:kafka.common.NotLeaderForPartitionException (kafka.consumer.ConsumerFetcherThread)

【问题讨论】:

  • 生产批次过期的情况有几种,但 V0.10 错误消息并未揭示其过期的原因。无论如何,您可以增加“request.timeout.ms”的值以查看它是否有效。此外,您还可以调整 linger.ms 和 batch.size 以允许更大的批处理来提高吞吐量。
  • 这是什么Kafka版本?你的重试次数是多少?您可以添加一个回调,告诉您是否由于某种原因无法传递消息。可能,在您的情况下,您有一个快速的网络或发布速度比您的网络支持的速度快,因此消息堆积在缓冲区中,然后超时并被丢弃。你最好做“同步”,它有更多的交付保证,并在网络问题发生时更早地通知。无论哪种方式,将重试次数增加到一个非常大的数字,然后从 1 开始慢慢增加发布吞吐量,看看会发生什么。
  • @amethystic 增加确认超时的建议奏效了。 1.5 秒的默认值太低了。

标签: apache-kafka


【解决方案1】:

根据 cmets,@amethystic 的这个建议似乎可以解决问题:

...您可以增加“request.timeout.ms”的值...

【讨论】:

    猜你喜欢
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 2015-01-01
    • 2012-08-06
    • 1970-01-01
    • 2019-12-20
    • 1970-01-01
    • 2018-11-23
    相关资源
    最近更新 更多