You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Jon McEwen (Jira)" <ji...@apache.org> on 2021/09/20 06:53:00 UTC

[jira] [Comment Edited] (KAFKA-9965) Uneven distribution with RoundRobinPartitioner in AK 2.4+

    [ https://issues.apache.org/jira/browse/KAFKA-9965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17417479#comment-17417479 ] 

Jon McEwen edited comment on KAFKA-9965 at 9/20/21, 6:52 AM:
-------------------------------------------------------------

Here is my current WIP patch for fixing round robin:
 [https://github.com/apache/kafka/pull/11326]

[~showuon] please could you help me with formatting?  I can't find a gradle task for formatting Java code.

Do you think a unit test based on the current call pattern from producer is sufficient?  I think there is another ticket open for creating integration tests.


was (Author: jonmcewen):
I think I had something similar to the above initially, but it had thread safety issues.

Here is my current WIP patch
[https://github.com/apache/kafka/pull/11326]



[~showuon] please could you help me with formatting?  I can't find a gradle task for formatting Java code.

Do you think a unit test based on the current call pattern from producer is sufficient?  I think there is another ticket open for creating integration tests.

> Uneven distribution with RoundRobinPartitioner in AK 2.4+
> ---------------------------------------------------------
>
>                 Key: KAFKA-9965
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9965
>             Project: Kafka
>          Issue Type: Bug
>          Components: producer 
>    Affects Versions: 2.4.0, 2.5.0, 2.4.1
>            Reporter: Michael Bingham
>            Priority: Major
>
> {{RoundRobinPartitioner}} states that it will provide equal distribution of records across partitions. However with the enhancements made in KIP-480, it may not. In some cases, when a new batch is started, the partitioner may be called a second time for the same record:
> [https://github.com/apache/kafka/blob/2.4/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java#L909]
> [https://github.com/apache/kafka/blob/2.4/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java#L934]
> Each time the partitioner is called, it increments a counter in {{RoundRobinPartitioner}}, so this can result in unequal distribution.
> Easiest fix might be to decrement the counter in {{RoundRobinPartitioner#onNewBatch}}.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)