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

Compare with Current View Page History

« Previous Version 6 Next »

 

Status

Current stateUnder Discussion

Discussion threadhere

JIRA:

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

Motivation

This KIP aims to solve two problems:

1. There is currently no way for a Kafka client to know which API version the broker supports. This means a client might not be able to perform its desired functionality, nor report any meaningful errors back to the application. Which leads in to problem number two:..

2. Unsupported requests are not handled gracefully by the broker. A broker receiving a protocol request it does not support will simply close the TCP connection to the client. From the client's point of view it has no way of knowing that the broker did not support the request, it could just as well be a network or software problem causing the connection reset.

This makes it hard for clients and applications to support multiple versions of Kafka, which in turn limits the Kafka eco-system since applications and clients will need to be manually built or configured for a specific broker version.


Public Interfaces

Add protocol BrokerMetadataRequest & Response message

BrokerMetadataRequest => (empty)
 
BrokerMetadataResponse => ProtocolVersion [Key Value]
  ProtocolVersion => int32   // Global protocol version, bumped manually for each addition to the protocol. Starts at 9 (for 0.9.0.0) with the addition of this request type.
  Key => String              // Generic key name, such as "broker.version"
  Value => String            // Generic value for key, e.g. "0.9.0.0"

Note: the ProtocolVersion field could be a Key-Value too, but having it as a specific int field might make it easier for clients to use.



Java client
TBD: some interface to query BrokerMetadata information

Proposed Changes

1. New protocol API: BrokerMetadataRequest and BrokerMetadataResponse

This KIP proposes a new protocol request and response to be added to the Kafka protocol, BrokerMetadataRequest and BrokerMetadataResponse. While adding only the ProtocolVersion field to the response would solve the issues at hand it is probably a good idea to conceive a more generic interface that allows the broker to communicate any sort of information about itself in a generic fashion to cater for future needs, such as communicating supported features, protocols, endpoints, etc, to the client.

To this end the proposal suggests a string-based key-value array response message populated by the broker.

Suggestions/examples on (future) uses of Key & Value which may be of relevance to clients:

KeyValue (example)Reason
broker.version0.9.0.0Useful for monitoring applications, admin tools, etc.
supported.compression.codecssnappy,gzip,lz4Lets a newer producer avoid using unsupported codecs. Alternatively using the Message.Attributes codes (e.g. "1,2,5").
endpointsplaintext:9091,ssl:9092

Announces broker endpoints, allows clients to "upgrade" connection to SSL

<...><..>Arbitrary key-value configured in broker.properties by user. E.g., "rack"="a1b2", for consumer balancing.

Another benefit of this API is further client de-integration from ZooKeeper since broker and cluster metadata may now be queried directly from the broker.

While this new API has little impact to begin with it will be of great value as new protocol additions are made and it allows a thriving eco-system with generic clients and tools that can operate on multiple broker versions (which is important for tools/libs/apps packages provided by Linux distributions, or are otherwise not versioned with the official Kafka project, i.e., the non-java clients).

 

2. Improved handling of unsupported requests on broker

Additionally, to solve issue nr 2. - ungraceful handling of unknown requests - it is also suggested to make the following change in the broker request handling code:

If a request is received for an unknown protocol request type, or for an unsupported version of a known type, the broker should respond with an empty response only including the common Length+CorrId header with Length=0, instead of closing the connection. The effect of this empty message received by the client is that the client will fail to parse the response (since it will expect a proper non-empty reply) and throw an error to the application with the correct context - that of a protocol parsing failure for request type XYZ. All existing clients should be able to handle this gracefully without any alterations to the code, while updated clients supporting the proposals in this KIP can handle the empty response accordingly by returning a "Request not supported by server" error the application. The level of detail in the returned error message to the application naturally varies between client implementations but is still by far better than a closed connection which says nothing of the underlying error.

 

Compatibility, Deprecation, and Migration Plan

  • Existing clients are not affected by 1. (BrokerMetadataRequest), but will get the error propagation benefits of 2. (graceful errors).
  • Updated clients that add support for 1. will be able to adapt their functionality based on broker functionality and provide meaningful error propagation to applications when proper broker support is lacking.
  • Release with 0.9.0.0: Since 0.9.0.0 will incorporate a large number of new protocol request types that the various client implementations are likely to pick up and implement it makes sense to add this new functionality along with it.

Rejected Alternatives

 

  • No labels