Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Prevent attempts to reset the offset when trying to fetch consumer lag.
Browse files Browse the repository at this point in the history
`kafka_tools.fetch_consumer_lag` will attempt to reset the offset for a consumer group that does not have any offsets for a topic. This is unexpected behavior, since it seems to indicate it will just read data. Additionally, if the reset fails, it can cause a timeout for the calling service (since consumer_timeout_ms is not set), which can be a problem for monitoring tools.
  • Loading branch information
Andrew Thal authored Aug 21, 2018
1 parent 69b501d commit 52c4194
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pykafka/cli/kafka_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def fetch_consumer_lag(client, topic, consumer_group):
"""
latest_offsets = fetch_offsets(client, topic, 'latest')
consumer = topic.get_simple_consumer(consumer_group=consumer_group,
auto_start=False)
auto_start=False,
reset_offset_on_fetch=False)
current_offsets = consumer.fetch_offsets()
return {p_id: (latest_offsets[p_id].offset[0], res.offset)
for p_id, res in current_offsets}
Expand Down

0 comments on commit 52c4194

Please sign in to comment.