卡夫卡INVALID_FETCH_SESSION_EPOCH

mme*_*sen 10 apache-kafka spring-cloud-stream apache-kafka-streams

我们正在将kafka代理设置与使用Spring云流kafka运行的kafka stream应用程序结合使用。尽管看起来运行良好,但在日志中确实出现了以下错误语句:

2019-02-21 22:37:20,253 INFO kafka-coordinator-heartbeat-thread | anomaly-timeline org.apache.kafka.clients.FetchSessionHandler [Consumer clientId=anomaly-timeline-56dc4481-3086-4359-a8e8-d2dae12272a2-StreamThread-1-consumer, groupId=anomaly-timeline] Node 2 was unable to process the fetch request with (sessionId=1290440723, epoch=2089): INVALID_FETCH_SESSION_EPOCH. 
Run Code Online (Sandbox Code Playgroud)

我搜索了互联网,但是关于此错误的信息不多。我猜想这可能与经纪人和使用者之间的时间设置有所不同,但是两台机器的时间服务器设置相同。

知道如何解决吗?

tgr*_*rez 5

This could be caused by network issues.

There is a concept of fetch session, introduced within KIP-227 since 1.1.0 release: https://cwiki.apache.org/confluence/display/KAFKA/KIP-227%3A+Introduce+Incremental+FetchRequests+to+Increase+Partition+Scalability

Kafka brokers, which are replica followers, fetch messages from the leader. In order to avoid sending full metadata each time for all partitions, only those partitions which changed are sent within the same fetch session.

When we look into Kafka's code, we can see an example, when this is returned:

if (session.epoch != expectedEpoch) {
        info(s"Incremental fetch session ${session.id} expected epoch $expectedEpoch, but " +
          s"got ${session.epoch}.  Possible duplicate request.")
        new FetchResponse(Errors.INVALID_FETCH_SESSION_EPOCH, new FetchSession.RESP_MAP, 0, session.id)
      } else {
Run Code Online (Sandbox Code Playgroud)

src: https://github.com/axbaretto/kafka/blob/ab2212c45daa841c2f16e9b1697187eb0e3aec8c/core/src/main/scala/kafka/server/FetchSession.scala#L493

In general, if you don't have thousands of partitions and, at the same time, this doesn't happen very often, then it shouldn't worry you.

  • 不幸的是,我认为这与网络问题无关,因为我也在本地docker设置上遇到了这些问题:anomaly-timeline-2 | 2019-02-22 14:45:39,593信息异常-时间轴-db8558f2-cb17-4a87-b4ba-fe0fd1c47ec0-StreamThread-1 org.apache.kafka.clients.FetchSessionHandler [Consumer clientId = anomaly-timeline-db8558f2-cb17-4a87 -b4ba-fe0fd1c47ec0-StreamThread-1-consumer,groupId =异常时间线]节点1001无法处理以下请求的获取请求:(sessionId = 593140062,纪元= 65):INVALID_FETCH_SESSION_EPOCH。 (2认同)

Dan*_*n M 5

看来这可能是由Kafka-2052修复的Kafka-8052问题引起的