What is Metadata?
The first API every client calls after connecting, and re-called on NOT_LEADER or UNKNOWN_TOPIC_OR_PARTITION errors. A surge in Metadata requests signals partition leaders are moving around, typically during rolling restarts, broker failures, or reassignments.
| Version | Kafka | Changes |
|---|---|---|
| MetadataRequest | ||
| v0 | 2.2 | + Topics []MetadataRequestTopic+ Name string |
| v1 | 2.2 | ~ Topics became nullable |
| v2 | 2.2 | are the same as version 1. |
| v3 | 2.2 | are the same as version 1. |
| v4 | 2.2 | + AllowAutoTopicCreation booladds AllowAutoTopicCreation. |
| v5 | 2.2 | No changes |
| v6 | 2.2 | No changes |
| v7 | 2.2 | No changes |
| v8 | 2.3 | + IncludeClusterAuthorizedOperations bool+ IncludeTopicAuthorizedOperations boolauthorized operations can be requested for cluster and topic resource. |
| v9 | 2.4 | ~ Flexible encoding enabled FLEXIBLE is the first flexible version. |
| v10 | 2.8 | + TopicId uuid~ Name became nullableshould not use the topicId field or set topic name to null. |
| v11 | 2.8 | - IncludeClusterAuthorizedOperations booldeprecates IncludeClusterAuthorizedOperations field. This is now exposed by the DescribeCluster API (KIP-700). |
| v12 | 3.1 | supports topic Id. |
| v13 | 4.0 | supports top-level error code in the response. |
| MetadataResponse | ||
| v0 | 2.2 | + Brokers []MetadataResponseBroker+ NodeId int32+ Host string+ Port int32+ Topics []MetadataResponseTopic+ ErrorCode int16+ Name string+ Partitions []MetadataResponsePartition+ ErrorCode int16+ PartitionIndex int32+ LeaderId int32+ ReplicaNodes []int32+ IsrNodes []int32 |
| v1 | 2.2 | + Rack string+ ControllerId int32+ IsInternal booladds fields for the rack of each broker, the controller id, and whether or not the topic is internal. |
| v2 | 2.2 | + ClusterId stringadds the cluster ID field. |
| v3 | 2.2 | + ThrottleTimeMs int32adds the throttle time. |
| v4 | 2.2 | is the same as version 3. |
| v5 | 2.2 | + OfflineReplicas []int32adds a per-partition offline_replicas field. This field specifies the list of replicas that are offline. |
| v6 | 2.2 | on quota violation, brokers send out responses before throttling. |
| v7 | 2.2 | + LeaderEpoch int32adds the leader epoch to the partition metadata. |
| v8 | 2.3 | + TopicAuthorizedOperations int32+ ClusterAuthorizedOperations int32brokers can send authorized operations for topic and cluster. |
| v9 | 2.4 | ~ Flexible encoding enabled FLEXIBLE is the first flexible version. |
| v10 | 2.8 | + TopicId uuidadds topicId. |
| v11 | 2.8 | - ClusterAuthorizedOperations int32deprecates ClusterAuthorizedOperations. This is now exposed by the DescribeCluster API (KIP-700). |
| v12 | 3.1 | ~ Name became nullablesupports topicId. |
| v13 | 4.0 | + ErrorCode int16supports top-level error code in the response. |