{
  "id": "python/sqlalchemy-operational-error-server-closed-connection",
  "signature": "sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.",
  "signature_zh": "服务器意外关闭了连接，这可能意味着服务器在处理请求之前或期间异常终止。",
  "regex": "sqlalchemy\\.exc\\.OperationalError:\\ \\(psycopg2\\.OperationalError\\)\\ server\\ closed\\ the\\ connection\\ unexpectedly\\ This\\ probably\\ means\\ the\\ server\\ terminated\\ abnormally\\ before\\ or\\ while\\ processing\\ the\\ request\\.",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The database server closed the connection due to timeout, crash, or network issue, often when a long-running query or idle connection exceeds server limits.",
  "root_cause_type": "generic",
  "root_cause_zh": "数据库服务器因超时、崩溃或网络问题关闭了连接，通常发生在长时间运行的查询或空闲连接超过服务器限制时。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Retrying the query without pool reset",
      "why_fails": "",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increasing client-side timeout only",
      "why_fails": "",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Enable connection pool pre-ping",
      "success_rate": 0.85,
      "how": "Configure SQLAlchemy engine with pool_pre_ping=True to check connection health before use.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set pool_recycle parameter",
      "success_rate": 0.9,
      "how": "Set pool_recycle to a value less than the server's idle timeout (e.g., 3600 seconds) to recycle connections before they are dropped.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}