Note this was initially erroneously assigned as KIP-178, which was already taken, and has been reassigned KIP-179.
Current state: Under Discussion [One of "Under Discussion", "Accepted", "Rejected"]
KAFKA-5601Getting issue details...
KAFKA-5561Getting issue details...
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Describe the problems you are trying to solve.
ReassignPartitionsCommand (which is used by the
kafka-reassign-partitions.sh tool) talks directly to ZooKeeper. This prevents the tool being used in deployments where only the brokers are exposed to clients (i.e. where the zookeeper servers are intentionally not exposed). In addition, there is a general push to refactor/rewrite/replace tools which need ZooKeeper access with equivalents which use the
AdminClient API. Thus it is necessary to change the
ReassignPartitionsCommand so that it no longer talks to ZooKeeper directly, but via an intermediating broker. Similar work is needed for the
kafka-topics.sh tool (which can also change assignments and numbers of partitions and replicas), so common
AdminClient and protocol APIs are desirable.
ReassignPartitionsCommand currently has no proper facility to report progress of a reassignment;
--verify can be used periodically to check whether the request assignments have been achieved. It would be useful if the tool could report progress better.
Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that will come along with this feature.
A public interface is any change to the following:
Binary log format
The network protocol and api behavior
Any class in the public packages under clientsConfiguration, especially client configuration
org/apache/kafka/clients/consumer (eventually, once stable)
Command line tools and arguments
- Anything else that will likely break existing users in some way when they upgrade
Two new network protocol APIs will be added:
AdminClient API will have two new methods added (plus overloads for options):
The options accepted by
kafka-reassign-partitions.sh command will change:
--zookeeperwill be deprecated, with a warning message
- a new
--bootstrap-serveroption will be added
- a new
--progressaction option will be added
Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.
--zookeeper option will be retained and will:
- Cause a deprecation warning to be printed to standard error. The message will say that the
--zookeeperoption will be removed in a future version and that
--bootstrap-serveris the replacement option.
- Perform the reassignment via ZooKeeper, as currently.
--bootstrap-server option will be added and will:
- Perform the reassignment via the given intermediating broker.
--bootstrap-server in the same command will produce an error message and the tool will exit without doing the intended operation.
It is anticipated that a future version of Kafka would remove support for the
--progress action option will be added. This will only be supported when used with
--bootstrap-server. If used with
--zookeeper the command will produce an error message and the tool will exit without doing the intended operation.
--progress will report on the synchronisation of each of the partitions and brokers in the reassignment given via the
That might print something like the following:
ReassignPartitionsCommand will be refactored to support the above changes to the options. An interface will abstract the commands currently issued directly to zookeeper.
There will be an implementation which makes the current calls to ZooKeeper, and another implementation which uses the
AdminClient API described below.
In all other respects, the public API of
ReassignPartitionsCommand will not be changed.
The following methods will be added to
AdminClient to support the ability to reassign partitions:
The following methods will be added to
AdminClient to support the progress reporting functionality:
With broker-mediated reassignment it becomes possible limit the authority to perform reassignment to something finer-grained than "anyone with access to zookeeper".
The reasons for reassignment are usually operational. For example, migrating partitions to new brokers when expanding the cluster, or attempting to find a more balanced assignment (according to some notion of balance). These are cluster-wide considerations and so authority should be for the reassign operation being performed on the cluster. Therefore
alterTopics() will require
ClusterAction on the
replicaStatus() will require
Describe on the
AlterTopicsRequest will initiate the process of topic alteration/partition reassignment
the topic name
the number of partitions. A
the replication factor. A
the partition id
the ids of the assigned brokers for this partition
true to just validate the request, but not actually alter the topics
|the timeout, in ms, to wait for the topic to be altered.|
partition_assignment would mean that the broker should calculate a suitable assignment. Such broker calculated assignment is unlikely to be balanced.
It is not necessary to send an A
lterTopicsRequest to the leader for a given partition. Any broker will do.
AlterTopicsResponse enumerates those topics in the request, together with any error in initiating alteration:
duration in milliseconds for which the request was throttled
the topic name
the error code for altering this topic
detailed error information
Possible values for
CLUSTER_AUTHORIZATION_FAILED(31) Authorization failed
INVALID_TOPIC_EXCEPTION(17) If the topic doesn't exist
INVALID_PARTITIONS(37) If the
INVALID_REPLICATION_FACTOR(38) If the
UNKNOWN_MEMBER_ID(25) If any broker ids in the
artition_assignmentincluded an unknown broker id
INVALID_REQUEST(42) If trying to modify the partition assignment and the number of partitions or the partition assignment and the replication factor in the same request. Or if duplicate
topics appeared in the request.
INVALID_REPLICA_ASSIGNMENT(39) If a partition, replica or broker id in the
partition_assignmentdoesn't exist or is incompatible with the requested
error_messagewould contain further information.
NONE(0) If the request was successful and the alteration/reassignment has been started.
As currently, it will not be possible to have multiple reassignments running concurrently, hence the addition of the
PARTITION_REASSIGNMENT_IN_PROGRESS error code.
CreateTopicPolicy can be used to apply a cluster-wide policy on topic configuration at the point of creation via the
create.topic.policy.class.name config property. To avoid an obvious loophole, it is necessary to also be able to apply a policy to topic alteration. Maintaining two separate policies in sync is a burden both in terms of class implementation and configuring the policy. It seems unlikely that many use cases would require a different policy for alteration than creation. On the other hand, just applying the
CreateTopicPolicy to alterations is undesirable because:
- Its name doesn't convey that it would be applied to alterations too
- Its API (specifically its
RequestMetadatamember class) includes topic
Map<String, String>) which is not part of the API for topic alteration even though it is part of the API for topic creation.
- It prevents any use cases which legitimately did need to apply a different policy for alteration than creation.
Finding a balance between compatibility with existing deployments, and not opening the loophole is difficult.
create.topic.policy.class.name config would continue to work, and would continue to name an implementation of
CreateTopicPolicy. That policy would be applied to alterations automatically. The topic's config would be presented to the
validate() method (via the
RequestMetadata) even though it's not actually part of the
AlterTopicsRequest. The documentation for the interface and config property would be updated.
ReplicaStatusRequest requests information about the progress of a number of replicas.
a topic name
a partition id of this topic
a follower broker id for this partition
The response includes replication information for each of the replicas in the request:
the topic name
the partition id of this topic
the follower broker id
an error code
the time the status was current
the lag (#messages) of this broker, for this partition
Anticipated errors are:
CLUSTER_AUTHORIZATION_FAILED(31) Authorization failed. (or the TOPIC?)
INVALID_TOPIC_EXCEPTION(17) The topic is not known
_idof the given topic is not valid
UNKNOWN_MEMBER_ID(25) The given
brokerid is not known.
UNKNOWN_TOPIC_OR_PARTITION(3) The given
brokeris not a follower for the partition identified by
NONE(0) if the status request completed normally,
AdminClient.replicaStatus() will make the underlying
ReplicaStatusRequest to the leader for the given partition. This saves the need for every broker (because any broker could be the
--bootstrap-server ) to have knowledge of the replication status of every replica, which would be inefficient in network IO and/or memory use.
Compatibility, Deprecation, and Migration Plan
- What impact (if any) will there be on existing users?
- If we are changing behavior how will we phase out the older behavior?
- If we need special migration tools, describe them here.
- When will we remove the existing behavior?
Existing users of the
kafka-reassign-partitions.sh will receive a deprecation warning when they use the
--zookeeper option. The option will be removed in a future version of Kafka. If this KIP is introduced in version 1.0.0 the removal could happen in 2.0.0.
If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.
One alternative is to do nothing: Let the ReassignPartitionsCommand continue to communicate with ZooKeeper directly.
Another alternative is to do exactly this KIP, but without the deprecation of
--zookeeper. That would have a higher long term maintenance burden, and would prevent any future plans to, for example, provide alternative cluster technologies than ZooKeeper.