You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Status

Current state"Under Discussion"

Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]

JIRA Unable to render Jira issues macro, execution error.

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Whether the preferred replica is the partition leader directly affects the external output traffic of the broker. When the preferred replica of all partitions becomes the leader, the external output traffic of the broker will be in a balanced state. When there are a large number of partition leaders that are not preferred replicas, it will be destroyed this state of balance.

Currently, the controller will periodically check the unbalanced ratio of the partition preferred replicas (if enabled) to trigger the preferred replica election, or manually trigger the election through the kafka-leader-election tool. However, if we want to know which partition leader is in the non-preferred replica, we need to look it up in the controller log or judge ourselves from the topic details list.

We hope to add an interface to TopicCommand to directly obtain the list of partitions whose leader is in a non-preferred replica.

Public Interfaces

kafka-topic.sh:

The topic command will accept the --under-preferred-replica-partitions option when using the --bootstrap-server option.

Proposed Changes

Make some changes in TopicCommand.scala

TopicCommand.scala
    def isUnderPreferredReplicaPartitions: Boolean = {
      hasLeader && !info.leader.equals(info.replicas.asScala.head)
    }

    private def shouldPrintUnderPreferredReplicaPartitions(partitionDescription: PartitionDescription): Boolean = {
      opts.reportUnderPreferredReplicaPartitions && partitionDescription.isUnderPreferredReplicaPartitions
    }

    private val reportUnderPreferredReplicaPartitionsOpt = parser.accepts("under-preferred-replica-partitions",
      "if set when describing topics, only show partitions whose leader is not equal to the first replica in the replica list. Not supported with the --zookeeper option.")

    private val allReplicationReportOpts = Set(reportUnderReplicatedPartitionsOpt, reportUnderMinIsrPartitionsOpt, reportAtMinIsrPartitionsOpt, reportUnavailablePartitionsOpt, reportUnderPreferredReplicaPartitionsOpt)

    def reportUnderPreferredReplicaPartitions: Boolean = has(reportUnderPreferredReplicaPartitionsOpt)

	# Some other minor changes omitted


Compatibility, Deprecation, and Migration Plan

The new option has no effect on existing usage.

Rejected Alternatives

  • No labels