泰坦:锁所有者等待自己的锁导致 com.sleepycat.je.LockTimeoutException
Titan: Lock owner waits for own lock causing com.sleepycat.je.LockTimeoutException
我有一个使用 Tinkerpop 3 and Titan Graph DB 加上本地 Berkeley 存储后端的多线程 Web 应用程序。有时,由于以下异常而导致提交失败:
Transaction x owns y
Transaction x waits for y
这当然让我感到困惑。为什么锁拥有者在等待自己的锁时会超时呢?同样的 commit/rollback 操作在第一次和第二次接近后总是尝试最多 3 次,退避时间分别为 1 秒和 1.5 秒。我还确保事务不会在请求之间泄漏(总是在每个请求的开始和结束时回滚)。最后,我尝试尽快释放任何锁。有什么提示吗?
一些例子
示例异常 1
Caused by: com.sleepycat.je.LockTimeoutException: (JE 5.0.73) Lock expired. Locker 1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn: waited for lock on database=edgestore LockAddr:1418570977 LSN=0x0/0x7498 type=WRITE grant=WAIT_PROMOTION timeoutMillis=500 startTime=1486450928285 endTime=1486450928785
Owners: [<LockInfo locker="1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn" type="READ"/>, <LockInfo locker="1628779116 2189_pool-4-thread-1_Txn" type="READ"/>]
Waiters: []
Transaction 1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn owns LockAddr:1418570977 <LockInfo locker="1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn" type="READ"/>
Transaction 1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn waits for LockAddr:1418570977
示例异常 2
Caused by: com.sleepycat.je.LockTimeoutException: (JE 5.0.73) Lock expired. Locker 1938532737 6471_ForkJoinPool-1-worker-1_Txn: waited for lock on database=edgestore LockAddr:2056488084 LSN=0x0/0x5a1db type=WRITE grant=WAIT_PROMOTION timeoutMillis=500 startTime=1486457805980 endTime=1486457806480
Owners: [<LockInfo locker="1938532737 6471_ForkJoinPool-1-worker-1_Txn" type="READ"/>, <LockInfo locker="1223191726 6475_pool-16-thread-1_Txn" type="READ"/>]
Waiters: []
Transaction 1938532737 6471_ForkJoinPool-1-worker-1_Txn owns LockAddr:2056488084 <LockInfo locker="1938532737 6471_ForkJoinPool-1-worker-1_Txn" type="READ"/>
Transaction 1938532737 6471_ForkJoinPool-1-worker-1_Txn waits for LockAddr:2056488084
示例异常 3
Caused by: com.sleepycat.je.LockTimeoutException: (JE 5.0.73) Lock expired. Locker 1723301468 1446_pool-3-thread-1_Txn: waited for lock on database=edgestore LockAddr:1184880090 LSN=0x0/0xa966 type=WRITE grant=WAIT_PROMOTION timeoutMillis=500 startTime=1486730956580 endTime=1486730957080
Owners: [<LockInfo locker="1577323761 1489_Thread-41_Txn" type="READ"/>, <LockInfo locker="1723301468 1446_pool-3-thread-1_Txn" type="READ"/>, <LockInfo locker="1845682412 1451_Thread-40_Txn" type="READ"/>]
Waiters: [<LockInfo locker="2126118378 1517_Thread-42_Txn" type="READ"/>]
Transaction 1723301468 1446_pool-3-thread-1_Txn owns LockAddr:1184880090 <LockInfo locker="1723301468 1446_pool-3-thread-1_Txn" type="READ"/>
Transaction 1723301468 1446_pool-3-thread-1_Txn waits for LockAddr:1184880090
使用 Titan's successor JanusGraph. I presume it was a bug within the Titan 代码库不再存在此问题。
我有一个使用 Tinkerpop 3 and Titan Graph DB 加上本地 Berkeley 存储后端的多线程 Web 应用程序。有时,由于以下异常而导致提交失败:
Transaction x owns y
Transaction x waits for y
这当然让我感到困惑。为什么锁拥有者在等待自己的锁时会超时呢?同样的 commit/rollback 操作在第一次和第二次接近后总是尝试最多 3 次,退避时间分别为 1 秒和 1.5 秒。我还确保事务不会在请求之间泄漏(总是在每个请求的开始和结束时回滚)。最后,我尝试尽快释放任何锁。有什么提示吗?
一些例子
示例异常 1
Caused by: com.sleepycat.je.LockTimeoutException: (JE 5.0.73) Lock expired. Locker 1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn: waited for lock on database=edgestore LockAddr:1418570977 LSN=0x0/0x7498 type=WRITE grant=WAIT_PROMOTION timeoutMillis=500 startTime=1486450928285 endTime=1486450928785
Owners: [<LockInfo locker="1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn" type="READ"/>, <LockInfo locker="1628779116 2189_pool-4-thread-1_Txn" type="READ"/>]
Waiters: []
Transaction 1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn owns LockAddr:1418570977 <LockInfo locker="1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn" type="READ"/>
Transaction 1437370674 2837_jWebSocket TCP-Connector 01.52499.3_Txn waits for LockAddr:1418570977
示例异常 2
Caused by: com.sleepycat.je.LockTimeoutException: (JE 5.0.73) Lock expired. Locker 1938532737 6471_ForkJoinPool-1-worker-1_Txn: waited for lock on database=edgestore LockAddr:2056488084 LSN=0x0/0x5a1db type=WRITE grant=WAIT_PROMOTION timeoutMillis=500 startTime=1486457805980 endTime=1486457806480
Owners: [<LockInfo locker="1938532737 6471_ForkJoinPool-1-worker-1_Txn" type="READ"/>, <LockInfo locker="1223191726 6475_pool-16-thread-1_Txn" type="READ"/>]
Waiters: []
Transaction 1938532737 6471_ForkJoinPool-1-worker-1_Txn owns LockAddr:2056488084 <LockInfo locker="1938532737 6471_ForkJoinPool-1-worker-1_Txn" type="READ"/>
Transaction 1938532737 6471_ForkJoinPool-1-worker-1_Txn waits for LockAddr:2056488084
示例异常 3
Caused by: com.sleepycat.je.LockTimeoutException: (JE 5.0.73) Lock expired. Locker 1723301468 1446_pool-3-thread-1_Txn: waited for lock on database=edgestore LockAddr:1184880090 LSN=0x0/0xa966 type=WRITE grant=WAIT_PROMOTION timeoutMillis=500 startTime=1486730956580 endTime=1486730957080
Owners: [<LockInfo locker="1577323761 1489_Thread-41_Txn" type="READ"/>, <LockInfo locker="1723301468 1446_pool-3-thread-1_Txn" type="READ"/>, <LockInfo locker="1845682412 1451_Thread-40_Txn" type="READ"/>]
Waiters: [<LockInfo locker="2126118378 1517_Thread-42_Txn" type="READ"/>]
Transaction 1723301468 1446_pool-3-thread-1_Txn owns LockAddr:1184880090 <LockInfo locker="1723301468 1446_pool-3-thread-1_Txn" type="READ"/>
Transaction 1723301468 1446_pool-3-thread-1_Txn waits for LockAddr:1184880090
使用 Titan's successor JanusGraph. I presume it was a bug within the Titan 代码库不再存在此问题。