IBM / sarama

Sarama is a Go library for Apache Kafka.
MIT License
11.38k stars 1.75k forks source link

Error not being thrown when multiple consumer groups are created with the same group ID #2842

Closed AhmedNSidd closed 1 month ago

AhmedNSidd commented 5 months ago

Description

The issue is simple:

consumerGroup1, err := sarama.NewConsumerGroup(same_kafka_broker, "groupId", sarama.NewConfig())
consumerGroup2, err := sarama.NewConsumerGroup(same_kafka_broker, "groupId", sarama.NewConfig())

The above code should given an error because you're not supposed to be able to create two consumer groups with the same group ID, but you're able to do so here.

Additional context

N/A

dnwe commented 5 months ago

👋🏻 hi and thanks for raising this question

The above code should given an error because you're not supposed to be able to create two consumer groups with the same group ID, but you're able to do so here

Why would it not be allowed? A consumer group is intended to contain more than one consumer. Whilst unusual, if you use the same groupId for two sarama.NewConsumerGroup(...) calls within the same Go process, it is really no different functionally to you running two separate Go processes that both join the same group. You'll just have two members within your single process, with different partition assignments within the same group.

AhmedNSidd commented 5 months ago

Why would it not be allowed? A consumer group is intended to contain more than one consumer. Whilst unusual, if you use the same groupId for two sarama.NewConsumerGroup(...) calls within the same Go process, it is really no different functionally to you running two separate Go processes that both join the same group. You'll just have two members within your single process, with different partition assignments within the same group.

Alright, fair enough. It just wasn't something that was clear to me from looking at the function's signature / documentation because as far as I know in Kafka, if you try to create a new consumer group with the same group ID as one that already exists, you can't generally do that. What you're referring to seems to be adding new consumers to the existing consumer group (I could be wrong, I'm still learning Kafka).

Anyway, I think we can close this issue.

github-actions[bot] commented 2 months ago

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the main branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.