ITL原理解释:

ITL(Interested Transaction List)是Oracle数据块内部的一个组成部分,用来记录该块所有发生的事务,一个itl可以看作是一个记录,在一个时间,可以记录一个事务(包括提交或者未提交事务)。当然,如果这个事务已经提交,那么这个itl的位置就可以被反复使用了,因为itl类似记录,所以,有的时候也叫itl槽位。Oracle的每个数据块中都有一个或者多个事务槽,每一个对数据块的并发访问事务都会占用一个事务槽。表和索引的事务槽ini_trans是1、max_trans是255,在oracle10g中,不能修改max_trans这个参数,因为oracle10g忽略了这个参数。如果一个事务一直没有提交,那么,这个事务将一直占用一个itl槽位,itl里面记录了事务信息,回滚段的嵌入口,事务类型等等。如果这个事务已经提交,那么,itl槽位中还保存的有这个事务提交时候的SCN号。如果在并发量特别大的系统中,最好分配足够的itl个数(10g之前的版本),其实它并浪费不了太多的空间,或者,设置足够的pctfree,保证itl能扩展。但是pctfree有可能是被行数据给消耗掉的,如update可能一下占满块空间,所以,也有可能导致块内部的空间不够而导致itl等待。所以在通常情况下,10g版本后引起itl等待的原因往往是因为块的空间不足导致,并不是tran事务槽数量不足。在正常情况下2k的数据块最多可以拥有41个itl,4k数据块最多拥有83,8k最多拥有169个itl(以itl 24byte为单位)。INITRANS不足的问题不会出现在索引数据块上,当发现没有足够空间分配ITL slot时,无论是枝点块还是叶子块,数据块会发生分裂(Index Block Split)。
模拟场景:initrans不能扩展分配slot导致的itl争用。

创建表cjc_t1,默认INI_TRANS为1,MAX_TRANS为255,PCT_FREE为10。
create table cjc_t1(a int);set line 300set pagesize 100select dbms_metadata.get_ddl('TABLE','CJC_T1','CJC') from dual;CREATE TABLE "CJC"."CJC_T1"( "A" NUMBER(*,0)) SEGMENT CREATION DEFERREDPCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255NOCOMPRESS LOGGINGTABLESPACE "CJCTBS"set line 300set pagesize 100col table_name for a15col tablespace_name for a15select table_name,tablespace_name,pct_free,ini_trans,max_trans from user_tables where table_name='CJC_T1';TABLE_NAME TABLESPACE_NAME PCT_FREE INI_TRANS MAX_TRANS--------------- --------------- ---------- ---------- ----------CJC_T1 CJCTBS 10 1 255
指定pctfree为0,同时指定initrans为1然后填满相关数据块,再对块满的数据进行更新模拟出itl的等待。
drop table cjc_t1 purge;create table cjc_t1(a int) pctfree 0 initrans 1;---alter table cjc_t1 pctfree 10;---alter table cjc_t1 pctfree 0;TABLE_NAME TABLESPACE_NAME PCT_FREE INI_TRANS MAX_TRANS--------------- --------------- ---------- ---------- ----------CJC_T1 CJCTBS 0 1 255
插入测试数据
beginfor i in 1 .. 20000 loopinsert into cjc_t1 values (i);commit;end loop;end;
查看测试数据对应的文件号、块号、数据量。
select file_id, block_id, count(*)from (select dbms_rowid.rowid_relative_fno(rowid) file_id,dbms_rowid.rowid_block_number(rowid) block_idfrom cjc_t1)group by file_id, block_idorder by 3, 2;FILE_ID BLOCK_ID COUNT(*)---------- ---------- ----------8 32 2098 11 7338 12 7338 13 7338 14 7338 15 7338 16 7338 17 7338 18 7338 19 7338 20 7338 21 7338 22 7338 23 7338 25 7338 26 7338 27 7338 28 7338 29 7338 30 7338 31 7338 33 7338 34 7338 35 7338 36 7338 37 7338 38 7338 39 73328 rows selected.
插入20000条数据后可以发现该表有28个数据块,填满了除了32块以外的其他数据块。
接着导出已经填满的数据块11.
SQL> conn as sysdbaConnected.SQL> alter system dump datafile 8 block 11;System altered.SQL> oradebug setmypid;Statement processed.SQL> oradebug tracefile_name;/u01/app/oracle11/diag/rdbms/chendb/chendb/trace/chendb_ora_8418.trc[oracle@cjcos01 trace]$ vim u01/app/oracle11/diag/rdbms/chendb/chendb/trace/chendb_ora_8418.trc......Block header dump: 0x0200000bObject id on Block? Yseg/obj: 0x15ac6 csc: 0x00.2436e8 itc: 2 flg: E typ: 1 - DATAbrn: 0 bdba: 0x2000008 ver: 0x01 opc: 0inc: 0 exflg: 0Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0002.01c.00001141 0x00c051b5.0109.20 C--- 0 scn 0x0000.002436e80x02 0x0007.01b.0000105b 0x00c0631e.0100.1a C--- 0 scn 0x0000.002436e7bdba: 0x0200000bdata_block_dump,data header at 0x7fa1f9d42a64===============tsiz: 0x1f98hsiz: 0x5ccpbl: 0x7fa1f9d42a6476543210flag=--------ntab=1nrow=733frre=-1fsbo=0x5ccfseo=0xb94avsp=0x7tosp=0x70xe:pti[0] nrow=733 offs=00x12:pri[0] offs=0x1f910x14:pri[1] offs=0x1f8a
接着导出没有填满的数据块32。
alter system dump datafile 8 block 32;oradebug setmypid;oradebug tracefile_name;
查看trc信息。
Block header dump: 0x02000020Object id on Block? Yseg/obj: 0x15ac6 csc: 0x00.247d61 itc: 2 flg: E typ: 1 - DATAbrn: 1 bdba: 0x2000018 ver: 0x01 opc: 0inc: 0 exflg: 0Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0003.011.00001174 0x00c06232.00bb.11 --U- 1 fsc 0x0000.00247d620x02 0x0009.007.000011a0 0x00c003d4.010f.09 C--- 0 scn 0x0000.00247d61bdba: 0x02000020data_block_dump,data header at 0x7fa1f9d42a64===============tsiz: 0x1f98hsiz: 0x1b4pbl: 0x7fa1f9d42a6476543210flag=--------ntab=1nrow=209frre=-1fsbo=0x1b4fseo=0x1914avsp=0x168btosp=0x168b0xe:pti[0] nrow=209 offs=00x12:pri[0] offs=0x1f90
ITL说明:
1)Itl:ITL事务槽编号,ITL事务槽号的流水编号2)Xid:代表对应的事务id(transac[X]tion identified),在回滚段事务表中有一条记录和这个事务对应。Xid由三列使用十六进制编码的数字列表示,分别是:Undo Segment Number +Transaction Table Slot Number+ Wrap,即由undo段号+undo槽号+undo槽号的覆盖次数三部分组成,即usn.slot.sqn。3)Uba:(Undo Block Address),该事务对应的回滚段地址,记录了最近一次的该记录的前镜像(修改前的值)。Uba组成:Undo块地址(undo文件号和数据块号)+回滚序列号+回滚记录号。多版本一致读是Oracle保证读操作不会被事务阻塞的重要特性。当Server Process需要查询一个正在被事务修改,但是尚未提交的数据时,就根据ITL上的uba定位到对应Undo前镜像数据位置。4)Flag:事务标志位,即当前事务槽的状态信息。这个标志位就记录了这个事务的操作状态,各个标志的含义分别是:----:事务是活动的,未提交,或者在块清理前提交事务。C---:事务已经提交,锁已经被清除(提交)。-B--:this undo record contains the undo for this ITL entry。--U-:事务已经提交,但是锁还没有清除(快速提交)。---T:...C-U-:...5)Lck:表示这个事务所影响的行数,锁住了几行数据,对应有几个行锁。我们看到01号事物槽Lck为3,因为该事物槽中的事物Flag为U,证明该事物已经提交,但是锁还没有清除。再比如对于下边这个ITL:我们看到01号事物槽Lck为0,因为该事物槽中的事物Flag为C,证明该事物已经提交,锁也被清楚掉了,该事物槽可以被重用了。02号事物槽Lck为1,是因为我对第一行做了一个更新,并且没有提交,Flag为“----”说明该事物是活动的。6)Scn/Fsc:Commit SCN或者快速提交(Fast Commit Fsc)的SCN。Scn=SCN of commited TX; Fsc=Free space credit(bytes)每条记录中的行级锁对应Itl条目lb,对应于Itl列表中的序号,即那个事务在该记录上产生的锁。一个事物只有在提交之后才会在ITL事物槽中记录SCN。

通过bbed工具,查看块信息:
准备文件:
[oracle@cjcos01 bbed]$ pwd/home/oracle/bbed[oracle@cjcos01 bbed]$ ll -rthtotal 20K-rw-r--r-- 1 oracle oinstall 1.2K Dec 20 11:43 ssbbded.o-rw-r--r-- 1 oracle oinstall 1.9K Dec 20 11:43 sbbdpt.o-rw-r--r-- 1 oracle oinstall 8.5K Dec 20 11:43 bbedus.msb
将文件拷贝到指定目录
[oracle@cjcos01 bbed]$ cp bbedus.msb $ORACLE_HOME/rdbms/mesg/[oracle@cjcos01 bbed]$ cp ssbbded.o $ORACLE_HOME/rdbms/lib/[oracle@cjcos01 bbed]$ cp sbbdpt.o $ORACLE_HOME/rdbms/lib/
编译
[oracle@cjcos01 bbed]$ make -f $ORACLE_HOME/rdbms/lib/ins_rdbms.mk BBED=$ORACLE_HOME/bin/bbed $ORACLE_HOME/bin/bbedLinking BBED utility (bbed)rm -f u01/app/oracle11/product/11.2.0/dbhome_1/bin/bbedgcc -o u01/app/oracle11/product/11.2.0/dbhome_1/bin/bbed -m64 -z noexecstack -L/u01/app/oracle11/product/11.2.0/dbhome_1/rdbms/lib/ -L/u01/app/oracle11/product/11.2.0/dbhome_1/lib/ -L/u01/app/oracle11/product/11.2.0/dbhome_1/lib/stubs/ /u01/app/oracle11/product/11.2.0/dbhome_1/lib/s0main.o /u01/app/oracle11/product/11.2.0/dbhome_1/rdbms/lib/ssbbded.o /u01/app/oracle11/product/11.2.0/dbhome_1/rdbms/lib/sbbdpt.o `cat /u01/app/oracle11/product/11.2.0/dbhome_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -ldbtools11 -lclntsh `cat /u01/app/oracle11/product/11.2.0/dbhome_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /u01/app/oracle11/product/11.2.0/dbhome_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnnz11 -lzt11 -lztkg11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lmm -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /u01/app/oracle11/product/11.2.0/dbhome_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /u01/app/oracle11/product/11.2.0/dbhome_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /u01/app/oracle11/product/11.2.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle11/product/11.2.0/dbhome_1/lib -lm `cat /u01/app/oracle11/product/11.2.0/dbhome_1/lib/sysliblist` -ldl -lm -L/u01/app/oracle11/product/11.2.0/dbhome_1/lib
bbed 默认密码" blockedit"
[oracle@cjcos01 bbed]$ bbedPassword:BBED: Release 2.0.0.0.0 - Limited Production on Sun Dec 20 11:51:23 2020Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.************* !!! For Oracle Internal Use only !!! ***************BBED>
使用BBED 工具之前需要创建filelist 文件
set linesize 100col name for a50set feedback off;set heading off;spool /home/oracle/filelist.txtselect file#,name,bytes from v$datafile order by 1;1 /u01/app/oracle11/oradata/chendb/system01.dbf 7864320002 /u01/app/oracle11/oradata/chendb/sysaux01.dbf 5872025603 /u01/app/oracle11/oradata/chendb/undotbs01.dbf 2097152004 /u01/app/oracle11/oradata/chendb/users01.dbf 52428805 /u01/app/oracle11/oradata/chendb/example01.dbf 3283353606 /u01/app/oracle11/oradata/chendb/cjctbs01.dbf 10485767 /u01/app/oracle11/oradata/chendb/cjctbs02.dbf 10485768 /u01/app/oracle11/oradata/chendb/cjctbs03.dbf 10485769 /u01/app/oracle11/oradata/chendb/cjctbs05.dbf 1048576spool off
创建bbed.par文件
[oracle@cjcos01 ~]$ touch bbed.par[oracle@cjcos01 ~]$ vim bbed.parblocksize=8192listfile=/home/oracle/filelist.txtmode=edit
登录
[oracle@cjcos01 ~]$ bbed parfile=bbed.parPassword:BBED: Release 2.0.0.0.0 - Limited Production on Sun Dec 20 11:56:31 2020Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.************* !!! For Oracle Internal Use only !!! ***************BBED> help allBBED> infoFile# Name Size(blks)----- ---- ----------1 /u01/app/oracle11/oradata/chendb/system01.dbf 960002 /u01/app/oracle11/oradata/chendb/sysaux01.dbf 716803 /u01/app/oracle11/oradata/chendb/undotbs01.dbf 256004 /u01/app/oracle11/oradata/chendb/users01.dbf 6405 /u01/app/oracle11/oradata/chendb/example01.dbf 400806 /u01/app/oracle11/oradata/chendb/cjctbs01.dbf 1287 /u01/app/oracle11/oradata/chendb/cjctbs02.dbf 1288 /u01/app/oracle11/oradata/chendb/cjctbs03.dbf 1289 /u01/app/oracle11/oradata/chendb/cjctbs05.dbf 128
指定查看file 8 block 11信息
BBED> set file 8 block 11FILE# 8BLOCK# 11
查看信息
BBED> mapFile: /u01/app/oracle11/oradata/chendb/cjctbs03.dbf (8)Block: 11 Dba:0x0200000b------------------------------------------------------------KTB Data Block (Table/Cluster)struct kcbh, 20 bytes @0struct ktbbh, 72 bytes @20struct kdbh, 14 bytes @100struct kdbt[1], 4 bytes @114sb2 kdbr[733] @118ub1 freespace[1480] @1584 ---该块空闲1480byteub1 rowdata[5124] @3064ub4 tailchk @8188
BBED> p ktbbhstruct ktbbh, 72 bytes @20ub1 ktbbhtyp @20 0x01 (KDDBTDATA)union ktbbhsid, 4 bytes @24ub4 ktbbhsg1 @24 0x00015ac6ub4 ktbbhod1 @24 0x00015ac6struct ktbbhcsc, 8 bytes @28ub4 kscnbas @28 0x00249012ub2 kscnwrp @32 0x0000sb2 ktbbhict @36 2ub1 ktbbhflg @38 0x32 (NONE)ub1 ktbbhfsl @39 0x00ub4 ktbbhfnx @40 0x02000008struct ktbbhitl[0], 24 bytes @44struct ktbitxid, 8 bytes @44ub2 kxidusn @44 0x0002ub2 kxidslt @46 0x001cub4 kxidsqn @48 0x00001141struct ktbituba, 8 bytes @52ub4 kubadba @52 0x00c051b5ub2 kubaseq @56 0x0109ub1 kubarec @58 0x20ub2 ktbitflg @60 0x8000 (KTBFCOM)union _ktbitun, 2 bytes @62sb2 _ktbitfsc @62 0ub2 _ktbitwrp @62 0x0000ub4 ktbitbas @64 0x002436e8struct ktbbhitl[1], 24 bytes @68struct ktbitxid, 8 bytes @68ub2 kxidusn @68 0x000aub2 kxidslt @70 0x001bub4 kxidsqn @72 0x00001097struct ktbituba, 8 bytes @76ub4 kubadba @76 0x00c05ffaub2 kubaseq @80 0x00c5ub1 kubarec @82 0x33ub2 ktbitflg @84 0x8000 (KTBFCOM)union _ktbitun, 2 bytes @86sb2 _ktbitfsc @86 0ub2 _ktbitwrp @86 0x0000ub4 ktbitbas @88 0x00249010
指定查看file 8 block 32信息
BBED> set file 8 block 32FILE# 8BLOCK# 32
查看信息
BBED> mapFile: /u01/app/oracle11/oradata/chendb/cjctbs03.dbf (8)Block: 32 Dba:0x02000020------------------------------------------------------------KTB Data Block (Table/Cluster)struct kcbh, 20 bytes @0struct ktbbh, 72 bytes @20struct kdbh, 14 bytes @100struct kdbt[1], 4 bytes @114sb2 kdbr[209] @118ub1 freespace[5984] @536ub1 rowdata[1668] @6520ub4 tailchk @8188
更新数据,查看行迁移情况
SQL> update cjc_t1 set a=10000000000000000000000000000000000000000000000000000000000000 where a=1500;1 row updated.SQL> commit;Commit complete.
BBED> set file 8 block 11FILE# 8BLOCK# 11
查看信息
BBED> mapFile: /u01/app/oracle11/oradata/chendb/cjctbs03.dbf (8)Block: 11 Dba:0x0200000b------------------------------------------------------------KTB Data Block (Table/Cluster)struct kcbh, 20 bytes @0struct ktbbh, 72 bytes @20struct kdbh, 14 bytes @100struct kdbt[1], 4 bytes @114sb2 kdbr[733] @118ub1 freespace[1480] @1584ub1 rowdata[5124] @3064ub4 tailchk @8188
查看行迁移情况
SQL> @?/rdbms/admin/utlchain.sqlTable created.SQL> desc chained_rowsName Null? Type----------------------------------------- -------- ----------------------------OWNER_NAME VARCHAR2(30)TABLE_NAME VARCHAR2(30)CLUSTER_NAME VARCHAR2(30)PARTITION_NAME VARCHAR2(30)SUBPARTITION_NAME VARCHAR2(30)HEAD_ROWID ROWIDANALYZE_TIMESTAMP DATE
SQL> conn cjc/cjcConnected.SQL> set autotrace traceonly statSQL> set linesize 1000SQL> select * from cjc_t1 where a>20000000000000000;Statistics----------------------------------------------------------5 recursive calls0 db block gets64 consistent gets0 physical reads0 redo size519 bytes sent via SQL*Net to client523 bytes received via SQL*Net from client2 SQL*Net roundtrips to/from client0 sorts (memory)0 sorts (disk)1 rows processedupdate cjc_t1 set a=to_number(LPAD('1', 22, '1')) where a=1521;commit;SQL> select * from cjc_t1 where a>20000000000000000;Statistics----------------------------------------------------------0 recursive calls0 db block gets32 consistent gets0 physical reads0 redo size583 bytes sent via SQL*Net to client523 bytes received via SQL*Net from client2 SQL*Net roundtrips to/from client0 sorts (memory)0 sorts (disk)2 rows processedupdate cjc_t1 set a=to_number(LPAD('1', 10, '1')) where a=1525;commit;update cjc_t1 set a=to_number(LPAD('1', 10, '1')) where a=1526;commit;update cjc_t1 set a=1527 where a=1527;SQL> analyze table cjc.cjc_t1 list chained rows into sys.chained_rows;Table analyzed.

模拟enq: TX - allocate ITL entry等待事件
会话1
SQL> conn cjc/cjcConnected.SQL> select * from v$mystat where rownum<=1;SID STATISTIC# VALUE---------- ---------- ----------1 0 0SQL> update cjc_t1 set a=1500 where a=1500;1 row updated.
会话56
SQL> conn cjc/cjcConnected.SQL> select * from v$mystat where rownum<=1;SID STATISTIC# VALUE---------- ---------- ----------56 0 0SQL> update cjc_t1 set a=1501 where a=1501;1 row updated.
会话35
SQL> conn cjc/cjcConnected.SQL> select * from v$mystat where rownum<=1;SID STATISTIC# VALUE---------- ---------- ----------35 0 0SQL> update cjc_t1 set a=1502 where a=1502;...卡住
查看会话信息,35号会话出现enq: TX - allocate ITL entry等待事件。
select sid,serial#,username,status,program,sql_id,event,p1,p2,p2text,p3from v$sessionwhere username = 'CJC'and machine = 'cjcos01';SID SERIAL# USERNAME STATUS PROGRAM SQL_ID EVENT P1 P2 P2TEXT P31 1 13 CJC INACTIVE sqlplus@cjcos01 (TNS V1-V3) SQL*Net message from client 1650815232 1 #bytes 02 35 59 CJC ACTIVE sqlplus@cjcos01 (TNS V1-V3) 05u6gsqjgrvxq enq: TX - allocate ITL entry 1415053316 524304 usn<<16 | slot 44803 56 253 CJC INACTIVE sqlplus@cjcos01 (TNS V1-V3) SQL*Net message from client 1650815232 1 #bytes 0
查看enq: TX - allocate ITL entry等待事件描述
select * from v$event_name where name like 'enq: TX - allocate ITL entry';EVENT# EVENT_ID NAME PARAMETER1 PARAMETER2 PARAMETER3 WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS1 242 281768874 enq: TX - allocate ITL entry name|mode usn<<16 | slot sequence 3290255840 2 Configuration
再次查看数据块信息
SQL> conn / as sysdbaConnected.SQL> alter system dump datafile 8 block 11;System altered.SQL> oradebug setmypid;Statement processed.SQL> oradebug tracefile_name;/u01/app/oracle11/diag/rdbms/chendb/chendb/trace/chendb_ora_14553.trc
查看trace信息
[root@cjcos01 ~]# vim /u01/app/oracle11/diag/rdbms/chendb/chendb/trace/chendb_ora_14553.trc......Block header dump: 0x0200000bObject id on Block? Yseg/obj: 0x15ac6 csc: 0x00.2436e8 itc: 2 flg: E typ: 1 - DATAbrn: 0 bdba: 0x2000008 ver: 0x01 opc: 0inc: 0 exflg: 0Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0007.018.00001093 0x00c06349.0100.32 ---- 1 fsc 0x0000.000000000x02 0x0008.010.00001180 0x00c002a2.0136.30 ---- 1 fsc 0x0000.00000000bdba: 0x0200000bdata_block_dump,data header at 0x7f3d1e7bda64===============tsiz: 0x1f98hsiz: 0x5ccpbl: 0x7f3d1e7bda6476543210flag=--------ntab=1nrow=733frre=-1fsbo=0x5ccfseo=0xb94avsp=0x7tosp=0x7
update cjc_t1 set a=1505 where a=1505;update cjc_t1 set a=1506 where a=1506;
select sid,serial#,username,status,program,sql_id,event,p1,p2,p2text,p3from v$sessionwhere username = 'CJC'and machine = 'cjcos01';SID SERIAL# USERNAME STATUS PROGRAM SQL_ID EVENT P1 P2 P2TEXT P31 1 15 CJC INACTIVE sqlplus@cjcos01 (TNS V1-V3) SQL*Net message from client 1650815232 1 #bytes 02 35 63 CJC ACTIVE sqlplus@cjcos01 (TNS V1-V3) 05u6gsqjgrvxq enq: TX - allocate ITL entry 1415053316 655387 usn<<16 | slot 42473 52 12975 CJC ACTIVE sqlplus@cjcos01 (TNS V1-V3) g9tmbcuv84aq6 enq: TX - allocate ITL entry 1415053316 655387 usn<<16 | slot 42474 56 253 CJC INACTIVE sqlplus@cjcos01 (TNS V1-V3) SQL*Net message from client 1650815232 1 #bytes 05 58 31 CJC ACTIVE sqlplus@cjcos01 (TNS V1-V3) 3pu5608w2zktc enq: TX - allocate ITL entry 1415053316 458776 usn<<16 | slot 4243

如何解决enq: TX - allocate ITL entry等待事件问题:
业务需要需要考虑:
1 业务需要考虑对应SQL是否可以优化,比如优化并行执行次数、减少访问频率等。2 考虑是否可以修改业务逻辑,减少频繁访问等。3 考虑多个SQL在一个事务内完成,减少itl分配次数,减少并发执行多个事务。
数据库层需要考虑:
Troubleshooting waits for 'enq: TX - allocate ITL entry' (Doc ID 1472175.1)
为了减少enq:TX-allocate ITL entry“等待事件,我们需要遵循以下步骤:
一:增加INITRANS
1) 根据表中的事务数,可以需要更改INITRANS的值。例如这里改为50:alter table <table name> INITRANS 50;2) 使用下面命令重新组织表。alter table <table_name> move;3) rebuild这张表下的所有索引。alter index <index_name> rebuild INITRANS 50;
二:增加PCTFREE
如果通过增加INITRANS无法解决问题,请尝试增加PCTFREE。增加PCTFREE可以保留更多的空间,因此可以将相同数量的行分布到更多的块上。这意味着,还有更多的ITL插槽可用。1 将行分散到更多的块中也有助于减少这种等待事件。alter table <table name> PCTFREE 20;2) 使用下面命令重新组织表。alter table <table_name> move;3) Rebuild indexalter index index_name rebuild PCTFREE 20;三:同时增加INITRANS和PCTFREE的组合1) Set INITRANS to 50 and pct_free to 20alter table <table_name> PCTFREE 20 INITRANS 50;2) Re-organize the table using movealter table <table_name> move;3) Then rebuild all the indexes of the table as belowalter index <index_name> rebuild PCTFREE 20 INITRANS 50;
注意:
可以为表/索引修改INITRANS的新值。但更改后的值仅对新块生效。需要重新生成对象,以便再次初始化块。对于索引,这意味着需要重新生成或重新创建索引。对于表,可通过以下方式实现:exp/impalter table movedbms_redefenition

2020-12-20 19:35 chenjuchao




