{
  "id": "go/deadlock-two-mutexes",
  "signature": "fatal error: all goroutines are asleep - deadlock! (mutex lock ordering)",
  "signature_zh": "fatal error: 所有 goroutine 都在休眠 - 死锁！（互斥锁加锁顺序）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(mutex\\ lock\\ ordering\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Two goroutines acquire mutexes A and B in opposite orders, each waiting for the other's lock.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个 goroutine 以相反顺序获取互斥锁 A 和 B，各自等待对方持有的锁。",
  "versions": [
    {
      "version": "1.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Busy retry burns CPU and does not guarantee progress; can still livelock.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Serializes everything, destroying concurrency, and may still deadlock with other lock paths.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "// always lock A then B\nmuA.Lock()\ndefer muA.Unlock()\nmuB.Lock()\ndefer muB.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "var mu sync.Mutex\nmu.Lock()\ndefer mu.Unlock()\n// access both A and B",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}