You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Eric Chang (Jira)" <ji...@apache.org> on 2026/10/09 13:26:00 UTC
[jira] [Assigned] (KAFKA-21252) NewPartitions#increaseTo no longer follows partition 0’s replication factor in KRaft mode
[ https://issues.apache.org/jira/browse/KAFKA-21252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Chang reassigned KAFKA-21252:
----------------------------------
Assignee: Eric Chang (was: Chia-Ping Tsai)
> NewPartitions#increaseTo no longer follows partition 0’s replication factor in KRaft mode
> -----------------------------------------------------------------------------------------
>
> Key: KAFKA-21252
> URL: https://issues.apache.org/jira/browse/KAFKA-21252
> Project: Kafka
> Issue Type: Improvement
> Reporter: Chia-Ping Tsai
> Assignee: Eric Chang
> Priority: Minor
>
> {code:java}
> val proposedAssignmentForNewPartitions = replicaAssignment.getOrElse {
> val startIndex = math.max(0, allBrokers.indexWhere(_.id >= existingAssignmentPartition0.head))
> CoreUtils.replicaToBrokerAssignmentAsScala(AdminUtils.assignReplicasToBrokers(allBrokers.asJava, partitionsToAdd, existingAssignmentPartition0.size,
> startIndex, existingAssignment.size))
> } {code}
> The zk broker picks partition 0’s replicas for the newly created partitions.
> {code:java}
> Iterator<PartitionRegistration> iterator = topicInfo.parts.values().iterator();
> if (!iterator.hasNext()) {
> throw new UnknownServerException("Invalid state: topic " + topic.name() +
> " appears to have no partitions.");
> }
> PartitionRegistration partitionInfo = iterator.next();
> if (partitionInfo.replicas.length > Short.MAX_VALUE) {
> throw new UnknownServerException("Invalid replication factor " +
> partitionInfo.replicas.length + ": expected a number equal to less than " +
> Short.MAX_VALUE);
> }
> short replicationFactor = (short) partitionInfo.replicas.length;{code}
> By contrast, the kraft broker picks the "first" partition, but the "first" depends on the hash slot layout. Hence, it is unpredictable to users :(
> It can be fixed simply by replacing the `.next` to `parts.get(0)` :)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)