Skip to content

Consumer group not consuming due to multiple k6 init #37

@timkersch

Description

@timkersch

When using the consumer group feature to subscribe to all partitions in a topic, I got some very strange behaviour where some runs of the code did consume messages and some runs were just stuck and did not get any messages back.

After a lot of debugging I found that k6 runs the init code (code outside of methods) multiple times: https://community.k6.io/t/why-init-called-4-times/973

This caused multiple consumer group instances to be created, which in turn meant that partitions were distributed between them. Thus, sometimes the consumer group created during the last init contained the partitions where my data was, and sometimes it did not contain the right partitions as they were assigned to consumers created in a previous run of init.

I solved this by using a UUID when naming my consumer group, thereby guaranteeing that my consumer group object was assigned to all partitions in a topic.

Although this is not per-se a bug in xk6-kafka, when I followed the documentation here there was no mention of this and the examples all used consumers directly in the init code.
I would suggest to either make this clear in the documentation of somehow alter the code to avoid this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    📖 DocumentationImprovements or additions to documentation

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions