如何识别 Oracle 死锁中涉及的行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10577000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I identify the rows involved in an Oracle deadlock?
提问by WW.
When Oracle detects a deadlock, a trace file like this is written:
当 Oracle 检测到死锁时,会写入这样的跟踪文件:
*** SESSION ID:(56.27081) 2012-05-14 08:16:28.013
DEADLOCK DETECTED ( ORA-00060 )
[Transaction Deadlock]
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock: Deadlock graph:
---------Blocker(s)-------- ---------Waiter(s)---------
Resource Name process session holds waits process session holds waits
TX-0010002c-002719b5 146 56 X 164 44 X
TX-000f002a-002edd1e 164 44 X 146 56 X
session 56: DID 0001-0092-00050D0D session 44: DID 0001-00A4-0002E3C2
session 44: DID 0001-00A4-0002E3C2 session 56: DID 0001-0092-00050D0D
Rows waited on:
Session 44: obj - rowid = 00035157 - AAA1FXAAxAAASfLAAn
(dictionary objn - 217431, file - 49, block - 75723, slot - 39)
Session 56: obj - rowid = 00035157 - AAA1FXAAsAACjuiAAP
(dictionary objn - 217431, file - 44, block - 670626, slot - 15)
How can I determine the rows involved based on the information above in order to assist in debugging the application?
如何根据上述信息确定涉及的行以协助调试应用程序?
回答by WW.
I found the answer:
我找到了答案:
The number after
dictionary objn
can be used to select out of DBA_objects.SELECT owner, object_name, object_type FROM dba_objects WHERE object_id = 217431;
Once the table is identified, the row can be found using the rowid:
SELECT * FROM table_found_above WHERE rowid = 'AAA1FXAAxAAASfLAAn';
后面的数字
dictionary objn
可用于从 DBA_objects 中选择。SELECT owner, object_name, object_type FROM dba_objects WHERE object_id = 217431;
一旦确定了表,就可以使用 rowid 找到该行:
SELECT * FROM table_found_above WHERE rowid = 'AAA1FXAAxAAASfLAAn';
If the trace file says that there are no "Rows waited on" this technique will not work. The problem may be due to an unindexed foreign key.
如果跟踪文件说没有“等待的行”,则此技术将不起作用。问题可能是由于未索引的外键造成的。