conduktor.io ↗

Kafka OffsetForLeaderEpoch Response Wire Format v4 — Binary Protocol Layout

What is OffsetForLeaderEpoch?

Follower replicas call this after a leader failover to determine the divergence point and truncate their local log to match the new leader. Without it, a follower might replay entries the new leader doesn't have, causing data inconsistency across leader elections.

Related Errors

TOPIC_AUTHORIZATION_FAILED · UNKNOWN_LEADER_EPOCH

Wire Diagram

Response Header · flexible
message_size int32 · 4B
correlation_id int32 · 4B
tagged var
OffsetForLeaderEpochResponse v4
ThrottleTimeMs int32 · 4B
Topics array
tagged var
Topic string (compact)
Partitions array
tagged var
ErrorCode int16 · 2B
Partition int32 · 4B
LeaderEpoch int32 · 4B
EndOffset int64 · 8B
tagged var

Schema & Example

Schema
{
  "ThrottleTimeMs": int32,
  "Topics": [{
      "Topic": string,
      "Partitions": [{
          "ErrorCode": int16,
          "Partition": int32,
          "LeaderEpoch": int32,
          "EndOffset": int64
      }]
  }]
}
Example
{
  "ThrottleTimeMs": 0,
  "Topics": [{
      "Topic": "orders",
      "Partitions": [{
          "ErrorCode": 0,
          "Partition": 0,
          "LeaderEpoch": 17,
          "EndOffset": 150382
      }]
  }]
}