-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consume as part of consumer group consumes more than max-messages #198
Comments
Is this bug planned to be addressed any time soon? I do not know enough Go to figure out how to fix it myself, but it looks like draining the channel after consuming max-messages is intentional (those "drop message" log entries) and just not doing that (draining) might fix the issue. |
The problem is not that easy to solve: Suppose you have a topic with 4 partitions and you want to read only a single message. In order to know on which partition the next message was produced, you will have to read one message from all partitions and then compare their timestamps. Finally, you have to mark only one of these messages as consumed. This will lead to a bigger change in how the consumption of messages is implemented. Hence, I cannot predict when I will have time to look into it. |
"In order to know on which partition the next message was produced, you will have to read one message from all partitions and then compare their timestamps. Finally, you have to mark only one of these messages as consumed." - that is not how it works. Broker decides where a returning consumer should pick up based on where they left off and order of messages in the topic. In other words, the logic you describe is implemented on broker side, consumers don't have to bother with that. If there's just one consumer in the consumer group, it will consume messages from a topic in order or arrival regardless if it's partitioned or not, and if there are multiple consumers in a group then order on topic level simply can't be guaranteed (but it's still guaranteed within each partition). Ordered consumption from a topic requires single partition or a key which constrains keyed messages to single partition where order is guaranteed, it's a well-known behavior. And the use case here is really simple: read messages from a topic in whatever order the broker returns them and stop after reading N. There is no assumption or expectation that this will be done concurrently in more than one invocation of the program, but if that's the case, the invoker is expected to understand the relationships between multiple consumers in a group and multiple partitions in a topic and how this affects order of consumption. |
Current behavior:
kafkactl consume -g group_name --max-messages 1 topic.name
advances
group_name
consumer offset by more than 1 while only outputting one message. Simple reproducer:you will notice that messages are "skipped" and CG offset advances by more than 1 after each invocation of
kafkactl consume
. In my case:Expected behavior:
Each invocation of
kafkactl consume
with--max-messages
parameter and consumer group advances that consumer group's offset by no more than the value ofmax-messages
parameter so that no messages are skipped during consumption.Version tested:
cmd.info{version:"v5.0.6", buildTime:"2024-03-14T10:08:45Z", gitCommit:"d7f78e0", goVersion:"go1.21.8", compiler:"gc", platform:"linux/amd64"}
The text was updated successfully, but these errors were encountered: