# 错误：流条目已添加到消费者组待处理条目列表但未确认

- **ID:** `redis/stream-entries-added-to-consumer-group-pel`
- **领域:** redis
- **类别:** data_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

消费者组待处理条目列表(PEL)因消费者未能确认已处理的消息而无限制增长，可能导致内存耗尽和性能下降。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| redis 6.2 | active | — | — |
| redis 7.0 | active | — | — |
| redis 7.2 | active | — | — |

## 解决方案

1. ```
   Periodically acknowledge processed entries using XACK: `XACK mystream mygroup 1526569498055-0` for each message ID. Automate with a background job that calls XACK after successful processing.
   ```
2. ```
   Set a consumer group PEL size limit with `XGROUP SETID mystream mygroup $` and use XTRIM to cap stream length: `XTRIM mystream MAXLEN ~ 10000`.
   ```
3. ```
   Use XAUTOCLAIM to reassign idle PEL entries to other consumers: `XAUTOCLAIM mystream mygroup consumer2 3600000 0-0` after setting a reasonable idle timeout.
   ```

## 无效尝试

- **Increasing consumer group size to handle more messages** — Adding more consumers does not clear the PEL; each consumer still accumulates unacknowledged entries, worsening the issue. (85% 失败率)
- **Deleting and recreating the stream** — Deletes all data and disrupts active consumers; PEL rebuilds quickly if root cause (lack of acknowledgment) persists. (90% 失败率)
- **Setting XREADGROUP COUNT to a very high value** — High COUNT does not clear PEL; it only returns more entries, and unacknowledged entries remain, continuing to grow the PEL. (80% 失败率)
