-
Notifications
You must be signed in to change notification settings - Fork 237
Description
Hello, I have kafka topic with 4 partitions and 2 instances of my application, each of them has established 1 Kafka receiver flux. So, there are 2 consumers in Kafka consumer group, each of them pools events from 2 topic partitions. I use default receiver options with manual acknowledgment and auto-commit enabled.
Lets consider that consumer1 has assigned partition0, partition1, consumer2 - partition2, partition3
I have scaled up my application and deployed 2 more instance, it has triggered consumer group rebalance.
Expected Behavior
After rebalanced there should be 4 Kafka consumers and each of them should process events only from one topic partition.
Actual Behavior
Actually there are 4 Kafka consumer in consumer group, and each of them has only one partition assigned.
But after rebalance partition0 has been assigned on new consumer3. Since partition0 has been previously assigned on consumer1, it has prefetched a batch of events. And after rebalance rebalance was performed these"ore-fetched" events was processed on BOTH consumer.
Note: it is reproducible under high load on Kafka topic. In my case there was a 6000 offset lag on each partition at the moment pf rebalance.
Could you please clarify is it expected behavior for reactive kafka?
I have found a possible workaround for this issue: https://medium.com/thinkspecial/handling-partition-rebalancing-3e4f3cb192b0. It seems it can help, but I have not tested it yet.