OffsetForLeaderEpoch
This page encodes the smallest legal instance of the request and the response: numeric fields are zero, strings and byte arrays are empty, every array carries exactly one sample element, and any records field holds one empty 61-byte RecordBatch v2. Version 4 is a flexible version, so every struct is terminated by a uvarint tagged-field count and strings and arrays carry compact length-plus-one prefixes. Sizes below include the leading int32 size prefix.
- API key
- 23
- Encoded at
- v4
- Flexible versions
- 4+
- Headers
- req v2, resp v1
- Request versions
- 2-4
- Response versions
- 2-4
- Request size
- 37 bytes
- Response size
- 37 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields
Request
OffsetForLeaderEpochRequest v4, request header v2, 37 bytes on the wire
byte layout (37 bytes, 16 bytes per row)
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020
object tree
OffsetForLeaderEpochRequest message v4 [0x0000, 37B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 33 [0x0000, 4B] number of bytes that follow, patched after encoding +-- RequestHeader v2 [0x0004, 11B] common request header | +-- request_api_key int16 = 23 (OffsetForLeaderEpoch) [0x0004, 2B] numeric id of the API being invoked | +-- request_api_version int16 = 4 [0x0006, 2B] version of the API being invoked | +-- correlation_id int32 = 0 [0x0008, 4B] echoed back by the broker in the response | +-- client_id nullable_string = "" (int16 len=0) [0x000c, 2B] always a non-flexible int16-prefixed string | +-- tagged_fields uvarint = 0 [0x000e, 1B] number of tagged fields in the header +-- OffsetForLeaderEpochRequest struct [0x000f, 22B] message body, version 4 +-- ReplicaId int32 = 0 [0x000f, 4B] The broker ID of the follower, of -1 if this request is from a consumer. +-- Topics []OffsetForLeaderTopic = 1 element [0x0013, 17B] Each topic to get offsets for. | +-- length uvarint = 2 (compact, n+1) [0x0013, 1B] one sample element follows | +-- OffsetForLeaderTopic[0] OffsetForLeaderTopic = struct [0x0014, 16B] | +-- Topic string = "" (compact, len+1=1) [0x0014, 1B] The topic name. | +-- Partitions []OffsetForLeaderPartition = 1 element [0x0015, 14B] Each partition to get offsets for. | | +-- length uvarint = 2 (compact, n+1) [0x0015, 1B] one sample element follows | | +-- OffsetForLeaderPartition[0] OffsetForLeaderPartition = struct [0x0016, 13B] | | +-- Partition int32 = 0 [0x0016, 4B] The partition index. | | +-- CurrentLeaderEpoch int32 = 0 [0x001a, 4B] An epoch used to fence consumers/replicas with old metadata. If the epoch p... | | +-- LeaderEpoch int32 = 0 [0x001e, 4B] The epoch to look up an offset for. | | +-- tagged_fields uvarint = 0 [0x0022, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x0023, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x0024, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 23, "type": "request", "listeners": ["broker"], "name": "OffsetForLeaderEpochRequest", // Versions 0-1 were removed in Apache Kafka 4.0, Version 2 is the new baseline. // // Version 1 is the same as version 0. // // Version 2 adds the current leader epoch to support fencing. // // Version 3 adds ReplicaId (the default is -2 which conventionally represents a // "debug" consumer which is allowed to see offsets beyond the high watermark). // Followers will use this replicaId when using an older version of the protocol. // // Version 4 enables flexible versions. "validVersions": "2-4", "flexibleVersions": "4+", "fields": [ { "name": "ReplicaId", "type": "int32", "versions": "3+", "default": -2, "ignorable": true, "entityType": "brokerId", "about": "The broker ID of the follower, of -1 if this request is from a consumer." }, { "name": "Topics", "type": "[]OffsetForLeaderTopic", "versions": "0+", "about": "Each topic to get offsets for.", "fields": [ { "name": "Topic", "type": "string", "versions": "0+", "entityType": "topicName", "mapKey": true, "about": "The topic name." }, { "name": "Partitions", "type": "[]OffsetForLeaderPartition", "versions": "0+", "about": "Each partition to get offsets for.", "fields": [ { "name": "Partition", "type": "int32", "versions": "0+", "about": "The partition index." }, { "name": "CurrentLeaderEpoch", "type": "int32", "versions": "2+", "default": "-1", "ignorable": true, "about": "An epoch used to fence consumers/replicas with old metadata. If the epoch provided by the client is larger than the current epoch known to the broker, then the UNKNOWN_LEADER_EPOCH error code will be returned. If the provided epoch is smaller, then the FENCED_LEADER_EPOCH error code will be returned." }, { "name": "LeaderEpoch", "type": "int32", "versions": "0+", "about": "The epoch to look up an offset for." } ]} ]} ] }
Response
OffsetForLeaderEpochResponse v4, response header v1, 37 bytes on the wire
byte layout (37 bytes, 16 bytes per row)
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020
object tree
OffsetForLeaderEpochResponse message v4 [0x0000, 37B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 33 [0x0000, 4B] number of bytes that follow, patched after encoding +-- ResponseHeader v1 [0x0004, 5B] common response header | +-- correlation_id int32 = 0 [0x0004, 4B] matches the correlation_id of the request | +-- tagged_fields uvarint = 0 [0x0008, 1B] number of tagged fields in the header +-- OffsetForLeaderEpochResponse struct [0x0009, 28B] message body, version 4 +-- ThrottleTimeMs int32 = 0 [0x0009, 4B] The duration in milliseconds for which the request was throttled due to a q... +-- Topics []OffsetForLeaderTopicResult = 1 element [0x000d, 23B] Each topic we fetched offsets for. | +-- length uvarint = 2 (compact, n+1) [0x000d, 1B] one sample element follows | +-- OffsetForLeaderTopicResult[0] OffsetForLeaderTopicResult = struct [0x000e, 22B] | +-- Topic string = "" (compact, len+1=1) [0x000e, 1B] The topic name. | +-- Partitions []EpochEndOffset = 1 element [0x000f, 20B] Each partition in the topic we fetched offsets for. | | +-- length uvarint = 2 (compact, n+1) [0x000f, 1B] one sample element follows | | +-- EpochEndOffset[0] EpochEndOffset = struct [0x0010, 19B] | | +-- ErrorCode int16 = 0 [0x0010, 2B] The error code 0, or if there was no error. | | +-- Partition int32 = 0 [0x0012, 4B] The partition index. | | +-- LeaderEpoch int32 = 0 [0x0016, 4B] The leader epoch of the partition. | | +-- EndOffset int64 = 0 [0x001a, 8B] The end offset of the epoch. | | +-- tagged_fields uvarint = 0 [0x0022, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x0023, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x0024, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 23, "type": "response", "name": "OffsetForLeaderEpochResponse", // Versions 0-1 were removed in Apache Kafka 4.0, Version 2 is the new baseline. // // Version 1 added the leader epoch to the response. // // Version 2 added the throttle time. // // Version 3 is the same as version 2. // // Version 4 enables flexible versions. "validVersions": "2-4", "flexibleVersions": "4+", "fields": [ { "name": "ThrottleTimeMs", "type": "int32", "versions": "2+", "ignorable": true, "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." }, { "name": "Topics", "type": "[]OffsetForLeaderTopicResult", "versions": "0+", "about": "Each topic we fetched offsets for.", "fields": [ { "name": "Topic", "type": "string", "versions": "0+", "entityType": "topicName", "mapKey": true, "about": "The topic name." }, { "name": "Partitions", "type": "[]EpochEndOffset", "versions": "0+", "about": "Each partition in the topic we fetched offsets for.", "fields": [ { "name": "ErrorCode", "type": "int16", "versions": "0+", "about": "The error code 0, or if there was no error." }, { "name": "Partition", "type": "int32", "versions": "0+", "about": "The partition index." }, { "name": "LeaderEpoch", "type": "int32", "versions": "1+", "default": "-1", "ignorable": true, "about": "The leader epoch of the partition." }, { "name": "EndOffset", "type": "int64", "versions": "0+", "default": "-1", "about": "The end offset of the epoch." } ]} ]} ] }