Status
Current state: Under Discussion
Discussion thread: here
JIRA: - KAFKA-3304Getting issue details... STATUS
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 the next problem, problem #2.
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.
Additional key points
- The broker version from MetadataResponse may be used in broker-broker communication to decide on a common protocol version between brokers with different versions, i.e., during upgrades.
Proposed Changes
In order for a client to successfully talk to a broker, it needs to know what versions of various protocols does the broker support. The KIP suggests the following to achieve that.
New Metadata Request and Response version, v1, will be added to provide information on supported protocol versions to clients.
MetadataRequest => api_keys, topics api_keys => [INT16] topics => [STRING] MetadataResponse => api_versions, brokers, topic_metadata api_versions => [single_api_versions] single_api_versions => api_key, min_version, max_version api_key => INT16 min_version => INT16 max_version => INT16 brokers => node_id host port node_id => INT32 host => STRING port => INT32 topic_metadata => topic_error_code topic [partition_metadata] topic_error_code => INT16 topic => STRING partition_metadata => partition_error_code partition_id leader [replicas] [isr] partition_error_code => INT16 partition_id => INT32 leader => INT32
Metadata Request v1 can be used by clients to ask for supported protocol versions by a broker. Client can send Metadata Request, v1, with api_keys set to one of the following values.
Empty array, this will get the client supported versions for all ApiKeys.
Array of some ApiKeys, this will get client supported versions for the specified ApiKeys.
Null array, this will not get any information on ApiKeys.
Broker on receiving a Metadata Request v1, will respond with MetadataResponse v1. The response will contain information on supported versions for api keys specified in the request, if an empty array of api keys is sent, then broker will respond with info on all api keys, and if null array is sent for api keys, then no information on protocol versions is added to the response. Note that broker only provides information on its supported protocol versions.
- Clients can choose to not receive topics metadata by specifying a null array for topics in Metadata Request v1.
Deprecation of a protocol version will be done by marking a protocol version as deprecated in protocol documentation. Documentation shall also be used to indicate a protocol version that must not be used, or for any such information.For instance, say 0.9.0 had protocol versions [0] for api key 1. On trunk, version 1 of the api key was added. Users running of trunk started using version 1 of the api and found out a major bug. To rectify that version 2 of the api is added to trunk. For some reason, it is now deemed important to have version 2 of the api should be added to 0.9.1 as well. To do so, version 1 and version 2 both of the api will be backported to the 0.9.1 branch. 0.9.1 broker will return 0 as min supported version for the api and 2 for the max supported version for the api. However, the version 1 should be clearly marked as deprecated on its documentation. It will be client's responsibility to make sure they are not using any such deprecated version.
Supported protocol versions obtained from a broker, is good only for current connection on which that information is obtained. In the event of disconnection, the client should obtain the information from the broker again, as the broker might have upgraded/ downgraded in the mean time.
- If a client faces connection closure on sending MetadataRequest Vn, where n is >=1, seeking supported protocol versions, it could be due to following reasons.
- Broker does not support version Vn of MetadataRequest. It is advised that client starts from V1 of metadata request and incrementally try above versions for connection closures.
- Connection closure was caused by issues other than unknown MetadataRequest version.
Public Interfaces
Changes to MetadataRequest and MetadataResponse
MetadataRequest and MetadataResponse v1 will be added.
Compatibility, Deprecation, and Migration Plan
- Updated clients that add support for new MetadataRequest will be able to adapt their functionality based on broker functionality.
Rejected Alternatives
- Include meta key-value tags in response ("broker.id=...", "message.max.bytes=...", ...)
- Include user-defined tags in response ("aws.zone=...", "rack=...", ..)
- Using a versionInt instead of ApiVersion's id as broker protocol version.
Use a new protocol request and response, ProtocolVersionRequest and ProtocolVersionResponse. A client may use this new API to query the broker for its supported protocol request types and versions and use the information to select a suitable set of conforming API requests and versions for further communication with the broker.
- Return array of supported versions, instead of min and max of supported versions, in MetadataResponse.