[20171123]Skip Locked and ITL slot 2.txt

[20171123]Skip Locked and ITL slot 2.txt

--//昨天看链接提到Skip Locked and ITL slot相关问题,链接
http://jonathanlewis.wordpress.com/2010/05/31/skip-locked/

--//我自己重复测试看看:

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.测试建立:

create table t1 (
    id  number(6),
    modded  number(6)
)
pctused 99
pctfree 0
;
 
insert into t1
select
    rownum      id,
    mod(rownum,3)   modded
from
    all_objects
where
    rownum <= 5000
;
 
commit;
 
-- gather stats at this point.

This gave me 693 rows in the first block, 2 entries in the ITL, and 10 bytes of free space so that I could not add an
ITL entry to the block.

Run the following from three different sessions – supply 0, 1, and 2 as the input parameter in turn.
   
--//建立3个session ,分别带入0,1,2:   
select  id from t1 where   modded = &1 and     rownum <=100 for update skip locked;

The first two sessions will return 100 rows, the third session will (should) return no rows – even though there are no
locked rows for the given value of modded – but the first hundred rows that will be scanned cannot be locked because an
ITL entry cannot be acquired.

--//前面2个会话返回100行,而第3个会话因为ITL槽耗尽,无法分配ITL槽,查询结果如下:
SCOTT@book> select  id from t1 where   modded = &1 and     rownum <=100 for update skip locked;
Enter value for 1: 2
old   1: select  id from t1 where   modded = &1 and     rownum <=100 for update skip locked
new   1: select  id from t1 where   modded = 2 and     rownum <=100 for update skip locked
no rows selected

Remove the skip locked from the query and repeat the test – the third session will get stuck on "enq: TX – allocate
ITL entry".

--//如果删除for update skip locked;
select  id from t1 where   modded = &1 and     rownum <=100;
--//查询返回100行.
select  id from t1 where   modded = &1 and     rownum <=100 for update;

SCOTT@book> select  id from t1 where   modded = &1 and     rownum <=100 for update;
Enter value for 1: 2
old   1: select  id from t1 where   modded = &1 and     rownum <=100 for update
new   1: select  id from t1 where   modded = 2 and     rownum <=100 for update

--//我的测试挂起!!查看等待事件如下:

SYS@book> @ &r/wait
P1RAW            P2RAW            P3RAW                    P1         P2         P3        SID    SERIAL#       SEQ# EVENT                                    STATUS   STATE               WAIT_TIME_MICRO SECONDS_IN_WAIT WAIT_CLASS
---------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------------------------------- -------- ------------------- --------------- --------------- --------------------
0000000054580004 00000000000A001F 000000000000599C 1415053316     655391      22940         80         59         42 enq: TX - allocate ITL entry             ACTIVE   WAITING                    14933217              15 Configuration

SCOTT@book> select  id from t1 where   modded = &1 and     rownum <=100 for update;
Enter value for 1: 2
old   1: select  id from t1 where   modded = &1 and     rownum <=100 for update
new   1: select  id from t1 where   modded = 2 and     rownum <=100 for update
select  id from t1 where   modded = 2 and     rownum <=100 for update
                *
ERROR at line 1:
ORA-01013: user requested cancel of current operation

SCOTT@book> @ &r/spid
       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
        80         59 19582                    DEDICATED 19583       30         27 alter system kill session '80,59' immediate;

时间: 2024-09-28 16:28:12

[20171123]Skip Locked and ITL slot 2.txt的相关文章

1120 11g select for update skip locked

[20171120]11g select for update skip locked.txt --//11G在select for update遇到阻塞时可以通过skipped locked跳过阻塞的记录,测试看看: 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- -----------

MySQL8.0新特性随笔: NOWAIT以及SKIP LOCKED

MySQL8.0版本中对SELECT..FOR UPDATE进行了扩展,实现了新的子句NOWAIT 及 SKIP LOCKED ( WL#3597 及 WL #8919). 本文简单的试玩一把,并看看是怎么实现的.最后介绍下AliSQL中存在的类似功能 测试 如新语法的字面含义,NOWAIT表示当无法获取到锁时直接返回错误,而不是等待:SKIP LOCKED表示忽略那些已经被其他session占有行锁的记录. --session 1 mysql> use test Database change

PostgreSQL 使用advisory lock或skip locked消除行锁冲突, 提高几十倍并发更新效率

PostgreSQL 使用advisory lock或skip locked消除行锁冲突, 提高几十倍并发更新效率 作者 digoal 日期 2016-10-18 标签 PostgreSQL , advisory lock , 高并发更新 背景 通常在数据库中最小粒度的锁是行锁,当一个事务正在更新某条记录时,另一个事务如果要更新同一条记录(或者申请这一条记录的锁),则必须等待锁释放. 通常持锁的时间需要保持到事务结束,也就是说,如果一个长事务持有了某条记录的锁,其他会话要持有这条记录的锁,可能要

[20160728]]行链接行迁移与ITL槽3.txt

[20160728]]行链接行迁移与ITL槽3.txt --上午测试了行链接行迁移与ITL槽的关系,链接如下: [20160727]行链接行迁移与ITL槽2.txt => http://blog.itpub.net/267265/viewspace-2122663/ --如果仔细看前面的测试可以发现当出现行链接或者行迁移时,除了增加1个空itl槽像如下: 0x05   0x0000.000.00000000  0x00000000.0000.00  C---    0  scn 0x0000.0

[20160729]行链接行迁移与ITL槽4.txt

[20160729]行链接行迁移与ITL槽4.txt --做了几个测试,有点乱. http://blog.itpub.net/267265/viewspace-2122700/ http://blog.itpub.net/267265/viewspace-2122663/ http://blog.itpub.net/267265/viewspace-2122599/ --还是通过1个例子来模拟看看.做一个非常极端的测试: 1.环境: SCOTT@book> @ &r/ver1 PORT_ST

[20140130]关于enq TX-allocate ITL entry

  昨天遇到一例enq TX - allocate ITL entry等待事件,就是维护人员打开多个会话更新一个表的某个字段,开始以为等待与undo有关,查 看才发现是"enq TX - allocate ITL entry",因为没有业务操作,建议修改为ctas来建立新表,建立相关索引,然后改名完成操作. 实际上,一般正常的业务操作,很少遇到这个等待事件,如果出现一般是pctfree设置太小或者由于记录程度增大,导致pctfree减少,以及块 上事务太多而导致问题. 做一个简单的比喻

[20160803]另类行迁移.txt

[20160803]另类行迁移.txt --前几天做测试时,链接: http://blog.itpub.net/267265/viewspace-2122712/=>[20160729]行链接行迁移与ITL槽4.txt --发现一个块中的记录在字段长度变长后全部发生行迁移,感觉很奇怪,当时也没有仔细思考(开始以为至少有一些记录不会发生行迁移的 --情况),事后才想起来以前我做过类似的测试,参考链接: http://blog.itpub.net/267265/viewspace-1742243/=

【MOS】 Troubleshooting waits for enq: TX - allocate ITL entry(1472175.1)

Troubleshooting waits for 'enq: TX - allocate ITL entry' (文档 ID 1472175.1) In this Document Symptoms Cause Solution   Increase INITRANS   Increase PCTFREE   A Combination of increasing both INITRANS and PCTFREE References APPLIES TO: Oracle Database

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

[故障处理]队列等待之TX - allocate ITL entry案例 1  BLOG文档结构图       2  前言部分 2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ① enq: TX - allocate ITL entry等待事件的解决 ② 一般等待事件的解决办法 ③ 队列等待的基本知识 Tips: ① 本文在ITpub(http://blog.itpub.net/26736162).博客园(ht