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.
Wire Diagram
Response Header
message_size
int32 · 4B
correlation_id
int32 · 4B
OffsetForLeaderEpochResponse v2
ThrottleTimeMs
int32 · 4B
Topic
string
ErrorCode
int16 · 2B
Partition
int32 · 4B
LeaderEpoch
int32 · 4B
EndOffset
int64 · 8B
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 }] }] }