`
winie
  • 浏览: 216573 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
社区版块
存档分类
最新评论

数据库出现 enq: TX - row lock contention

 
阅读更多

数据库出现 enq: TX - row lock contention

今天上午过来,做awr报告数据库出现了很多enq: TX - row lock contention的等待事件,以前从来没有过的,感觉很奇怪。查询gv$session中的等待事件

  1. scrac1/sys@JSCN>selectevent,count(*)fromgv$sessiongroupbyevent;
  2. EVENTCOUNT(*)
  3. --------------------------------------------------------------------------
  4. SQL*Netmessagefromclient275
  5. StreamsAQ:waitingformessagesinthequeue2
  6. ASMbackgroundtimer2
  7. waitforunreadmessageonbroadcastchannel1
  8. gcsremotemessage12
  9. gesremotemessage2
  10. jobqslavewait3
  11. rdbmsipcmessage34
  12. smontimer2
  13. pmontimer2
  14. StreamsAQ:qmnslaveidlewait3
  15. classslavewait2
  16. PXDeq:reapcredit2
  17. PXDeq:ExecutionMsg1
  18. StreamsAQ:waitingfortimemanagementorcleanuptasks2
  19. StreamsAQ:qmncoordinatoridlewait2
  20. DIAGidlewait2
  21. 17rowsselected.

在结果没有出现该等待事件,我们去ash中在看看
  1. scrac1/sys@JSCN>selectSAMPLE_TIME,SESSION_ID,USER_ID,SQL_ID,EVENT,CURRENT_OBJ#,CURRENT_FILE#,CURRENT_BLOCK#fromGV$ACTIVE_SESSION_HISTORY
  2. whereeventlike'enq:TX%'andmodule='JDBCThinClient'andrownum<=10;2
  3. SAMPLE_TIMESESSION_IDUSER_IDSQL_IDEVENTCURRENT_OBJ#CURRENT_FILE#CURRENT_BLOCK#
  4. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  5. 02-AUG-1203.46.26.854PM312059a209wq32zy3jwenq:TX-rowlockcontention583591024510
  6. 02-AUG-1203.46.26.854PM313959a209wq32zy3jwenq:TX-rowlockcontention583591024510
  7. 02-AUG-1203.46.26.854PM315859a209wq32zy3jwenq:TX-rowlockcontention583591024510
  8. 02-AUG-1203.46.26.854PM318659a209wq32zy3jwenq:TX-rowlockcontention583591024510
  9. 02-AUG-1203.46.26.854PM319459a209wq32zy3jwenq:TX-rowlockcontention583591024510
  10. 02-AUG-1203.46.26.854PM319759a209wq32zy3jwenq:TX-rowlockcontention583591024510
  11. 02-AUG-1203.46.26.854PM319859a209wq32zy3jwenq:TX-rowlockcontention583591024510
  12. 02-AUG-1203.46.26.854PM320159a209wq32zy3jwenq:TX-rowlockcontention583591024510
  13. 02-AUG-1203.46.26.854PM321259a209wq32zy3jwenq:TX-rowlockcontention583591024510
  14. 02-AUG-1203.46.26.854PM321359a209wq32zy3jwenq:TX-rowlockcontention583591024510

结果发现很多的enq: TX - row lock contention等待事件,都是昨天的,这个是怎么回事,这个需要我们详细查看GV_$ACTIVE_SESSION_HISTORY表中的字段
首先,我们最容易想到的是sql_ID字段,查询
select * from V$SQL where sql_id='a209wq32zy3jw';
你妹啊,竟然是没有,不会啊,才昨天的sql,应该不会被重share pool中删掉啊,想了想,由于我们这个是rac会不会是连得另外一个节点啊
  1. select*fromGV$SQLwheresql_id='a209wq32zy3jw';
  2. scrac1/sys@JSCN>selectINST_ID,SQL_TEXTfromGV$SQLwheresql_id='a209wq32zy3jw';
  3. INST_ID
  4. ----------
  5. SQL_TEXT
  6. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  7. 1
  8. updateQUARTZ.TASK_LOGSETTASK_ID=:1,STATUS=:2,RESULT_DESC=:3,START_TIME=:4,END_TIME=:5
  9. whereLOG_ID=:6
  10. 1
  11. updateQUARTZ.TASK_LOGSETTASK_ID=:1,STATUS=:2,RESULT_DESC=:3,START_TIME=:4,END_TIME=:5
  12. whereLOG_ID=:6

这个表和sql都很奇怪,之前我们并没有看到过,GV$ACTIVE_SESSION_HISTORY中还有一个USER_ID=59
  1. scrac1/sys@JSCN>selectUSERNAME,USER_ID,CREATEDfromdba_userswhereUSER_ID='59';
  2. USERNAMEUSER_IDCREATED
  3. ----------------------------------------------------
  4. QUARTZ5925-JUN-12
查看到底是那个表出现了锁等待
  1. scrac1/sys@JSCN>select*fromdba_objectswhereobject_id='58359';
  2. OWNEROBJECT_NAMESUBOBJECT_NAMEOBJECT_IDDATA_OBJECT_IDOBJECT_TYPECREATEDLAST_DDL_TIMTIMESTAMPSTATUSTGS
  3. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  4. QUARTZTASK_LOG5835958359TABLE02-AUG-1202-AUG-122012-08-02:14:33:28VALIDNNN

想起来了,昨天他们一直再用这个用在做定时任务,在不停的测试。所以产生的。到此原因已经查明。

如果是在session中出现此类问题,解决方法有:
解决方法:

1:通过v$session找到BLOCK=1的用户,告知用户提交事务

2:通过sid找到pid,kill掉该进程

3:更改sql语句,SELECT * FROM QRTZ_LOCKS WHERE LOCK_NAME = :1 FOR UPDATE no wait

一般如果是现网中出现了大量类似的问题,排除人为原因,那么就要检查应用了

再看看官网上关于TX - row lock contention类容
http://docs.oracle.com/cd/B19306_01/server.102/b14211/instance_tune.htm#sthref761

10.3.7.2.4 TX enqueue

These are acquired exclusive when a transaction initiates its first change and held until the transaction does a COMMIT or ROLLBACK.
Waits for TX in mode 6: occurs when a session is waiting for a row level lock that is already held by another session. This occurs when one user is updating or deleting a row, which another session wishes to update or delete. This type of TX enqueue wait corresponds to the wait event enq: TX - row lock contention.
The solution is to have the first session already holding the lock perform a COMMIT or ROLLBACK.
Waits for TX in mode 4 can occur if the session is waiting for an ITL (interested transaction list) slot in a block. This happens when the session wants to lock a row in the block but one or more other sessions have rows locked in the same block, and there is no free ITL slot in the block. Usually, Oracle dynamically adds another ITL slot. This may not be possible if there is insufficient free space in the block to add an ITL. If so, the session waits for a slot with a TX enqueue in mode 4. This type of TX enqueue wait corresponds to the wait event enq: TX - allocate ITL entry.
The solution is to increase the number of ITLs available, either by changing the INITRANS or MAXTRANS for the table (either by using an ALTER statement, or by re-creating the table with the higher values).
Waits for TX in mode 4 can also occur if a session is waiting due to potential duplicates in UNIQUE index. If two sessions try to insert the same key value the second session has to wait to see if an ORA-0001 should be raised or not. This type of TX enqueue wait corresponds to the wait event enq: TX - row lock contention.
The solution is to have the first session already holding the lock perform a COMMIT or ROLLBACK.
Waits for TX in mode 4 is also possible if the session is waiting due to shared bitmap index fragment. Bitmap indexes index key values and a range of ROWIDs. Each 'entry' in a bitmap index can cover many rows in the actual table. If two sessions want to update rows covered by the same bitmap index fragment, then the second session waits for the first transaction to either COMMIT or ROLLBACK by waiting for the TX lock in mode 4. This type of TX enqueue wait corresponds to the wait event enq: TX - row lock contention.
Waits for TX in Mode 4 can also occur waiting for a PREPARED transaction.
Waits for TX in mode 4 also occur when a transaction inserting a row in an index has to wait for the end of an index block split being done by another transaction. This type of TX enqueue wait corresponds to the wait event enq: TX - index contention.

10.3.7 enqueue (enq:) waits

Enqueues are locks that coordinate access to database resources. This event indicates that the session is waiting for a lock that is held by another session.

The name of the enqueue is included as part of the wait event name, in the form enq: enqueue_type - related_details. In some cases, the same enqueue type can be held for different purposes, such as the following related TX types:

enq: TX - allocate ITL entry

enq: TX - contention

enq: TX - index contention

enq: TX - row lock contention

The V$EVENT_NAME view provides a complete list of all the enq: wait events.

You can check the following V$SESSION_WAIT parameter columns for additional information:

P1 - Lock TYPE (or name) and MODE

P2 - Resource identifier ID1 for the lock

P3 - Resource identifier ID2 for the lock


2012-08-26

补充,今天又出现几百个等待事件了,现在这里等待时间已经到了top event的排名第二了

又按照上述方法查看等待的sql和用户,发现是SYSMAN用户用户造成的等待事件:

sql语句为:

  1. SELECTCURRENT_STATUS
  2. FROMMGMT_CURRENT_AVAILABILITY
  3. WHERETARGET_GUIDIN
  4. (SELECTTARGET_GUIDFROMMGMT_TARGETSWHEREEMD_URL=:B1)
  5. ORDERBYTARGET_GUID
  6. FORUPDATE;
这个sql没看过,google了一下,发现原来可能OEM产生的问题,今天是周末临时过来值班的。一般周末和周五不到万不得已,不要动数据库,不能出了问题找配合的人很麻烦,等到周一过来,吧OEM关掉再看看。


转:http://blog.csdn.net/rulev5/article/details/7826909

分享到:
评论

相关推荐

    enq:TX index contention.txt

    cause:当插入新的索引条目时,发现索引块中没有足够的空间容纳新的索引条目,索引块就会产生分裂(分为5-5分裂...这时就会表现为enq: TX - index contention。本例中索引块分裂属于5-5 分裂,此分裂可以通过awr报告观察

    enq PS - contention.pdf

    enq PS - contention.pdf enq PS - contention.pdfenq PS - contention.pdf

    BLOG_【AWR分析】Oracle_lhr_队列等待之enq IV - contention案例.pdf

    BLOG_【AWR分析】Oracle_lhr_队列等待之enq IV - contention案例.pdfBLOG_【AWR分析】Oracle_lhr_队列等待之enq IV - contention案例.pdf

    BLOG_【故障处理】Oracle_lhr_队列等待之TX - allocate ITL entry案例.pdf

    BLOG_【故障处理】Oracle_lhr_队列等待之TX - allocate ITL entry案例.pdfBLOG_【故障处理】Oracle_lhr_队列等待之TX - allocate ITL entry案例.pdf

    【故障处理】队列等待之TX 等待事件处理.docx

    队列等待之TX - allocate ITL entry引起的死锁处理 Buffer busy waits异常等待事件分析与处理。 Buffer latch异常等待事件分析与处理。 Db file parallel read异常等待事件分析与处理。 Db file sequential read异常...

    BLOG_Oracle_lhr_ 【等待事件】等待事件系列(5.1)--Enqueue(队列等待) .pdf

    BLOG_Oracle_lhr_ 【等待事件】等待事件系列(5.1)--Enqueue(队列等待) .pdfBLOG_Oracle_lhr_ 【等待事件】等待事件系列(5.1)--Enqueue(队列等待) .pdf

    序列等待事件总结

    BLOG_Oracle_lhr_【等待事件】序列等待事件总结(enq SQ - contention、row cache lock、DFS lock handle和enq SV - contention).pdfBLOG_Oracle_lhr_【等待事件】序列等待事件总结(enq SQ - contention、row ...

    undo引起的告警.txt

    当系统activity增加或者降低的时候,oracle SMON进程会自动ONLINE或者OFFLINE rollback segments。这样导致某些与undo segments相关的latch或者enqueue被...导致系统很多活跃session都开始等待enq: US - contention。

    SECSEmulatorv.zip_BAD_HSMS-SECS_SECS_SECS-II_自动化测试

    ITRI CIM Emulator能够读取SML档案,主要功能是用来测试半导体设备的通讯功能,它支持SECS-I/SECS-II/HSMS-SS通讯协议...Send Non-ENQ Bad Length Byte Bad Checksum T1 Timeout T2 Timeout for Length Byte T4 Timeout

    两因素身份验证客户端-Node.js开发

    安装:npm install -g tfa获得帮助bash-3.2 $ tfa用法:tfa [选项] [命令]命令:enroll-qrcode | enq [选项] 使用qrcode文件进行注册enroll | en [选项] enroll生成| gen [options] [label]生成list | l list delete...

    VMWare7.14汉化补丁

    VU59U-D0E0L-48ENQ-G6WGG-PQUZF 汉化方法: 1.安装原始版本。 2.解压完美汉化包,把汉化文件直接复制到虚拟机文件夹中,替 换原文件即可。 3.替换时,个别文件可能提示无法替换,请在任务管理器中先 结束相应...

    ASCII码表完整版, 从48-0,65-A,97-a,等等日常通用对照表

    打印字符:数字32-126分配给了能在键盘上找到的字符,当查看或打印文档时就会出现。 NUT SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR So SI DLE DCI DC2 DC3 DC4 NAK SYN TB CAN EM SUB ESC FS GS RS Us

    测试:Avelacnum enq testayin REPO

    ИмяпользователяПервое,чтовследуетсделатьпослеустановкиGit —указатьвашеимяиадресэлект。 Этоважно,потомуч...

    linux作业调度C程序

    linux实验 linux 作业调度程序 C语言 源码 可执行文件 enq deq stat

    超详细的字符编码教程

    5 – ENQ – ENQuiry 请求 2.1.2.1.2.6. 6 – ACK – ACKnowledgment 回应/响应 2.1.2.1.2.7. 7 – BEL – [audible] BELl 2.1.2.1.2.8. 8 – BS – BackSpace 退格键 2.1.2.1.2.9. 9 – HT – Horizontal Tab 水平...

    priorityqueuejs:Node.js的简单优先级队列数据结构

    priorityqueue.js Node.js的... enq ( { cash : 250 , name : 'Valentina' } ) ;queue . enq ( { cash : 300 , name : 'Jano' } ) ;queue . enq ( { cash : 150 , name : 'Fran' } ) ;queue . size ( ) ; // 3queue . p

    Python实现队列的方法

    def enQ(): queue.append(raw_input('Enter new string: ').strip()) #调用list的列表的pop()函数.pop(0)为列表的第一个元素 def deQ(): if len(queue) == 0: print 'Cannot pop from an empty queue!' else: ...

    FreeBarcode

    \NUL、\SOH、\STX、\ETX、\EOT、\ENQ、\ACK、\BEL、\BS、\HT、\LF、\VT、\FF、\CR、\SO、\SI、\DLE、 \DC1、\DC2、\DC3、\DC4、\NAK、\SYN、\ETB、\CAN、\EM、\SUB、\ESC、\FS、\GS、\RS、\US 也就是说,这些符号...

    Job-Scheduling:OS实验2, 作业调度

    Job-Scheduling需求说明基本要求和提高要求基本要求:学习源代码,并完成十个调试任务。提高要求:实现多级反馈轮转调度算法多级——多个队列。反馈——优先级会根据等待时间变化轮转——同优先级的作业轮流进行具体...

    遂宁网万事卡学习版 V1.0

    通过该程序,你可以用来销售小量各类数字卡币。 主要功能: 1,采用预存方式时实交易数字卡。便利数字卡网上即使交易的特性。 2,带积分、消费总金额、交易历史等统计功能。 3,客户预存点,可采用发行充值卡方式。...

Global site tag (gtag.js) - Google Analytics