kafka
protocol_error
ai_generated
true
org.apache.kafka.common.errors.LeaderEpochStaleException: The leader epoch in the request is older than the current leader epoch
ID: kafka/leader-epoch-stale
78%Fix Rate
83%Confidence
1Evidence
2023-04-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Kafka 2.8.0 | active | — | — | — |
| Kafka 3.0.0 | active | — | — | — |
| Kafka 3.4.0 | active | — | — | — |
| Kafka 3.6.0 | active | — | — | — |
Root Cause
A follower or client sent a request with a stale leader epoch, indicating it has not yet learned about a recent leader election, causing the broker to reject the request.
generic中文
跟随者或客户端发送了带有过时领导纪元的请求,表明它尚未了解最近的领导选举,导致代理拒绝该请求。
Official Documentation
https://kafka.apache.org/documentation/#replication_configWorkarounds
-
80% success Ensure followers can quickly learn about leader changes by reducing the metadata.max.age.ms on the broker: metadata.max.age.ms=5000 # 5 seconds Also check that network connectivity between followers and the controller is stable; monitor controller election logs.
Ensure followers can quickly learn about leader changes by reducing the metadata.max.age.ms on the broker: metadata.max.age.ms=5000 # 5 seconds Also check that network connectivity between followers and the controller is stable; monitor controller election logs.
-
75% success If the issue is persistent, manually trigger a preferred leader election to stabilize the leader epoch: kafka-leader-election --bootstrap-server localhost:9092 --election-type preferred --partition 0 --topic my_topic This forces all replicas to acknowledge the current leader.
If the issue is persistent, manually trigger a preferred leader election to stabilize the leader epoch: kafka-leader-election --bootstrap-server localhost:9092 --election-type preferred --partition 0 --topic my_topic This forces all replicas to acknowledge the current leader.
中文步骤
Ensure followers can quickly learn about leader changes by reducing the metadata.max.age.ms on the broker: metadata.max.age.ms=5000 # 5 seconds Also check that network connectivity between followers and the controller is stable; monitor controller election logs.
If the issue is persistent, manually trigger a preferred leader election to stabilize the leader epoch: kafka-leader-election --bootstrap-server localhost:9092 --election-type preferred --partition 0 --topic my_topic This forces all replicas to acknowledge the current leader.
Dead Ends
Common approaches that don't work:
-
Restart the follower broker that sent the stale request
75% fail
Restarting may reset the follower's state, but the underlying replication lag or network issue causing the stale epoch will persist.
-
Increase the replica.fetch.wait.max.ms on the follower
85% fail
This setting controls how long a follower waits for fetch responses, but does not update the leader epoch; the follower needs to actively learn the new epoch via metadata requests.