{
  "id": "python/sqlalchemy-connection-pool-recycle",
  "signature": "sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) SSL connection has been closed unexpectedly",
  "signature_zh": "sqlalchemy.exc.OperationalError：(psycopg2.OperationalError) SSL 连接意外关闭",
  "regex": "sqlalchemy\\.exc\\.OperationalError:\\ \\(psycopg2\\.OperationalError\\)\\ SSL\\ connection\\ has\\ been\\ closed\\ unexpectedly",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "Database server closed idle connections due to timeout; pool still holds stale connections.",
  "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": "Disabling SSL entirely.",
      "why_fails": "Security risk; may not be allowed by policy.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increasing pool_timeout.",
      "why_fails": "Does not refresh stale connections.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set pool_recycle to a value less than server idle timeout.",
      "success_rate": 0.95,
      "how": "engine = create_engine(url, pool_recycle=3600)  # Recycle connections every hour",
      "condition": "",
      "sources": []
    },
    {
      "action": "Enable pool_pre_ping to check connection health.",
      "success_rate": 0.9,
      "how": "engine = create_engine(url, pool_pre_ping=True)",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-09-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}