{
  "id": "python/flask-sqlalchemy-operational-error-mysql-gone-away",
  "signature": "sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2006, 'MySQL server has gone away')",
  "signature_zh": "sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2006, 'MySQL 服务器已断开')",
  "regex": "sqlalchemy\\.exc\\.OperationalError:\\ \\(pymysql\\.err\\.OperationalError\\)\\ \\(2006,\\ 'MySQL\\ server\\ has\\ gone\\ away'\\)",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "Idle connections in the SQLAlchemy pool timed out server-side; pool_recycle not configured and pool_pre_ping off.",
  "root_cause_type": "generic",
  "root_cause_zh": "SQLAlchemy 连接池中的空闲连接在服务端超时；未配置 pool_recycle 且 pool_pre_ping 关闭。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Only delays the problem; bad connections still get reused.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disables pooling; performance collapses under load.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {'pool_pre_ping': True, 'pool_recycle': 280}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "In create_engine: create_engine(url, pool_pre_ping=True, pool_recycle=280)",
      "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": "2024-09-26",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}