{
  "id": "go/sql-too-many-open-connections",
  "signature": "sql: connection pool exhausted: too many open connections (max_open_conns=10)",
  "signature_zh": "sql：连接池耗尽：打开连接过多（max_open_conns=10）",
  "regex": "sql:\\ connection\\ pool\\ exhausted:\\ too\\ many\\ open\\ connections\\ \\(max_open_conns=10\\)",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Handlers acquire connections but never Close rows or return them, or MaxOpenConns is set too low for concurrency. Leaked *sql.Rows exhaust the pool.",
  "root_cause_type": "generic",
  "root_cause_zh": "处理程序获取连接后未 Close rows 或归还连接，或 MaxOpenConns 对并发量设置过低。未关闭的 *sql.Rows 会耗尽连接池。",
  "versions": [
    {
      "version": "1.18",
      "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": "",
      "why_fails": "Hides the leak and can exhaust the database server's connection limit.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Does not release leaked connections; just delays the failure.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "rows, err := db.QueryContext(ctx, q)\nif err != nil { return err }\ndefer rows.Close()\nfor rows.Next() { ... }\nreturn rows.Err()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "db.SetMaxOpenConns(50)\ndb.SetMaxIdleConns(25)\ndb.SetConnMaxLifetime(5*time.Minute)",
      "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": "2024-02-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}