{
  "id": "redis/err-bgsave-failed-disk",
  "signature": "Error: BGSAVE failed because fork failed: Cannot allocate memory",
  "signature_zh": "错误：BGSAVE 失败，因为 fork 失败：无法分配内存",
  "regex": "BGSAVE failed because fork failed: Cannot allocate memory",
  "domain": "redis",
  "category": "resource_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "Redis 服务器尝试 fork 子进程以执行 BGSAVE 失败，原因是系统内存不足，通常是由于内存过提交设置或高内存使用率。",
  "versions": [
    {
      "version": "Redis 6.2.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Redis 7.0.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Linux kernel 5.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Linux kernel 6.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The fork failure is at the OS level, not Redis config.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Swap can provide a buffer; disabling it may cause immediate OOM kills.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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`.",
      "success_rate": 0.9,
      "how": "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`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce Redis memory usage by setting a lower `maxmemory` value or evicting keys with `maxmemory-policy allkeys-lru`. Restart Redis after changes.",
      "success_rate": 0.75,
      "how": "Reduce Redis memory usage by setting a lower `maxmemory` value or evicting keys with `maxmemory-policy allkeys-lru`. Restart Redis after changes.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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`.",
      "success_rate": 0.8,
      "how": "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`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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`."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}