database
resource_error
ai_generated
true
redis.exceptions.ResponseError:-OOM 命令不允许,当已用内存超过 'maxmemory' 时。
redis.exceptions.ResponseError: -OOM command not allowed when used memory > 'maxmemory'.
ID: database/redis-maxmemory-policy-eviction-blocked
85%修复率
90%置信度
1证据数
2023-11-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Redis 6.2 | active | — | — | — |
| Redis 7.0 | active | — | — | — |
| Redis 7.2 | active | — | — | — |
根因分析
Redis 已达到 maxmemory 限制,并且配置的逐出策略 (maxmemory-policy) 无法释放足够的空间,或者策略设置为 'noeviction',导致写命令被拒绝。
English
Redis has reached its maxmemory limit and the configured eviction policy (maxmemory-policy) cannot free enough space, or the policy is set to 'noeviction', causing write commands to be rejected.
官方文档
https://redis.io/docs/latest/operate/oss_and_stack/management/admin/#maxmemory解决方案
-
Set an appropriate eviction policy: CONFIG SET maxmemory-policy allkeys-lru (or volatile-lru, allkeys-lfu, etc.) via redis-cli. Then verify with CONFIG GET maxmemory-policy.
-
Increase maxmemory if feasible: CONFIG SET maxmemory 2gb (or edit redis.conf and restart). Also monitor memory usage with INFO memory to ensure the new limit is sufficient.
无效尝试
常见但无效的做法:
-
Increase maxmemory without addressing the eviction policy or data growth pattern
80% 失败
Memory will eventually fill up again if the root cause (e.g., unbounded cache growth, no eviction) is not fixed.
-
Flush all keys using FLUSHALL or FLUSHDB without restarting or changing config
70% 失败
While this temporarily frees memory, the same pattern of writes will cause the error to recur unless the eviction policy is adjusted.