简体   繁体   English

如何在 Kafka Streams 应用程序中处理偏移提交期间的超时异常

[英]How to handle Timeout exceptions during Offset Commit in a Kafka Streams application

If there is a timeout exception during committing offsets in a Kafka Streams application, does the ProductionExceptionHandler come into play?如果在 Kafka Streams 应用程序中提交偏移量期间出现超时异常,ProductionExceptionHandler 是否起作用?

Timeout of 60000ms expired before successfully committing offsets

I'm using a Spring cloud stream based Kafka streams application and I do have a ProductionExceptionHandler implementation configured to LogAndContinue.我正在使用基于 Spring 云流的 Kafka 流应用程序,并且我确实将 ProductionExceptionHandler 实现配置为 LogAndContinue。 But it seems like the control doesn't come to the exception handler for this timeout exception and all stream threads die anyway.但是对于这个超时异常,似乎控件没有到达异常处理程序,并且所有流线程无论如何都会死亡。

What's the correct way to handle this?处理这个问题的正确方法是什么? Here is the full error.这是完整的错误。

[-StreamThread-1] o.a.k.s.p.i.AssignedStreamsTasks         : stream-thread [stream-app-0d77ace1-4d20-413b-a71a-94cca3e620e0-StreamThread-1] Failed to commit stream task 0_3 due to the following error:
org.apache.kafka.common.errors.TimeoutException: Timeout of 60000ms expired before successfully committing offsets {example-topic-3=OffsetAndMetadata{offset=139191, leaderEpoch=null, metadata='AQAAAXU0ut1W'}}
2020-10-17 04:05:23.410 ERROR [ratelimit-transformer,,,] 19 --- [-StreamThread-1] o.a.k.s.p.internals.StreamThread         : stream-thread [stream-app-0d77ace1-4d20-413b-a71a-94cca3e620e0-StreamThread-1] Encountered the following unexpected Kafka exception during processing, this usually indicate Streams internal errors:
org.apache.kafka.common.errors.TimeoutException: Timeout of 60000ms expired before successfully committing offsets {example-topic-3=OffsetAndMetadata{offset=139191, leaderEpoch=null, metadata='AQAAAXU0ut1W'}}
2020-10-17 04:05:24.149 ERROR [ratelimit-transformer,,,] 19 --- [-StreamThread-1] org.apache.kafka.streams.KafkaStreams    : stream-client [stream-app-0d77ace1-4d20-413b-a71a-94cca3e620e0] All stream threads have died. The instance will be in error state and should be closed.
Exception in thread "stream-app-0d77ace1-4d20-413b-a71a-94cca3e620e0-StreamThread-1" org.apache.kafka.common.errors.TimeoutException: Timeout of 60000ms expired before successfully committing offsets {example-topic-3=OffsetAndMetadata{offset=139191, leaderEpoch=null, metadata='AQAAAXU0ut1W'}}

Currently TimeoutException is not very well managed by Kafka Streams and will eventually cause your StreamThread to crash.目前,Kafka Streams 没有很好地管理TimeoutException ,最终会导致您的 StreamThread 崩溃。 Most of a the time a timeouts happen due to network issue or kafka unavailability.大多数情况下,由于网络问题或 kafka 不可用而发生超时。

The error message logged by Kafka Streams is explicit "All stream threads have died. The instance will be in error state and should be closed." Kafka Streams 记录的错误消息是明确的“所有流线程都已死亡。实例将处于错误状态,应关闭。” ; ; So, you can stop and restart your KafkaStreams application but if it's a network issue restartingyour app will not help.因此,您可以停止并重新启动您的 KafkaStreams 应用程序,但如果是网络问题,重新启动您的应用程序将无济于事。

Note that there is some works in progress :请注意,正在进行一些工作:

You can configure an java.lang.Thread.UncaughtExceptionHandler on your KafkaStreams instance to handle that exception ( KafkaStreams JavaDoc )您可以在 KafkaStreams 实例上配置java.lang.Thread.UncaughtExceptionHandler来处理该异常( KafkaStreams JavaDoc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM