Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to shift back the offset of a topic within a stable Kafka consumer group?

Tags:

I try to shift back the offset of topic within consumer group using following command:

bin/kafka-consumer-groups.sh --bootstrap-server loclahost:9092 --group xxx-0 --topic schedule-changed --reset-offsets --shift-by -2 --execute 

(Yes, I'm using kafka version > 1.x) As a result I got a message:

Error: Assignments can only be reset if the group 'xxx-0' is inactive, but the current state is Stable.

How can I change the state of group from 'stable' to 'inactive'?

like image 562
Karol Król Avatar asked Feb 19 '18 12:02

Karol Król


People also ask

How do I reset my consumer group offset?

How to change consumer offset? Use the kafka-consumer-groups.sh to change or reset the offset. You would have to specify the topic, consumer group and use the –reset-offsets flag to change the offset.

What is auto offset reset in Kafka?

Second, use auto. offset. reset to define the behavior of the consumer when there is no committed position (which would be the case when the group is first initialized) or when an offset is out of range. You can choose either to reset the position to the “earliest” offset or the “latest” offset (the default).


1 Answers

The reset-offsets option for kafka-consumer-groups.sh first checks to see if a consumer is active in that group before attempting to shift back your offsets. 'Stable' means you have an active consumer running.

Use the describe-groups option to check on your consumer groups:

bin/kafka-consumer-groups.sh --bootstrap-server $SERVERS --group $GROUP --describe 

If you see an entry under 'CONSUMER-ID/HOST/CLIENT-ID' for your topic, that means you still have a consumer running. Once you shut down the app that's keeping the consumer alive your consumer group will be inactive and you'll be able to shift your offsets at will.

like image 110
kellanburket Avatar answered Sep 28 '22 11:09

kellanburket