Kafka consumer behavior in case of DisconnectException

Viewed 1316

We have several applications consuming from Kafka, that regularly encounter a DisconnectException.

What happens is always like the following:

  • The application is subscribed on say partitions 5 and 6, messages are processed from both partitions
  • From time T, no message is consumed on partition 5, only messages of partition 6 are consumed.
  • At T + around 5 minutes, Kafka consumer spits many log lines:
Error sending fetch request (sessionId=552335215, epoch=INITIAL) to node 0: org.apache.kafka.common.errors.DisconnectException.
  • After that, the consumption resumes from partition 5 and 6 and catches up the accumulated lag

Same issue occurs if the application consumes a single partition : in this case, no message is consumed for 5 minutes.

My understanding according to https://issues.apache.org/jira/browse/KAFKA-6520 is that in case of connection issue, the Kafka consumer retries (with backoff, up to 1 second by default according to reconnect.backoff.max.ms config), hiding the issue to the end user. The calls to poll() return 0 message, so the polling loop goes on and on.

However, some interrogations:

  1. If the fetch fails due to connection issue, then the broker does not receive these requests and after the "max.poll.interval.ms" (50 seconds in our case) it should expel the consumer and trigger a rebalance. This is not happening, why?
  2. Since the Kafka consumer retries every second, why would it take systematically 5 minutes to reconnect? Unless there is some infrastructure / network issue going on...
  3. Otherwise, any client side configuration param which could explain the 5 minutes delay? Could this delay be somehow related to "metadata.max.age.ms"? (5 min by default)
0 Answers
Related