{
  "id": "java/derby-lock-timeout",
  "signature": "java.sql.SQLException: Lock time out. The lock request timed out because another transaction holds a conflicting lock.",
  "signature_zh": "java.sql.SQLException: 锁超时。锁请求超时，因为另一个事务持有冲突的锁。",
  "regex": "java\\.sql\\.SQLException: Lock time out\\. The lock request timed out because another transaction holds a conflicting lock\\.",
  "domain": "java",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "A database transaction is waiting for a lock held by another transaction and exceeds the configured lock timeout, typically due to long-running transactions or deadlocks in embedded Derby databases.",
  "root_cause_type": "generic",
  "root_cause_zh": "数据库事务正在等待另一个事务持有的锁，并超过了配置的锁超时时间，通常是由于嵌入式 Derby 数据库中的长时间运行事务或死锁。",
  "versions": [
    {
      "version": "Apache Derby 10.14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Apache Derby 10.15",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Apache Derby 10.16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Restart the database server or application",
      "why_fails": "Restarting clears all locks but does not fix the underlying transaction logic that causes contention; the problem will recur.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase the lock timeout to a very high value (e.g., 600 seconds)",
      "why_fails": "A higher timeout delays the error but does not resolve the conflict; the transaction may still time out or cause performance degradation.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a different database driver version",
      "why_fails": "The lock timeout is a database-level behavior, not a driver issue; changing drivers does not affect locking mechanisms.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set a shorter lock timeout using Derby system property derby.locks.waitTimeout=30 (in seconds) to fail fast and retry the transaction.",
      "success_rate": 0.8,
      "how": "Set a shorter lock timeout using Derby system property derby.locks.waitTimeout=30 (in seconds) to fail fast and retry the transaction.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Optimize transaction scope: commit or rollback transactions as early as possible to release locks. For example, in JDBC code, use try-with-resources to ensure auto-close and commit.",
      "success_rate": 0.85,
      "how": "Optimize transaction scope: commit or rollback transactions as early as possible to release locks. For example, in JDBC code, use try-with-resources to ensure auto-close and commit.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use isolation level READ_COMMITTED instead of REPEATABLE_READ to reduce lock contention. Set connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED).",
      "success_rate": 0.75,
      "how": "Use isolation level READ_COMMITTED instead of REPEATABLE_READ to reduce lock contention. Set connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Set a shorter lock timeout using Derby system property derby.locks.waitTimeout=30 (in seconds) to fail fast and retry the transaction.",
    "Optimize transaction scope: commit or rollback transactions as early as possible to release locks. For example, in JDBC code, use try-with-resources to ensure auto-close and commit.",
    "Use isolation level READ_COMMITTED instead of REPEATABLE_READ to reduce lock contention. Set connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED)."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://db.apache.org/derby/docs/10.15/ref/rrefexceptlocktimeout.html",
  "official_doc_section": null,
  "error_code": "DERBY-1000",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.82,
  "resolvable": "partial",
  "first_seen": "2024-01-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}