redis
resource_error
ai_generated
true
Error: BGSAVE failed because fork failed: Cannot allocate memory
ID: redis/err-bgsave-failed-disk
80%Fix Rate
90%Confidence
1Evidence
2023-11-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Redis 6.2.8 | active | — | — | — |
| Redis 7.0.13 | active | — | — | — |
| Linux kernel 5.10 | active | — | — | — |
| Linux kernel 6.1 | active | — | — | — |
Root Cause
The Redis server's attempt to fork a child process for BGSAVE failed due to insufficient system memory, often because of overcommit memory settings or high memory usage.
generic中文
Redis 服务器尝试 fork 子进程以执行 BGSAVE 失败,原因是系统内存不足,通常是由于内存过提交设置或高内存使用率。
Official Documentation
https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/Workarounds
-
90% success Enable overcommit memory on the Linux host: `echo 1 > /proc/sys/vm/overcommit_memory` and make it persistent in /etc/sysctl.conf with `vm.overcommit_memory = 1`.
Enable overcommit memory on the Linux host: `echo 1 > /proc/sys/vm/overcommit_memory` and make it persistent in /etc/sysctl.conf with `vm.overcommit_memory = 1`.
-
75% success Reduce Redis memory usage by setting a lower `maxmemory` value or evicting keys with `maxmemory-policy allkeys-lru`. Restart Redis after changes.
Reduce Redis memory usage by setting a lower `maxmemory` value or evicting keys with `maxmemory-policy allkeys-lru`. Restart Redis after changes.
-
80% success Use a smaller fork-friendly configuration: set `repl-diskless-sync yes` to avoid fork during replication, or switch to AOF with `appendonly yes` and `no-appendfsync-on-rewrite yes`.
Use a smaller fork-friendly configuration: set `repl-diskless-sync yes` to avoid fork during replication, or switch to AOF with `appendonly yes` and `no-appendfsync-on-rewrite yes`.
中文步骤
Enable overcommit memory on the Linux host: `echo 1 > /proc/sys/vm/overcommit_memory` and make it persistent in /etc/sysctl.conf with `vm.overcommit_memory = 1`.
Reduce Redis memory usage by setting a lower `maxmemory` value or evicting keys with `maxmemory-policy allkeys-lru`. Restart Redis after changes.
Use a smaller fork-friendly configuration: set `repl-diskless-sync yes` to avoid fork during replication, or switch to AOF with `appendonly yes` and `no-appendfsync-on-rewrite yes`.
Dead Ends
Common approaches that don't work:
-
95% fail
The fork failure is at the OS level, not Redis config.
-
70% fail
Swap can provide a buffer; disabling it may cause immediate OOM kills.