`
winie
  • 浏览: 223112 次
  • 性别: 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

分享到:
评论

相关推荐

    BLOG_【故障处理】Oracle_lhr_队列等待之TX - row lock contention

    ### 故障处理:Oracle_lhr_队列等待之TX - row lock contention #### 一、概述 在Oracle数据库管理中,“enq:TX-rowlockcontention”是一种常见的队列等待事件,通常与行级别的锁定冲突有关。这种冲突可能会导致...

    orcale死锁查杀PB版

    - 使用`v$session_wait`视图查找等待类型的`ENQ: TX - row lock contention`或`ENQ: TX - deadlock`。 - 查询`v$deadlock`和`v$deadlock_monitor`视图获取死锁信息。 - 执行`DBMS_LOCK.MONITOR`过程来监控死锁...

    Oracle10g数据库最佳新特性:等待界面 (1)

    例如,对于"enq:TX - row lock contention"这类等待事件,可能需要考虑事务的并发控制策略或锁的粒度。 总之,Oracle 10g的等待界面改进极大地增强了DBAs在性能监控和问题诊断方面的能力。结合ADDM的自动化分析和...

    oracledb-exporter.0.2.9-ora18.5.linux-amd64.tar.gz

    - 锁等待情况(如ENQ: TX - ROW LOCK contention) Prometheus会定期抓取oracledb-exporter提供的这些指标,并根据预设的规则进行报警和可视化展示。你可以利用Prometheus的Alertmanager设置告警规则,当特定指标...

    EBS服务器升级PPT课件.pptx

    数据库性能分析显示,主要的性能瓶颈在于用户I/O,尤其是db file sequential read和db file scattered read事件,以及enq: TX - row lock contention,这些都可能导致新Session无法启动或需要更多内存来处理更多的...

    中国银行ORACLE优化培训方案

    - **enq:TX-rowlock contention**:行级锁争用,表示两个或多个会话尝试在同一行上执行不兼容的操作。 - **latch free**:闩锁等待,表示进程正在等待一个当前被其他进程占用的闩锁。 #### 三、使用与查看数据库...

    Oracle10g数据库最佳新特性:等待界面 (2)

    以SID为269的会话为例,如果它正等待enq:TX — row lock contention事件,意味着它在等待另一个会话释放锁。在Oracle 10g之前,找出阻塞会话可能需要编写资源密集型查询,但在10g中,只需简单查询v$session就能找到...

    oraclev$sessionv$session_wait用途详解

    1. **等待事件类型**:`EVENT`字段列出了具体的等待事件名称,如“db file sequential read”表示顺序读取数据库文件,“enq: TX - row lock contention”表示行级锁竞争。 2. **等待时长**:`TIME_WAITED`字段提供...

    oracle DBA 例行维护内容

    WHERE event LIKE 'enq: TX - row lock contention' OR event LIKE '%wait%'; -- 杀死会话 ALTER SYSTEM KILL SESSION 'sid,serial#'; ``` ##### 2.4 检查系统空间占用 - **工具选择**:使用操作系统自带的...

    People soft on exadata

    - **行锁争用(enq:TX – row lock contention)**:在并发事务处理中,行锁争用是常见的问题之一。当多个事务尝试同时修改同一数据行时,就可能发生此类等待事件。 - **用户I/O**: - 单块读取(single block read...

Global site tag (gtag.js) - Google Analytics