死锁的根本原因?

Root cause of deadlock?

我在下面看到了有关在 Oracle 12g 跟踪文件中检测到的死锁之一的详细信息,但我不明白为什么这里会发生死锁?

当线程 1 获取 table1 或 table 行的锁但等待 table 2 行时发生死锁,同时线程 2 获取 [=17= 的锁] 2 行 byt 等待 table1 行

但我看不到详细信息,即哪个会话获取了哪个 table 上的锁以及等待哪个资源。任何帮助在这里被锁定的对象是什么 原因是什么?

Deadlock graph:
                                          ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name                             process session holds waits  process session holds waits
TX-00290010-00015F75-00000000-00000000        295    1200     X            288       10           X
TX-00570012-00005D9B-00000000-00000000        288       10     X            295    1200           X

session 1200: DID 0001-0127-00014421    session 10: DID 0001-0120-00016BD1 
session 10: DID 0001-0120-00016BD1  session 1200: DID 0001-0127-00014421 

Rows waited on:
  Session 1200: obj - rowid = 00051348 - BABRNIAARAAKfNLAAl
...
  Session 10: obj - rowid = 000514F2 - BABRTyAAJAAKWbIAAY
....

----- Information for the OTHER waiting sessions -----
....
  current SQL:
  update employee set name=:1 
----- End of information for the OTHER waiting sessions -----

Information for THIS session:

----- Current SQL Statement for this session (sql_id=5dfr2prw60rh1) -----
update department set address =:1 where id=:1 
===================================================

您的输出表明当前会话正在尝试更新部门 table 中的锁定记录("information for THIS session" 输出)。另一个会话试图更新每个员工记录("information for the OTHER waiting sessions" 输出)。当前会话必须更新了员工中的记录 table,阻塞了另一个会话,而另一个会话更新了当前会话正在尝试更新的记录。

我认为这是导致死锁的某种练习,因为您将每个员工记录设置为相同的名称。