-
Notifications
You must be signed in to change notification settings - Fork 387
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
Increasing consumers in consumer group cause rebalance failure with CommitFailedException because of revoked partition #750
Comments
We have the same problem here and I think we have found the explanation.
But this error is not related to the I'm pretty sure that Akka was depending on the behavior of Kafka's |
It looks like I have a test showing this now. Will stabilize and send a PR. |
Hi @ennru, have you any clue of how we could ensure that process is completed (or timed out) |
Also, I may have misunderstood your test, but your comment seems strange to me:
The case I have described does not require committing before the end of the rebalancing, the issue occurs even if we commit after the rebalancing, as long as the group duration condition is not met |
Yes, the funny thing is once the |
Sorry but I don't get it, if my group contains records of a revoked partition and I commit it, it will fail, regardless of whether the |
For me, it doesn't fail once the rebalance has finished. But I know, that doesn't really make sense. If you are happy with getting messages redelivered, you may add a supervision strategy to resume on |
I have to admit that indeed it doesn't make sense for me, I can't see how a Kafka broker will in any case accept a commit of revoked partitions for a consumer. The exception message seems quite clear: I'm pretty sure I can reproduce this using a simple Just to be sure, have you set the We can accept a few duplicated messages on rare case, but actually it will happen each time a rebalance occurs. Even worse, this issue has a snowball effect when we have several consumers: a rebalance (scale up only) will cause almost all consumers to raise a I think we should try to find a way to allow consumers flushing the pending data and committing before rejoining the group within an acceptable amount of time.
|
Thank you for your input on it, I'll dig into it. You can mitigate the problem with a supervision strategy on the Committer:
This will ignore the failed commits, and not take down the flow. So you avoid rippling efect of consumers shutting down. |
Hi @ennru Thank you for your reply so far. Also @laymain Thanks for the details. @ennru I was thinking about doing that. The only worry that I had was, If i use the resume do i run the risk to drop good drop good messages or not ? What i mean is if we commit in batch, is there a potential that i have started to fetch the new message from the new partition and end up with a batch to commit that include message for partition i have been revoked and message for partition i have been newly assign. Am i sure that all the good messages will pass trough and the fail will only happen for the bad messages. In other words, one big batch commit operation will partially succeed but return commit failed exception ? If that is the case, then your solution make sense. But if Kafka, reject the all batch commit because some of the message are wrong, then resuming will drop the good message. Does that make sense ? Have you though about that scenario ? |
Thank you, this workaround will indeed stop the consumers from crashing and the risk of triggering new rebalances. |
@Maatary There is a risk of producing duplicates because of not committing offsets, but since you are committing a batch, it means that have produced all messages contained in that batch, you won't drop good messages. |
@laymain Can you expand on this I did not get that:
|
Hum... I'll give a try:
From here there are two scenarios, depending on how it is implemented, we should check
In any case, you will redeliver some messages but won't drop any. |
The Scenario I have in mind is:
1 - Consumer 1 process some messages 2 - Rebalance occur in the mean time 3 - Consumer 1 get partition 2 4 - Consumer 1 start consuming from partition 2 not committing yet the message from partition 1 he already consumed (This could be because of the size of your batch) 5 - Consumer 1 rich a commit batch size, that contains message from partition 2 and partition 1 6 - Consumer 1 commit the batch and fail 7 - Then with the resume above, consumer 1 drop the all batch (**does the all batch failed or only messages from partition 1 ???? **) 8 - Consumer 1 resume and continue with the message of the new partition, not committing those messages from the new partition 2, but then commit the following messages of partition 2. That's potentially something that could happen. This does not mean the the messages from partition 2 drop were not processed but still they were not committed and that is not good. The issue here GroupWithin, can group message from the revoked partition and message from the new partition, or CommitBatch can batch together message from the old partition and message from the new partition. If however the semantic of commit of the Kafka API is you get everything expected those who failed and therefore get a commit exception for those only, then it works, however that would not be very nice. |
The Dilemma however is that a restart might cause a chain of restart cascade. Not completely sure of that tho. Somehow akka stream manage handle some use cases well :) !! i just can't completely predict the behavior :) |
I don't know if I'm misunderstanding what you're saying or if you're misunderstanding how offsets committing works but your following statement doesn't make sense for me
Batch isn't dropped, you're not using transactions, only the commit fails.
You should go further on this, ask yourself why is it not good? What are the risks? To give an answer to your worries, the behavior seems predictible to me depending on the scenario, I can't see a case where messages were dropped, only more or less redelivered messages |
Isn't what resume does is dropping messages ? If you do What I am saying in essence is what happens if in that batch, you have offsets of the revoked partition combined with offset of the partition you do own ? |
Nothing in particular, offsets of both partition aren't committed, |
I've written down my insights around this issue in #755 |
That was my worry with the resume, you will commit in order but skip committing some valid offset in the process. I don't know if that's a good thing in general. e.g commit 1 2 3 skipp 4 5 6 and commit 7 8 9. You will skip 4 5 6 because you are committing at the same time x y z which are of a revoked partition. Given that i do not know the consequence of doing that i just raised the question :) |
@Maatary That's not really how it works, when you have messages 1, 2, 3 in your batch, you will only commit offset 3, you don't need to commit offsets one by one. Committing has no effect on messages, it is just saving your group progression in consuming the stream, it's checkpointing. @ennru I've read your insights, I'm not sure that I'm understanding the implications, have you got in mind a solution that will avoid redelivering messages systematically on rebalance? Are you planning to disable polling until the pending messages are processed and committed (or timed out), not only until rebalance is finished? |
@laymain I think I found a case where that could be problematic. It is if you reach the end of the stream. Basically if you fail to commit the last offsets of a partition because your batch commit failed because it included offset of a partition you do not own anymore, then you consumer will act like he is done i.e. stop consuming from the partition, but then if you look into kafka/lenses, you will notice that there is still a lag and nobody is consuming those last offset ? It will take to have new messages in that partition for your consumer to request for new offsets. So in essence, yes you will have processed them, but for monitoring purpose it is a problem, if you use things like lenses, you will see that for a specific partition, some offset are not consumed yet, and nobody is consuming them, and you won't understand why. If you skip some commit and it appears that what you just skept, were the last offset of a partition you own, then, you can not signal to kafka that you have reach the end of the steam for that partition and whatever tool you use to monitor your consumer, will show you something confusing. |
My hunch is restarting the all stream instead of resume might be better. This all problem will not happen at all. However, I am just afraid that you will trigger a chain of rebalance as a result of it. Not sure, need to try it out |
## Purpose Commit 1: Make use of the fact that the rebalance listener `WrappedAutoPausedListener` is called on the thread that called `poll`, which is the actor thread. So it is safe to touch actor state. The messages sent from it before are turned into method calls. Commit 2: Isolate commit-refreshing into a class holding the data structures and deadline logic. Commit 3: When commit-refreshing is switched off (the default) no data needs to be collected at all. Depending on the `commit-refresh-interval` setting a no-op implementation might be used. ## Background Context I'm investigating #750 and rebalance handling for #539 and found this to be a good step on the way. Since Kafka 2.1 commit-refreshing is not required anymore, as [KAFKA-4682](https://issues.apache.org/jira/browse/KAFKA-4682) is resolved.
Fail actor of the rebalance doesn't finish within a timeout. Fixes akka#750
Fail actor of the rebalance doesn't finish within a timeout. Fixes akka#750
Fixed with #751 |
Hi,
I think this issue is related to #539 but I don't know if it is a bug, or the user is supposed to handle it himself.
So I have a consumer group, whenever i increase the number of consumer in that group, the revoking of partition is causing the following error:
This does not happen when i scale down the number of consumer. I mean so far i have not observed that. I assume this is because, partition are not revoke on scaling down. The remaining consumer just get new partition.
Note that, I do group message and commit batch things.
Here is how my code look like
My decider just does the following:
So I understand based on my reading of #539 that i have a number of inflight messages to commit back and I can't because of the revokation. That is, there is some rebalance that involve revokation that happen when the number of consumer is scaled up.
My service is at-least once, so i don't mind if another consumer reprocess those message. we don't have an at-most-one deliver constraint.
My question would be until the library handle those situation natively, how can i go about committing them anyway whenever revoke occurs or better yet, just discard them, so the consumer who get assigned the partition they belong too, will reprocess them.
Any suggestion ? I check the BalanceListener but i am not sure how to go about using it for this situation.
Note My timeout configs
The text was updated successfully, but these errors were encountered: