list_consumer_group_offsets is not returning all the available partitions
I am trying to get all the available partitions and their offsets using list_consumer_group_offsets
`def get_consumer_group_offset(group):
topic = ''
g = create_admin()
returnlist = []
counter = 0
end_offsets = g.list_consumer_group_offsets(group)
print(end_offsets)
offsets = list(end_offsets.values())
offsets_u = []
for n in offsets:
offsets_u.append(n.offset)
print("offsets_u")
print(offsets_u)
for f in end_offsets:
topic = f.topic
value = []
value.append(f.partition)
value.append(offsets_u[counter])
counter = counter + 1
returnlist.append(value)
print(returnlist)
return topic, returnlist`
output:
[[28, 247], [22, 262], [10, 257], [20, 5], [7, 297], [1, 301], [16, 256], [12, 776], [14, 569]]
as you can see some partitions are missing for some reason
kafka-python==2.0.2 Python==3.8.0
I had the same issue. After retrieving the same result from confluent_kafka library it became clear that this behavior is not bug. Indeed, see description of the function list_consumer_group_offsets https://github.com/dpkp/kafka-python/blob/a33fcf4d22bdf34e9660e394a7a6f84225411325/kafka/admin/client.py#L1262
:return dictionary: A dictionary with TopicPartition keys and OffsetAndMetada values. Partitions that are not specified and for which the group_id does not have a recorded offset are omitted.
After consuming messages from partitions missing at output from list_consumer_group_offsets, these partitions will be at output of the next call of list_consumer_group_offsets (I checked that). So, this is a feature, not bug