Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.

Status

Current state: Under Discussion

...

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

Motivation

Currently Kafka Producer is able to identify unavailable partitions and avoid routing messages to them, but the definition of an unavailable partitions is - the leader of the partition is not available, this may have covered most of the cases to avoid unnecessary network calls etc.

...

By exposing the min.insync.replicas of each Kafka topic to Producer, we could potentially avoid exhausting the entire Producer buffer and unnecessary network calls when a partition does not have enough in-sync replicas in the cluster and new replication may take a while to complete (partition is too large).

Public Interfaces

MetadataResponse

Add one more property called minInSyncReplicas to the TopicMetadata class that located in MetadataResponse class.

Code Block
languagejava
titleMetadataReponse.TopicMetadata
public static class TopicMetadata {
    private final Errors error;
    private final String topic;
    private final boolean isInternal;
    private final List<PartitionMetadata> partitionMetadata;
    private int authorizedOperations;
    private int minInSyncReplicas;
}

MetadataResponseTopic.SCHEMA_10

Add

...

one

...

more

...

field

...

min_insync_replicas

...

to

...

the

...

MetadataResponseTopic

...

response

...

and

...

bump

...

up

...

the

...

version.

Code Block
languagejava
titleMetadataResponseTopic.SCHEMA_10
public static final Schema SCHEMA_10 =
    new Schema(
        new Field("error_code", Type.INT16, "The topic error, or 0 if there was no error."),
        new Field("name", Type.COMPACT_STRING, "The topic name."),
        new Field("is_internal", Type.BOOLEAN, "True if the topic is internal."),
        new Field("partitions", new CompactArrayOf(MetadataResponsePartition.SCHEMA_9), "Each partition in the topic."),
        new Field("topic_authorized_operations", Type.INT32, "32-bit bitfield to represent authorized operations for this topic."),
        new Field("min_insync_replicas", Type.INT16, "min.insync.replicas of this topic."),
        TaggedFieldsSection.of(
        )
    );

Partitioner

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/common/serialization

    • org/apache/kafka/common

    • org/apache/kafka/common/errors

    • org/apache/kafka/clients/producer

    • org/apache/kafka/clients/consumer (eventually, once stable)

  • Monitoring

  • Command line tools and arguments

  • Anything else that will likely break existing users in some way when they upgrade

Proposed Changes

Add one extra parameter requireMinInSyncAcks to the partition method of Partitioner, so that we are able to build a readyPartitions on top of the availablePartitions that we get from cluster.availablePartitionsForTopic(topic) and partition messages by the readyPartitions.

Code Block
languagejava
titlePartitioner
/**
 * Compute the partition for the given record.
 *
 * @param topic The topic name
 * @param key The key to partition on (or null if no key)
 * @param keyBytes The serialized key to partition on( or null if no key)
 * @param value The value to partition on or null
 * @param valueBytes The serialized value to partition on or null
 * @param requireMinInSyncAcks The value of acks of producer
 * @param cluster The current cluster metadata
 */
public int partition(String topic, Object key, byte[] keyBytes, Object value, byte[] valueBytes, boolean requireMinInSyncAcks, Cluster cluster);

Proposed Changes

The KafkaApis.handleTopicMetadataRequest needs to be updated to populate min_insync_replicas to MetadataResponseTopic

Add one more parameter requireMinInSyncAcks to Partitioner.partition method so that we are able to build a readyPartitions on top of the availablePartitions that we get from cluster.availablePartitionsForTopic(topic) and partition messages by the readyPartitions. When the acks of producer is set to 0 or 1, readyPartitions is identical to the availablePartitions we get from clusterDescribe 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.

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?

Rejected Alternatives

...

The new field will not be populated when new clients talk to older brokers or when old clients talk to newer brokers, so there shouldn't be any compatibility issue.

Rejected Alternatives