{
  "id": "database/sqlite-busy-timeout-exceeded",
  "signature": "sqlite3.OperationalError: database is locked\n  (background: SQLite busy timeout of 5000ms exceeded)",
  "signature_zh": "sqlite3.OperationalError：数据库被锁定\n  （背景：SQLite忙超时5000毫秒已超过）",
  "regex": "database is locked.*busy timeout of \\d+ms exceeded",
  "domain": "database",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A write transaction is held by another connection for longer than the busy timeout, causing concurrent writes to fail.",
  "root_cause_type": "generic",
  "root_cause_zh": "另一个连接持有写事务的时间超过忙超时时间，导致并发写入失败。",
  "versions": [
    {
      "version": "SQLite 3.40",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "SQLite 3.41",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "SQLite 3.42",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Set PRAGMA busy_timeout to 0 to disable timeout",
      "why_fails": "Disabling timeout causes immediate failure on lock contention, making the problem worse instead of better.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use WAL mode but keep journal_mode=DELETE",
      "why_fails": "WAL mode improves concurrency for readers but does not eliminate write contention; the lock still exists.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set a higher busy timeout: PRAGMA busy_timeout = 30000; (30 seconds) to allow longer waits for locks.",
      "success_rate": 0.9,
      "how": "Set a higher busy timeout: PRAGMA busy_timeout = 30000; (30 seconds) to allow longer waits for locks.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Switch to WAL mode: PRAGMA journal_mode=WAL; This allows concurrent reads while a write is in progress.",
      "success_rate": 0.85,
      "how": "Switch to WAL mode: PRAGMA journal_mode=WAL; This allows concurrent reads while a write is in progress.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a connection pool with retry logic: from sqlite3 import connect; import time; for i in range(5): try: conn.execute(...); break; except sqlite3.OperationalError: time.sleep(1)",
      "success_rate": 0.8,
      "how": "Use a connection pool with retry logic: from sqlite3 import connect; import time; for i in range(5): try: conn.execute(...); break; except sqlite3.OperationalError: time.sleep(1)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Set a higher busy timeout: PRAGMA busy_timeout = 30000; (30 seconds) to allow longer waits for locks.",
    "Switch to WAL mode: PRAGMA journal_mode=WAL; This allows concurrent reads while a write is in progress.",
    "Use a connection pool with retry logic: from sqlite3 import connect; import time; for i in range(5): try: conn.execute(...); break; except sqlite3.OperationalError: time.sleep(1)"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.sqlite.org/lockingv3.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}