[发送到Kafka主题时获取某些消息的TimeoutException

问题描述 投票:0回答:1
Exception Stacktrace:
org.springframework.kafka.core.KafkaProducerException: Failed to send; nested exception is org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for ****-656 due to 30037 ms has passed since batch creation plus linger time
      at org.springframework.kafka.core.KafkaTemplate$1.onCompletion(KafkaTemplate.java:255) ~[spring-kafka-1.1.6.RELEASE.jar!/:?]
      at org.apache.kafka.clients.producer.internals.RecordBatch.done(RecordBatch.java:109) ~[kafka-clients-0.10.1.1.jar!/:?]
      at org.apache.kafka.clients.producer.internals.RecordBatch.maybeExpire(RecordBatch.java:160) ~[kafka-clients-0.10.1.1.jar!/:?]
      at org.apache.kafka.clients.producer.internals.RecordAccumulator.abortExpiredBatches(RecordAccumulator.java:245) ~[kafka-clients-0.10.1.1.jar!/:?]
      at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:212) ~[kafka-clients-0.10.1.1.jar!/:?]
      at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:135) ~[kafka-clients-0.10.1.1.jar!/:?]
      at java.lang.Thread.run(Thread.java:745) [?:1.8.0_77]

PROD环境中的上述异常,是在部署某些kafka消息的第一天开始的。从PROD中撤消更改。在Stage env中,我在测试时从未见过该异常。一旦我能够重现异常,但是只有一次,我可能已经运行了10次。现在,我对如何找到此问题的RCA没有任何指导?

我将发布如下的Kafka发送方配置,

retries=3
retryBackoffMS=500
lingerMS=30
autoFlush=true
acksConfig=all
kafkaServerConfig=***<Can't post here>
reconnectBackoffMS=200
compressionType=snappy
batchSize=1000000
maxBlockMS=500000
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
            <version>1.1.8.RELEASE</version>
        </dependency>
apache-kafka spring-kafka kafka-producer-api
1个回答
0
投票

该异常基本上说缓冲区中的记录达到了超时。

https://cwiki.apache.org/confluence/display/KAFKA/KIP-91+Provide+Intuitive+User+Timeouts+in+The+Producer?source=post_page-----fa3910d9aa54----------------------#KIP-91ProvideIntuitiveUserTimeoutsinTheProducer-TestPlan

在stg中,您看不到此异常是因为prod env比较忙。

您可以更新您的spring-kafka版本吗?您的kafka客户端远远落后于最新版本。https://mvnrepository.com/artifact/org.springframework.kafka/spring-kafka/1.1.8.RELEASE使用kafka 0.10.x,现在已经是2.3.x

如果可以使用最新版本,则可以将delivery.timeout.ms设置为更高

如果无法升级到较新的版本,则必须在linger.msrequest.timeout.ms周围玩(尝试增加它们)

此外,默认的重试次数是最大整数,显然您的重试次数:3不太实用。如果您不想一直重新连接,则30更为实用。https://docs.confluent.io/current/installation/configuration/producer-configs.html要么https://kafka.apache.org/documentation/#producerconfigs

注意,两个链接都指向当前版本

© www.soinside.com 2019 - 2024. All rights reserved.