{
  "id": "python/pytest-fixture-finalizer-error",
  "signature": "RuntimeError: Error during teardown of fixture 'database' (got exception: OperationalError: database is locked)",
  "signature_zh": "RuntimeError: 在 fixture 'database' 的 teardown 过程中出错 (得到异常: OperationalError: database is locked)",
  "regex": "RuntimeError:\\ Error\\ during\\ teardown\\ of\\ fixture\\ 'database'\\ \\(got\\ exception:\\ OperationalError:\\ database\\ is\\ locked\\)",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The fixture's finalizer (teardown) raises an exception, often because the database connection is still in use or locked when trying to close it.",
  "root_cause_type": "generic",
  "root_cause_zh": "fixture 的 finalizer（teardown）抛出异常，通常是因为在尝试关闭数据库连接时，连接仍在使用中或被锁定。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This is unreliable; the lock might persist longer, and sleeping wastes time.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This hides potential resource leaks and can cause issues in subsequent tests.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ensure all database transactions are committed or rolled back before teardown: `yield db; db.close()`",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use a context manager for the database connection to guarantee proper cleanup.",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-12-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}