Kafka Exception NoOffsetForPartitionException
org.apache.kafka.clients.consumer.NoOffsetForPartitionException
Non-retriable
Consumer
Indicates that there is no stored offset for a partition and no defined offset reset policy.
Common Causes
- The consumer has no committed offset for a partition and auto.offset.reset is set to none
- A brand-new consumer group reading a topic for the first time with no reset policy
- The committed offset for the group was deleted (offsets.retention.minutes elapsed while the group was inactive)
Solutions
- Set auto.offset.reset to earliest (reprocess from the start) or latest (only new records), depending on your semantics
- If you intentionally use none to detect this case, handle the exception by calling seekToBeginning()/seekToEnd() or seeking to an externally stored offset
- Increase offsets.retention.minutes if groups can be idle longer than the default retention
Example Stack Trace
org.apache.kafka.clients.consumer.NoOffsetForPartitionException: Undefined offset with no reset policy for partitions: [orders-0]
at org.apache.kafka.clients.consumer.internals.SubscriptionState.resetInitializingPositions(SubscriptionState.java:716)Diagnostic Commands
# Check whether the group has committed offsets
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group <group> --describeRelated
Related Consumer exceptions: CommitFailedException · CoordinatorLoadInProgressException · CoordinatorNotAvailableException · FencedInstanceIdException · FencedMemberEpochException · GroupMaxSizeReachedException · IllegalGenerationException · InvalidGroupIdException
Hitting
NoOffsetForPartitionException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.