kafka protocol_error ai_generated true

org.apache.kafka.common.errors.FetchSessionIdNotFoundException: Fetch session 123456789 not found

ID: kafka/fetch-session-id-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
1Evidence
2023-08-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2.4.0 active
3.0.0 active
3.3.0 active

Root Cause

Consumer fetch session expired or was evicted on broker due to inactivity or broker restart, causing fetch request with stale session ID.

generic

中文

消费者拉取会话因不活动或代理重启而过期或被驱逐,导致拉取请求使用了过期的会话ID。

Official Documentation

https://kafka.apache.org/documentation/#fetchsession

Workarounds

  1. 85% success Increase broker's max.incremental.fetch.session.cache.slots to a higher value (e.g., 2000) to prevent session eviction under high load.
    Increase broker's max.incremental.fetch.session.cache.slots to a higher value (e.g., 2000) to prevent session eviction under high load.
  2. 80% success Reduce consumer fetch request frequency by increasing fetch.min.bytes and fetch.max.wait.ms to reduce session churn.
    Reduce consumer fetch request frequency by increasing fetch.min.bytes and fetch.max.wait.ms to reduce session churn.
  3. 90% success Upgrade to Kafka 3.4+ where fetch session handling is more robust with improved eviction logic.
    Upgrade to Kafka 3.4+ where fetch session handling is more robust with improved eviction logic.

中文步骤

  1. 增加代理的 max.incremental.fetch.session.cache.slots 到更高值(例如2000),以防止高负载下会话被驱逐。
  2. 通过增加 fetch.min.bytes 和 fetch.max.wait.ms 来减少消费者拉取请求频率,从而减少会话波动。
  3. 升级到Kafka 3.4+,该版本具有改进的驱逐逻辑,拉取会话处理更健壮。

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Longer wait does not prevent session eviction; broker still evicts after max.incremental.fetch.session.cache.slots.

  2. 95% fail

    Disabling fetch session requirement is not a valid config; causes broker startup failure.

  3. 70% fail

    Restart creates new session temporarily but error reoccurs if broker evicts again; not a fix.