{
  "id": "python/mysql-connection-reset",
  "signature": "sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')",
  "signature_zh": "SQLAlchemy 操作错误：查询期间丢失与 MySQL 服务器的连接。",
  "regex": "sqlalchemy\\.exc\\.OperationalError:\\ \\(pymysql\\.err\\.OperationalError\\)\\ \\(2013,\\ 'Lost\\ connection\\ to\\ MySQL\\ server\\ during\\ query'\\)",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "MySQL 服务器关闭了连接，可能是由于超时、服务器重启或网络问题。",
  "root_cause_type": "generic",
  "root_cause_zh": "MySQL 服务器关闭了连接，可能是由于超时、服务器重启或网络问题。",
  "versions": [
    {
      "version": "1.4.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "增加 MySQL 的 wait_timeout，但需要重启服务器且影响所有连接。",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "在应用层无限重试，但可能造成资源浪费和死循环。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "使用 SQLAlchemy 的 pool_pre_ping=True 参数，自动检测并重建死连接。",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "设置连接池回收时间：pool_recycle=3600",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-10-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}