# ERR 客户端：订阅者队列已满 - 丢弃消息

- **ID:** `redis/pubsub-subscriber-queue-full`
- **领域:** redis
- **类别:** resource_error
- **错误码:** `ERM`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

发布/订阅订阅者客户端的输出缓冲区已满，导致 Redis 丢弃消息以防止客户端断开连接。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Redis 6.2.0 | active | — | — |
| Redis 7.0.0 | active | — | — |
| Redis 7.2.0 | active | — | — |

## 解决方案

1. ```
   Increase the client output buffer limit for Pub/Sub clients: CONFIG SET client-output-buffer-limit pubsub 32mb 8mb 60. This provides more headroom for message bursts.
   ```
2. ```
   Implement backpressure in the subscriber: use a message queue (e.g., Redis list) to buffer messages asynchronously. Example in Python: import redis; r = redis.Redis(); pubsub = r.pubsub(); pubsub.subscribe('channel'); for msg in pubsub.listen(): r.rpush('buffer', msg['data'])
   ```
3. ```
   Add more subscriber instances to distribute the load: run multiple worker processes each subscribing to a subset of channels.
   ```

## 无效尝试

- **** — Setting an unlimited buffer can cause Redis to run out of memory, leading to OOM kills or performance degradation. (85% 失败率)
- **** — Disabling processing does not address the queue full issue; the client will still fail to consume messages fast enough. (60% 失败率)
- **** — A single subscriber handling many channels increases message volume per client, worsening the queue full condition. (70% 失败率)
