Kafka Error ILLEGAL_GENERATION
Error code 22 · Non-retriable Consumer
Specified group generation id is not valid.
Common Causes
- Consumer took too long to process records between poll() calls, causing the broker-side session to expire and trigger a new rebalance with an incremented generation ID
- Consumer crashed or was killed during a rebalance and the group committed offsets with an outdated generation ID after rejoining
- Concurrent consumer group management from multiple application instances incorrectly sharing the same group.id with mismatched session state
Solutions
- Increase 'max.poll.interval.ms' (default 300000ms) or reduce processing time per poll batch by decreasing 'max.poll.records' (default 500) to prevent session timeout during processing
- Ensure offset commits happen within the poll loop and before max.poll.interval.ms elapses; use async commits for performance but sync commit before shutdown
- Check for duplicate group.id across different applications; each consumer group should have a unique, stable group.id — audit with kafka-consumer-groups.sh --list
Diagnostic Commands
# Describe consumer group offsets and lag
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group <group> --describe
# Look for rebalance events in logs
grep -E 'IllegalGeneration|Rebalance|JoinGroup|generation' /var/log/kafka/server.log | tail -30Related APIs
This error can be returned by: TxnOffsetCommit
Debugging Kafka errors? Conduktor Console gives you real-time visibility into your cluster. Explore all errors in the Error Decoder.