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.
| Version | Kafka | Changes |
|---|---|---|
| OffsetForLeaderEpochRequest | ||
| v2 | 2.2 | + CurrentLeaderEpoch int32adds the current leader epoch to support fencing. |
| v3 | 2.3 | + ReplicaId int32adds 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. |
| v4 | 2.8 | ~ Flexible encoding enabled FLEXIBLE enables flexible versions. |
| OffsetForLeaderEpochResponse | ||
| v2 | 2.2 | + ThrottleTimeMs int32added the throttle time. |
| v3 | 2.3 | is the same as version 2. |
| v4 | 2.8 | ~ Flexible encoding enabled FLEXIBLE enables flexible versions. |