{
  "id": "go/goroutine-mutex-lock-deadlock",
  "signature": "fatal error: all goroutines are asleep - deadlock! (sync.Mutex lock ordering)",
  "signature_zh": "致命错误：所有goroutine都处于睡眠状态 - 死锁！（sync.Mutex锁顺序）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(sync\\.Mutex\\ lock\\ ordering\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Two or more goroutines hold mutexes and wait for each other to release, creating a circular dependency.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个或多个goroutine持有互斥锁并等待对方释放，形成循环依赖。",
  "versions": [
    {
      "version": "1.18",
      "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"
    },
    {
      "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"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using sync.RWMutex instead of Mutex",
      "why_fails": "Does not fix lock ordering issue.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding sleep to break deadlock",
      "why_fails": "Sleep does not resolve logical cycle.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Always acquire locks in a consistent global order",
      "success_rate": 0.95,
      "how": "// Lock mu1 then mu2; goroutine1: mu1.Lock(); mu2.Lock(); goroutine2: mu1.Lock(); mu2.Lock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use try-lock pattern with channels",
      "success_rate": 0.8,
      "how": "select { case <-mu: default: // avoid deadlock }",
      "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-09-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}