{
  "id": "database/redis-bgsave-fork-error",
  "signature": "Can't save in background: fork: Cannot allocate memory",
  "signature_zh": "无法在后台保存：fork：无法分配内存",
  "regex": "Can't save in background: fork: Cannot allocate memory",
  "domain": "database",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "Redis 尝试执行 BGSAVE 或 BGREWRITEAOF 时，操作系统 fork() 系统调用失败，因为系统内存不足或 overcommit_memory 设置不当。",
  "root_cause_type": "generic",
  "root_cause_zh": "Redis 尝试执行 BGSAVE 或 BGREWRITEAOF 时，操作系统 fork() 系统调用失败，因为系统内存不足或 overcommit_memory 设置不当。",
  "versions": [
    {
      "version": "Redis 6.2.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Redis 7.0.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Redis 7.2.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "增加 Redis 的 maxmemory 参数，但问题在于系统内存不足，而非 Redis 内存限制。",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "直接重启 Redis 服务，暂时释放内存但系统配置未改，问题会再次出现。",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "调整系统 overcommit_memory 参数：echo 1 > /proc/sys/vm/overcommit_memory，或永久设置：在 /etc/sysctl.conf 中添加 vm.overcommit_memory = 1。",
      "success_rate": 0.9,
      "how": "调整系统 overcommit_memory 参数：echo 1 > /proc/sys/vm/overcommit_memory，或永久设置：在 /etc/sysctl.conf 中添加 vm.overcommit_memory = 1。",
      "condition": "",
      "sources": []
    },
    {
      "action": "减少 Redis 内存使用或增加系统交换空间，确保有足够内存供 fork() 使用。",
      "success_rate": 0.75,
      "how": "减少 Redis 内存使用或增加系统交换空间，确保有足够内存供 fork() 使用。",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "调整系统 overcommit_memory 参数：echo 1 > /proc/sys/vm/overcommit_memory，或永久设置：在 /etc/sysctl.conf 中添加 vm.overcommit_memory = 1。",
    "减少 Redis 内存使用或增加系统交换空间，确保有足够内存供 fork() 使用。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://redis.io/docs/latest/operate/oss_and_stack/management/admin/#background-save",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-01-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}