{
  "id": "go/too-many-files-open-in-docker",
  "signature": "accept tcp [::1]:8080: accept4: too many open files in system",
  "signature_zh": "accept tcp [::1]:8080: accept4: 系统中打开的文件过多",
  "regex": "accept tcp .+: accept\\d?: too many open files in system",
  "domain": "go",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "The system-wide file descriptor limit or per-process limit has been exceeded, often due to leaked file handles or high concurrency in a Go server.",
  "root_cause_type": "generic",
  "root_cause_zh": "系统范围的文件描述符限制或进程限制已被超出，通常由于 Go 服务器中的文件句柄泄漏或高并发导致。",
  "versions": [
    {
      "version": "Go 1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Temporary fix; the error will reoccur once file descriptors accumulate again.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "May not affect system-wide limits; also does not address the root cause of file descriptor leaks.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If close() fails silently, file descriptors may still leak.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase system-wide file descriptor limit: edit /etc/sysctl.conf with 'fs.file-max = 100000' and apply with sysctl -p.",
      "success_rate": 0.75,
      "how": "Increase system-wide file descriptor limit: edit /etc/sysctl.conf with 'fs.file-max = 100000' and apply with sysctl -p.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check for leaked file handles using lsof -p <pid> and ensure all resources (http.Response.Body, os.File) are properly closed in all code paths, using defer for cleanup.",
      "success_rate": 0.85,
      "how": "Check for leaked file handles using lsof -p <pid> and ensure all resources (http.Response.Body, os.File) are properly closed in all code paths, using defer for cleanup.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a connection pool with limits (e.g., http.Transport.MaxIdleConnsPerHost) to prevent excessive file descriptor usage.",
      "success_rate": 0.8,
      "how": "Use a connection pool with limits (e.g., http.Transport.MaxIdleConnsPerHost) to prevent excessive file descriptor usage.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase system-wide file descriptor limit: edit /etc/sysctl.conf with 'fs.file-max = 100000' and apply with sysctl -p.",
    "Check for leaked file handles using lsof -p <pid> and ensure all resources (http.Response.Body, os.File) are properly closed in all code paths, using defer for cleanup.",
    "Use a connection pool with limits (e.g., http.Transport.MaxIdleConnsPerHost) to prevent excessive file descriptor usage."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://go.dev/doc/effective_go#leaks",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-01-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}