{
  "id": "kafka/consumer-fetch-thread-interrupted-during-rebalance",
  "signature": "org.apache.kafka.common.errors.InterruptException: Consumer fetch thread interrupted during rebalance",
  "signature_zh": "org.apache.kafka.common.errors.InterruptException：消费者拉取线程在重平衡期间被中断",
  "regex": "InterruptException.*fetch thread interrupted.*rebalance",
  "domain": "kafka",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A consumer's background fetch thread was interrupted while the group was in a rebalance state, often due to thread pool shutdown or timeout in poll() loop.",
  "root_cause_type": "generic",
  "root_cause_zh": "消费者后台拉取线程在组处于重平衡状态时被中断，通常是由于线程池关闭或poll()循环超时。",
  "versions": [
    {
      "version": "Kafka 3.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kafka 3.6.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kafka 3.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Raising max.poll.interval.ms to 10 minutes",
      "why_fails": "Increasing max.poll.interval.ms gives more time but doesn't address the thread interruption source.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Restarting the consumer application",
      "why_fails": "Restarting the consumer without fixing the thread pool management just re-triggers the same interruption.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a dedicated thread pool for consumer operations and ensure graceful shutdown with consumer.wakeup() before interrupting threads. Example: ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(() -> { try { while (true) { consumer.poll(Duration.ofMillis(100)); } } catch (WakeupException e) { consumer.close(); } });",
      "success_rate": 0.92,
      "how": "Use a dedicated thread pool for consumer operations and ensure graceful shutdown with consumer.wakeup() before interrupting threads. Example: ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(() -> { try { while (true) { consumer.poll(Duration.ofMillis(100)); } } catch (WakeupException e) { consumer.close(); } });",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set session.timeout.ms and max.poll.interval.ms to values that give the consumer enough time to complete processing before rebalance interrupts.",
      "success_rate": 0.75,
      "how": "Set session.timeout.ms and max.poll.interval.ms to values that give the consumer enough time to complete processing before rebalance interrupts.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use a dedicated thread pool for consumer operations and ensure graceful shutdown with consumer.wakeup() before interrupting threads. Example: ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(() -> { try { while (true) { consumer.poll(Duration.ofMillis(100)); } } catch (WakeupException e) { consumer.close(); } });",
    "Set session.timeout.ms and max.poll.interval.ms to values that give the consumer enough time to complete processing before rebalance interrupts."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://kafka.apache.org/documentation/#consumerconfigs_max.poll.interval.ms",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2024-05-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}