ORACLE数据库等待-enq: TX - allocate ITL entry

https://blog.csdn.net/coco3600/article/details/100232105?utm_source=app

 故障分析及解决过程

3.1  故障环境介绍

2  故障发生现象及报错信息

最近事情比较多,不过还好,碰到的都是等待事件相关的,同事发了个AWR报告,说是系统响应很慢,我简单看了下,简单分析下吧:

wps9D7B.tmp

20分钟时间而DB Time为11461分钟,DB Time太高了,负载很大,很可能有异常的等待事件,系统配置还是比较牛逼的。

等待事件很明显了:

AWR的其它部分就不分析了,首先这个等待事件:enq: TX - allocate ITL entry比较少见,查了一下MOS,有点收获:Troubleshooting waits for 'enq: TX - allocate ITL entry' (文档 ID 1472175.1)

Observe high waits for event enq: TX - allocate ITL entry

Top 5 Timed Foreground Events

Event                           Waits  Time(s)  Avg wait (ms)  % DB time  Wait Class

enq: TX - allocate ITL entry    1,200   3,129           2607       85.22  Configuration

DB CPU                                                   323        8.79

gc buffer busy acquire         17,261      50              3        1.37  Cluster

gc cr block 2-way             143,108      48              0        1.32  Cluster

gc current block busy          10,631      46              4        1.24  Cluster

CAUSE

By default INITRANS value for table is 1 and for index is 2. This defines an internal block structure called the Interested Transaction List (ITL). In order to modify data in a block, a process needs to use an empty ITL slot to record that the transaction is interested in modifying some of the data in the block. If there are insufficient free ITL slots then new ones will be taken in the free space reserved in the block. If this runs out and too many concurrent DML transactions are competing for the same data block we observe contention against the following wait event - "enq: TX - allocate ITL entry".

You can see candidates for re-organisation due to ITL problems in the "Segments by ITL Waits"  section of an Automatic Workload Repository (AWR) report:

Segments by ITL Waits

  * % of Capture shows % of ITL waits for each top segment compared

  * with total ITL waits for all segments captured by the Snapshot

Owner Tablespace Name Object Name Subobject Name Obj. Type       ITL  Waits % of Capture

PIN   BRM_TABLES      SERVICE_T                  TABLE           188               84.30

PIN   BRM_TABLES      BILLINFO_T  P_R_06202012   TABLE PARTITION  35               15.70

SOLUTION

The main solution to this issue is to increase the ITL capability of the table or index by re-creating it and altering the INITRANS or PCTFREE parameter to be able to handle more concurrent transactions. This in turn will help to reduce "enq: TX - allocate ITL entry" wait events.

To reduce enq: TX - allocate ITL entry" wait events, We need to follow the steps below:

1) Set INITRANS to 50 and  pct_free to 40

alter table <table_name> PCTFREE 40  INITRANS 50;

2) Re-organize the table using move ()

alter table <table_name> move;

3) Then rebuild all the indexes of the table as below

alter index <index_name>  rebuild PCTFREE 40 INITRANS 50;

 

总结一下:

原因:表和索引的默认INITRANS值不合适,引起的事务槽分配等待。当一个事务需要修改一个数据块时,需要在数据块头部获取一个可用的ITL槽,用于记录事务的id,使用undo数据块地址,scn等信息。如果事务申请不到新的可用ITL槽时,就会产生enq: TX - allocate ITL entry等待。 发生这个等待时,要么是块上的已分配ITL个数(通过ini_trans参数控制)达到了上限255(10g以后没有了max_trans限制参数,无法指定小于255的值),要么是这个块中没有更多的空闲空间来容纳一个ITL了(每个ITL占用24bytes)。 默认情况下创建的表ITL槽数最小为1+1,pctfree为10,那么如果是这样一种情况,如果表中经常执行update语句,然后块中剩余的10%空间所剩无几,而且业务的并发量还很大,此时就很容易遇到enq: TX - allocate ITL entry等待。

解决:解决方式就是调整表和索引的INITRANS,有必要还需要调整pcfree值。

1) Set INITRANS to 50 and  pct_free to 40

alter table <table_name> PCTFREE 40  INITRANS 50;

2) Re-organize the table using move (alter table <table_name> move;)

3) Then rebuild all the indexes of the table as below

alter index <index_name>  rebuild PCTFREE 40 INITRANS 50;

3  故障分析及解决

有了以上的知识,我们知道,目前首先需要找到产生等待事件的表,然后修改INITRANS和PCTFREE来重构表就可以了。

我们查看AWR中的Segments by ITL Waits部分:

wps9D8F.tmp

wps9D90.tmp

wps9D91.tmp

 

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"enq: TX - allocate ITL entry" 是 Oracle 数据库中的一种 enqueue(加锁)类型,用于在事务中为数据块分配 ITL(Interested Transaction List)条目所需的加锁机制。 如果在数据库中频繁出现 "enq: TX - allocate ITL entry" 的等待事件,并且等待时间过长,可能会导致数据库性能下降,甚至因为事务阻塞而导致数据库宕机。 为了避免这种情况的发生,可以采取以下措施: 1. 调整事务的设计:如果事务设计不合理,可能导致频繁地请求 ITL 条目,从而引起 "enq: TX - allocate ITL entry" 等待事件。因此,可以通过调整事务的设计来减少对 ITL 条目的需求。 2. 增加 ITL 条目:如果数据库中经常出现 "enq: TX - allocate ITL entry" 等待事件,可能是因为 ITL 条目的数量不足,无法满足并发事务的需求。此时,可以通过增加数据块的大小或者增加 INITRANS 参数的值来增加 ITL 条目的数量。 3. 调整 INITRANS 参数:INITRANS 参数指定了在数据块中分配给 ITL 条目的初始数目。如果 INITRANS 参数的值太小,可能会导致 ITL 条目不足,从而引起 "enq: TX - allocate ITL entry" 等待事件。因此,可以通过增加 INITRANS 参数的值来增加 ITL 条目的数量。 4. 增加数据库缓存:如果数据库缓存不足,可能会导致频繁的磁盘 I/O 操作,从而引起 "enq: TX - allocate ITL entry" 等待事件。因此,可以通过增加数据库缓存的大小来减少磁盘 I/O 操作。 5. 优化 SQL 语句:如果 SQL 语句执行效率低下,可能会导致事务持有锁的时间过长,从而引起 "enq: TX - allocate ITL entry" 等待事件。因此,可以通过优化 SQL 语句来减少事务持有锁的时间。 需要注意的是,在数据库出现宕机的情况下,需要进行相应的恢复操作,并对数据库进行全面的性能优化和监控,以避免类似的问题再次发生。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值