# 错误：客户端命令队列已满，断开连接

- **ID:** `redis/command-queue-full`
- **领域:** redis
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

客户端的命令缓冲区超过了客户端输出缓冲区限制，导致 Redis 断开连接以防止内存耗尽。

## 版本兼容性

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

## 解决方案

1. ```
   检查客户端的应用程序逻辑：使用管道或批处理减少每个连接发送的命令数量。例如：在 Python 中使用 redis-py 的 pipeline。
   ```
2. ```
   使用 CLIENT LIST 监控慢消费者，并考虑增加特定客户端类型的客户端输出缓冲区限制：CONFIG SET client-output-buffer-limit 'normal 0 0 0'（重置为默认值）。
   ```

## 无效尝试

- **Increase client-output-buffer-limit to a very high value (e.g., 1GB)** — May hide the underlying issue (e.g., slow consumer or large replies) and risk OOM on Redis server. (45% 失败率)
- **Restart Redis server to clear all client connections** — Temporary fix; the issue will recur if the client behavior isn't changed. (60% 失败率)
