# org.apache.kafka.common.errors.InvalidPartitionCountException：静态组成员的分区计数0无效

- **ID:** `kafka/invalid-partition-count-on-static-membership`
- **领域:** kafka
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

静态消费者组成员资格需要至少一个分区分配；计数为零表示分配策略配置错误或未初始化。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Kafka 3.5.0 | active | — | — |
| Kafka 3.6.0 | active | — | — |
| Kafka 3.7.0 | active | — | — |

## 解决方案

1. ```
   Ensure the consumer subscribes to at least one topic with partitions before joining the group. Example: consumer.subscribe(Pattern.compile("my-topic-.*"));
   ```
2. ```
   Set partition.assignment.strategy to a non-empty strategy like 'org.apache.kafka.clients.consumer.RangeAssignor' explicitly in consumer config.
   ```

## 无效尝试

- **Tuning consumer max.poll.records to a higher value** — Increasing max.poll.records does not affect partition assignment count and only delays rebalance timeouts. (90% 失败率)
- **Deleting group.instance.id from consumer config** — Removing group.instance.id disables static membership but loses group rebalance stability benefits. (70% 失败率)
