# org.apache.kafka.common.errors.InterruptException: Consumer fetch thread interrupted during rebalance

- **ID:** `kafka/consumer-fetch-thread-interrupted-during-rebalance`
- **Domain:** kafka
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 78%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Kafka 3.4.0 | active | — | — |
| Kafka 3.6.1 | active | — | — |
| Kafka 3.8.0 | active | — | — |

## Workarounds

1. **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(); } });** (92% success)
   ```
   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(); } });
   ```
2. **Set session.timeout.ms and max.poll.interval.ms to values that give the consumer enough time to complete processing before rebalance interrupts.** (75% success)
   ```
   Set session.timeout.ms and max.poll.interval.ms to values that give the consumer enough time to complete processing before rebalance interrupts.
   ```

## Dead Ends

- **Raising max.poll.interval.ms to 10 minutes** — Increasing max.poll.interval.ms gives more time but doesn't address the thread interruption source. (85% fail)
- **Restarting the consumer application** — Restarting the consumer without fixing the thread pool management just re-triggers the same interruption. (95% fail)
