{
  "id": "go/database-sql-conn-already-in-use",
  "signature": "sql: connection is already in use",
  "signature_zh": "sql: 连接已被使用",
  "regex": "sql:\\ connection\\ is\\ already\\ in\\ use",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A database connection was returned to the pool while still being used by another goroutine, causing a race condition.",
  "root_cause_type": "generic",
  "root_cause_zh": "数据库连接在仍被其他 goroutine 使用时被返回到池中，导致竞争条件。",
  "versions": [
    {
      "version": "1.16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "May cause data corruption or panics due to concurrent access.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Doesn't fix the root cause; may delay the issue but not prevent it.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ensure each query uses its own connection properly: use db.QueryContext with a context and avoid sharing rows between goroutines.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.75,
      "how": "Use a mutex to serialize access to rows: var mu sync.Mutex; mu.Lock(); defer mu.Unlock(); rows.Scan(...)",
      "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.8,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}