{
  "id": "go/database-sql-connection-bad-connection",
  "signature": "error: sql: database is closed",
  "signature_zh": "错误：sql：数据库已关闭",
  "regex": "error:\\ sql:\\ database\\ is\\ closed",
  "domain": "go",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "Attempting to use a database connection after the database has been closed, typically due to calling db.Close() prematurely.",
  "root_cause_type": "generic",
  "root_cause_zh": "在数据库关闭后尝试使用数据库连接，通常由于过早调用db.Close()。",
  "versions": [
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reopening database for each query",
      "why_fails": "Inefficient; use connection pool and defer close at application shutdown.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a single db instance and close only when shutting down",
      "success_rate": 0.95,
      "how": "db, err := sql.Open(\"driver\", dsn)\nif err != nil { log.Fatal(err) }\ndefer db.Close()\n// use db for all queries",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2026-06-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}