How to resolve Oracle deadlock

DBA Notes: 2011/09/15

Cheng Li

 

How to resolve Oracle Deadlock

 

From alert log, we are reported for ORA-000060: Deadlock detected. By diggering into trace file we can see following information marked in RED.

 

*** 2011-09-15 15:37:08.529

*** SESSION ID:(14.60398) 2011-09-15 15:37:08.264 DEADLOCK DETECTED Current SQL statement for this session:

UPDATE PS_BU_ITEMS_INV SET    LAST_ORDER = :1, LAST_ORDER_DATE = :2, QTY_AVAILABLE = QTY_AVAILABLE - :3, QTY_RESERVED = QTY_RESERVED + :4, DT_TIMESTAMP = SYS

DATE WHERE  BUSINESS_UNIT = :5 AND INV_ITEM_ID = :6 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-000d0038-0001b99b         9      14     X             44      91           X

TX-000e005c-0001baea        44      91     X              9      14           X

session 14: DID 0001-0009-00000002      session 91: DID 0001-002C-00000002

session 91: DID 0001-002C-00000002      session 14: DID 0001-0009-00000002

Rows waited on:

Session 91: obj - rowid = 00001336 - AAABM2AAZAAAIJ5AAY Session 14: obj - rowid = 00001336 - AAABM2AA3AAAHQdAAU ===================================================

 

Oracle comments about deadlock:

http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14220/consist.htm#sthref2043

 

As I review the description from blog of secooler:

http://space.itpub.net/519536/viewspace-611729

 

And following article: http://oracle-error.blogspot.com/2008/10/ora-00060-deadlock-detected-while_20.html

 

Oracle automatically detects deadlocks and resolves them by rolling back one of the transactions/statements involved in the deadlock, thus releasing one set of resources/data locked by that transaction. The session that is rolled back will observe Oracle error: ORA-00060: deadlock detected while waiting for resource. Oracle will also produce detailed information in a trace file under database's UDUMP directory.

 

In the affected session, the rolled back statement needs to be re-executed once the resources are available

Way to detect:

When the wait event is experienced, issue the following complex query:

Select s.sid SID,
s.serial# Serial#,
l.type type,
' ' object_name,
lmode held,
request request
from v$lock l, v$session s, v$process p
where s.sid = l.sid and
s.username <> ' ' and
s.paddr = p.addr and
l.type <> 'TM' and
(l.type <> 'TX' or l.type = 'TX' and l.lmode <> 6)
union
select s.sid SID,
s.serial# Serial#,
l.type type,
object_name object_name,
lmode held,
request request
from v$lock l, v$session s, v$process p, sys.dba_objects o
where s.sid = l.sid and
o.object_id = l.id1 and
l.type = 'TM' and
s.username <> ' ' and
s.paddr = p.addr
union
select s.sid SID,
s.serial# Serial#,
l.type type,
'(Rollback='||rtrim(r.name)||')' object_name,
lmode held,
request request
from v$lock l, v$session s, v$process p, v$rollname r
where s.sid = l.sid and
l.type = 'TX' and
l.lmode = 6 and
trunc(l.id1/65536) = r.usn and
s.username <> ' ' and
s.paddr = p.addr
order by 5, 6
/

The output of the query will look something like this:

SID SERIAL# TY OBJECT_NAM HELD REQUEST
----- ------- -- ---------- ---------- --------
36 8428 TX 0 4
36 8428 TM TAB1 3 0
52 29592 TM TAB1 3 0
52 29592 TX (Rollback=RBS1_6) 6 0

CONCLUSION:
Dead locks do occur in most of the applications and dead locks can be avoided by properly designing the transactions and applications by keeping other transactions and applications in mind. ITL waits and dead locks related to ITL waits can be avoided by setting of INITRANS and MAXTRANS properly. Dead locks during the transactions on bitmap indexed tables can be avoided by performing heavy transactions with no bitmap indexes and after completing the transactions rebuild the bitmap indexes.

fj.pngU2727P2DT20110915091212.jpg

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26136400/viewspace-707602/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26136400/viewspace-707602/

已经博主授权,源码转载自 https://pan.quark.cn/s/a4b39357ea24 QueueForMcu 基于单片机实现的队列功能模块,主要用于8位、16位、32位非运行RTOS的单片机应用,兼容大多数单片机平台。 开源代码:https://.com/xiaoxinpro/QueueForMcu 一、特性 动态创建队列对象 动态设置队列数据缓冲区 静态指定队列元素数据长度 采用值传递的方式保存队列数据 二、快速使用 三、配置说明 目前QueueForMcu只有一个静态配置项,具体如下: 在文件 中有一个宏定义 用于指定队列元素的数据长度,默认是 ,可以根据需要更改为其他数据类型。 四、数据结构 队列的数据结构为 用于保存队列的状态,源码如下: 其中 为配置项中自定义的数据类型。 五、创建队列 1、创建队列缓存 由于我们采用值传递的方式保存队列数据,因此我们在创建队列前要手动创建一个队列缓存区,用于存放队列数据。 以上代码即创建一个大小为 的队列缓存区。 2、创建队列结构 接下来使用 创建队列结构,用于保存队列的状态: 3、初始化队列 准备好队列缓存和队列结构后调用 函数来创建队列,该函数原型如下: 参数说明: 参考代码: 六、压入队列 1、单数据压入 将数据压入队列尾部使用 函数,该函数原型如下: 参数说明: 返回值说明: 该函数会返回一个 枚举数据类型,返回值会根据队列状态返回以下几个值: 参考代码: 2、多数据压入 若需要将多个数据(数组)压入队列可以使用 函数,原理上循环调用 函数来实现的,函数原型如下: 参数说明: 当数组长度大于队列剩余长度时,数组多余的数据将被忽略。 返回值说明: 该函数将返回实际被压入到队列中的数据长度。 当队列中的剩余长度富余...
### 回答1: 这个错误提示通常出现在编写或运行类似Markdown文档时,因为出现了未知或无法识别的指令或命令。 可能的原因是: 1. 所使用的Markdown解析器或工具不支持或未安装这个指令; 2. 指令名拼写错误或使用了不正确的语法格式; 3. 指令依赖的外部库或插件没有正确安装或配置。 您可以检查所使用的Markdown解析器或工具的文档,以确定它是否支持该指令,或者您可以尝试使用其他的Markdown解析器或工具。另外,您也可以检查一下指令的拼写和语法是否正确,以及所依赖的库或插件是否已经正确安装和配置。 ### 回答2: “Failed to resolve directive”这个错误信息出现在使用某些编程语言和软件工具时,通常是由于缺少了某个库、模块或插件所导致的。 在一些编程语言和工具中,我们可以使用不同的指令或命令行来实现不同的功能,这些指令可能需要使用特定的库或模块才能正常工作。如果我们使用的指令需要的库或模块不存在或者无法正常加载,就会出现“failed to resolve directive”的错误提示。 对于这种错误,我们可以通过以下几种方法来解决: 1.检查环境配置:首先要确保我们的环境配置正确,比如检查相关的库、模块或插件是否已经安装或者是在正确的路径下。 2.更新/安装相关软件:如果检查发现缺少相关软件,我们需要及时更新或安装这些软件,以确保我们的指令能够正常运行。 3.检查指令语法:如果环境配置没有问题,那么我们需要检查指令语法是否正确,可能是因为笔误或者其他语法错误导致了“failed to resolve directive”。 4.寻求帮助:如果问题依然存在,那么我们可以寻求相应软件的官方支持,或者是在相关社区中寻求帮助。很多时候,其他开发者可能已经遇到了相似的问题,并找到了解决方案,可以提供宝贵的参考。 ### 回答3: "Failed to resolve directive" 是指一个文件中出现了一个指令 (directive),但编译器或者解释器 (compiler/interpreter) 无法解析它。在很多编程语言中,指令是很普遍的。在 HTML 中,例如,指令可能包括各种标签,如 <html>,<head>,<body> 等等。在 CSS 中,可能包括各种指令,如 font-size,font-color,background 等等。当编译器或者解释器无法解析这些指令时,就会出现 "Failed to resolve directive" 的错误。 大多数情况下,这个问题的解决方法都很简单。通常需要做的就是检查指令拼写是否正确,是否大小写正确,是否正确嵌套等等。这种错误可能被人为地引入进来,比如开发者写错了一些指令,比如大小写不匹配。也可能是由于应用程序中的更复杂的问题,比如应用程序不兼容,或者需要更新。 一般来说,解决这个问题并不难。最好的做法是在阅读错误消息的时候仔细查看哪个文件和哪个行号出现了错误。如果这个错误似乎没有明显的错误提示,可以尝试从头开始阅读代码,确认所有指令是否正确、是否与其他部分配合良好、是否有循环引用等问题。通常情况下,一个简单的错误可能导致 "Failed to resolve directive",因此要仔细检查代码并尝试简化它,以确保它不包含其他问题。最后,还可以咨询社区或其他开发人员,看看他们是否遇到过这个问题,并询问他们是否有解决办法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值