{
  "id": "kafka/leader-epoch-stale",
  "signature": "org.apache.kafka.common.errors.LeaderEpochStaleException: The leader epoch in the request is older than the current leader epoch",
  "signature_zh": "org.apache.kafka.common.errors.LeaderEpochStaleException: 请求中的领导纪元比当前领导纪元旧",
  "regex": "org\\.apache\\.kafka\\.common\\.errors\\.LeaderEpochStaleException: The leader epoch in the request is older than the current leader epoch",
  "domain": "kafka",
  "category": "protocol_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "跟随者或客户端发送了带有过时领导纪元的请求，表明它尚未了解最近的领导选举，导致代理拒绝该请求。",
  "versions": [
    {
      "version": "Kafka 2.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kafka 3.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kafka 3.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kafka 3.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Restart the follower broker that sent the stale request",
      "why_fails": "Restarting may reset the follower's state, but the underlying replication lag or network issue causing the stale epoch will persist.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase the replica.fetch.wait.max.ms on the follower",
      "why_fails": "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.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure followers can quickly learn about leader changes by reducing the metadata.max.age.ms on the broker:\n\nmetadata.max.age.ms=5000  # 5 seconds\n\nAlso check that network connectivity between followers and the controller is stable; monitor controller election logs.",
      "success_rate": 0.8,
      "how": "Ensure followers can quickly learn about leader changes by reducing the metadata.max.age.ms on the broker:\n\nmetadata.max.age.ms=5000  # 5 seconds\n\nAlso check that network connectivity between followers and the controller is stable; monitor controller election logs.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the issue is persistent, manually trigger a preferred leader election to stabilize the leader epoch:\n\nkafka-leader-election --bootstrap-server localhost:9092 --election-type preferred --partition 0 --topic my_topic\n\nThis forces all replicas to acknowledge the current leader.",
      "success_rate": 0.75,
      "how": "If the issue is persistent, manually trigger a preferred leader election to stabilize the leader epoch:\n\nkafka-leader-election --bootstrap-server localhost:9092 --election-type preferred --partition 0 --topic my_topic\n\nThis forces all replicas to acknowledge the current leader.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure followers can quickly learn about leader changes by reducing the metadata.max.age.ms on the broker:\n\nmetadata.max.age.ms=5000  # 5 seconds\n\nAlso 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:\n\nkafka-leader-election --bootstrap-server localhost:9092 --election-type preferred --partition 0 --topic my_topic\n\nThis forces all replicas to acknowledge the current leader."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://kafka.apache.org/documentation/#replication_config",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2023-04-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}