{
  "id": "go/deadlock-rwmutex-reader-writer",
  "signature": "fatal error: all goroutines are asleep - deadlock! (RWMutex reader waiting on writer)",
  "signature_zh": "fatal error: 所有 goroutine 已休眠 - 死锁！（RWMutex 读等待写）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(RWMutex\\ reader\\ waiting\\ on\\ writer\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A reader holds RLock and tries to acquire Lock, or a recursive RLock blocks because a pending writer is queued.",
  "root_cause_type": "generic",
  "root_cause_zh": "读持有 RLock 后试图获取写锁 Lock，或者递归 RLock 因已有写者排队而阻塞。",
  "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"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Eliminates read concurrency but the nested-lock logic still deadlocks under the same call path.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The pending writer still blocks new readers; sleep merely reorders the deadlock.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Never upgrade RLock to Lock; release the read lock before acquiring the write lock:\n\nmu.RUnlock()\nmu.Lock()\ndefer mu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Use a copy-on-write pattern with atomic.Pointer to avoid nested locks entirely.",
      "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-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}