You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Stephane Maarek (Jira)" <ji...@apache.org> on 2023/01/04 20:18:00 UTC

[jira] [Updated] (KAFKA-14573) RoundRobinPartitioner doesn't work as expected with topic that has 6 partitions

     [ https://issues.apache.org/jira/browse/KAFKA-14573?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stephane Maarek updated KAFKA-14573:
------------------------------------
    Description: 
Create a topic with 6 partitions (that's how the behavior is observed)
```
kafka-topics.sh --bootstrap-server localhost:9092 --topic test_topic --create --partitions 6
```

Start a consumer
```
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --formatter kafka.tools.DefaultMessageFormatter --property print.timestamp=true --property print.key=true --property print.value=true --property print.partition=true --from-beginning
```

Start a producer using `RoundRobinPartitioner`
```
kafka-console-producer.sh --bootstrap-server localhost:9092 --producer-property partitioner.class=org.apache.kafka.clients.producer.RoundRobinPartitioner --topic test_topic
```

And you will see only 3 partitions get produced to (not 6)

This doesn't happen with 3 partitions, 5, 7, 9 partitions (we get the expected behavior).

But with 6.... it happens.

Verified to be like this on my colleague's computer too. 

```
CreateTime: 1672859052082 Partition: 5 null a
CreateTime: 1672859053586 Partition: 1 null b
CreateTime: 1672859054995 Partition: 3 null c
CreateTime: 1672859056405 Partition: 5 null d
CreateTime: 1672859057861 Partition: 1 null e
CreateTime: 1672859059181 Partition: 3 null f
```

  was:
Create a topic with 6 partitions (that's how the behavior is observed)
```
kafka-topics.sh --bootstrap-server localhost:9092 --topic test_topic --create --partitions 6
```

Start a consumer
```
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --formatter kafka.tools.DefaultMessageFormatter --property print.timestamp=true --property print.key=true --property print.value=true --property print.partition=true --from-beginning
```

Start a producer using `RoundRobinPartitioner`
```
kafka-console-producer.sh --bootstrap-server localhost:9092 --producer-property partitioner.class=org.apache.kafka.clients.producer.RoundRobinPartitioner --topic test_topic
```

And you will see only 3 partitions get produced to (not 6)

This doesn't happen with 3 partitions, 5, 7, 9 partitions (we get the expected behavior).

But with 6.... it happens.

Verified to be like this on my colleague's computer too. 

```
CreateTime: 1672859052082 Partition: 5 null a
CreateTime: 1672859053586 Partition: 1 null b
CreateTime: 1672859054995 Partition: 3 null C
CreateTime: 1672859056405 Partition: 5 null d
CreateTime: 1672859057861 Partition: 1 null e
CreateTime: 1672859059181 Partition: 3 null e
```


> RoundRobinPartitioner doesn't work as expected with topic that has 6 partitions
> -------------------------------------------------------------------------------
>
>                 Key: KAFKA-14573
>                 URL: https://issues.apache.org/jira/browse/KAFKA-14573
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 3.3.1
>            Reporter: Stephane Maarek
>            Priority: Major
>         Attachments: image-2023-01-04-20-15-43-039.png
>
>
> Create a topic with 6 partitions (that's how the behavior is observed)
> ```
> kafka-topics.sh --bootstrap-server localhost:9092 --topic test_topic --create --partitions 6
> ```
> Start a consumer
> ```
> kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --formatter kafka.tools.DefaultMessageFormatter --property print.timestamp=true --property print.key=true --property print.value=true --property print.partition=true --from-beginning
> ```
> Start a producer using `RoundRobinPartitioner`
> ```
> kafka-console-producer.sh --bootstrap-server localhost:9092 --producer-property partitioner.class=org.apache.kafka.clients.producer.RoundRobinPartitioner --topic test_topic
> ```
> And you will see only 3 partitions get produced to (not 6)
> This doesn't happen with 3 partitions, 5, 7, 9 partitions (we get the expected behavior).
> But with 6.... it happens.
> Verified to be like this on my colleague's computer too. 
> ```
> CreateTime: 1672859052082 Partition: 5 null a
> CreateTime: 1672859053586 Partition: 1 null b
> CreateTime: 1672859054995 Partition: 3 null c
> CreateTime: 1672859056405 Partition: 5 null d
> CreateTime: 1672859057861 Partition: 1 null e
> CreateTime: 1672859059181 Partition: 3 null f
> ```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)