- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
14#
发表于 2012-3-7 23:42:13
SQL> select * from V$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
session A SQL> alter table maclean add a10 char(2000) default 'maclean';
session B: select 1 from maclean where rownum=1; ==> hang here !
session C: select 1 from maclean where rownum=1; ==> SAME SQL, hang here !
SQL> select event from v$session where event like 'library%';
EVENT
----------------------------------------------------------------
library cache lock
library cache pin
session 4:
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug dump systemstate 266;
Statement processed.
SQL> oradebug tracefile_name;
/s01/admin/G10R21/udump/g10r21_ora_6208.trc
----------------------------------------
SO: 0x84f5b4a8, type: 4, owner: 0x84e5d4f8, flag: INIT/-/-/0x00
(session) sid: 142 trans: (nil), creator: 0x84e5d4f8, flag: (41) USR/- BSY/-/-/-/-/-
DID: 0001-0010-00000027, short-term DID: 0000-0000-00000000
txn branch: (nil)
oct: 3, prv: 0, sql: 0x7bf10088, psql: 0x7bf582f0, user: 0/SYS
O/S info: user: oracle, term: pts/1, ospid: 6159, machine: vrh8.oracle.com
program: sqlplus@vrh8.oracle.com (TNS V1-V3)
application name: sqlplus@vrh8.oracle.com (TNS V1-V3), hash value=0
waiting for 'library cache lock' blocking sess=0x(nil) seq=23 wait_time=0 seconds since wait started=17
handle address=7c3a5560, lock address=8003b350, 100*mode+namespace=c9
Dumping Session Wait History
for 'library cache lock' count=1 wait_time=2149666
handle address=7c3a5560, lock address=8003b350, 100*mode+namespace=c9
for 'library cache lock' count=1 wait_time=2930643
handle address=7c3a5560, lock address=8003b350, 100*mode+namespace=c9
for 'library cache lock' count=1 wait_time=2930300
handle address=7c3a5560, lock address=8003b350, 100*mode+namespace=c9
for 'library cache lock' count=1 wait_time=2930715
handle address=7c3a5560, lock address=8003b350, 100*mode+namespace=c9
for 'library cache lock' count=1 wait_time=2930545
handle address=7c3a5560, lock address=8003b350, 100*mode+namespace=c9
for 'library cache lock' count=1 wait_time=2929985
session 142 is B waiting for library cache lock
the lock handle address is 7c3a5560
SO: 0x8003b350, type: 53, owner: 0x84f98ba0, flag: INIT/-/-/0x00
LIBRARY OBJECT LOCK: lock=8003b350 handle=7c3a5560 request=S
call pin=(nil) session pin=(nil) hpc=0005 hlc=0000
htl=0x8003b3d0[0x7d034330,0x7d034330] htb=0x7d034330 ssga=0x7e9f2168
user=84f5b4a8 session=84f5b4a8 count=0 flags=RES/[0010] savepoint=0x1f9
LIBRARY OBJECT HANDLE: handle=7c3a5560 mutex=0x7c3a5690(0)
name=SYS.MACLEAN
hash=458787ae49fd6f284ccb04a892b38231 timestamp=02-09-2012 21:32:36
namespace=TABL flags=KGHP/TIM/SML/[02000000]
kkkk-dddd-llll=0000-0701-0701 lock=X pin=X latch#=3 hpc=0006 hlc=0004
lwt=0x7c3a5608[0x8003b380,0x8003b380] ltm=0x7c3a5618[0x7c3a5618,0x7c3a5618]
pwt=0x7c3a55d0[0x7c3a55d0,0x7c3a55d0] ptm=0x7c3a55e0[0x7c3a55e0,0x7c3a55e0]
ref=0x7c3a5638[0x7c3a5638,0x7c3a5638] lnd=0x7c3a5650[0x7bf75a18,0x7bf90650]
LIBRARY OBJECT: object=7c1dec60
type=TABL flags=EXS/LOC/UPD[0905] pflags=[0000] status=VALD load=0
DATA BLOCKS:
data# heap pointer status pins change whr
----- -------- -------- --------- ---- ------ ---
0 7c3a54a0 7c1ded78 I/P/A/-/- 0 NONE 00
8 7c1de7f0 7e33ed48 I/P/A/-/- 1 UPDATE 00
9 7c1de8c0 7bf109e8 I/P/A/-/- 1 NONE 00
10 7c1de948 7bf10600 I/P/A/-/- 1 NONE 00
关于session B的 library cache lock , 其原因是 add column 的session A 以 X mode lock SYS.MACLEAN, X mode pin SYS.MACLEAN 且不释放, 所以session B的 library cache lock不用多解释
session C:
SO: 0x84f5dd18, type: 4, owner: 0x84e5dce0, flag: INIT/-/-/0x00
(session) sid: 144 trans: (nil), creator: 0x84e5dce0, flag: (41) USR/- BSY/-/-/-/-/-
DID: 0001-0011-0000000A, short-term DID: 0000-0000-00000000
txn branch: (nil)
oct: 3, prv: 0, sql: 0x7bf10088, psql: 0x7bf582f0, user: 0/SYS
O/S info: user: oracle, term: pts/2, ospid: 6183, machine: vrh8.oracle.com
program: sqlplus@vrh8.oracle.com (TNS V1-V3)
application name: sqlplus@vrh8.oracle.com (TNS V1-V3), hash value=0
waiting for 'library cache pin' blocking sess=0x(nil) seq=19 wait_time=0 seconds since wait started=17
handle address=7bf46e40, pin address=7f03f890, 100*mode+namespace=c8
Dumping Session Wait History
for 'library cache pin' count=1 wait_time=2568684
handle address=7bf46e40, pin address=7f03f890, 100*mode+namespace=c8
for 'library cache pin' count=1 wait_time=2930677
handle address=7bf46e40, pin address=7f03f890, 100*mode+namespace=c8
for 'library cache pin' count=1 wait_time=2929805
handle address=7bf46e40, pin address=7f03f890, 100*mode+namespace=c8
for 'library cache pin' count=1 wait_time=2931420
handle address=7bf46e40, pin address=7f03f890, 100*mode+namespace=c8
for 'library cache pin' count=1 wait_time=2930258
handle address=7bf46e40, pin address=7f03f890, 100*mode+namespace=c8
session 144 is session C , waiting for library cache pin
handle address 7bf46e40=> 指向 一个 child cursor namespace=CRSR, 而这个child cursor已经被 session B pin住了:
SO: 0x7f03f890, type: 54, owner: 0x84f5dd18, flag: INIT/-/-/0x00
LIBRARY OBJECT PIN: pin=7f03f890 handle=7bf46e40 request=S lock=0
user=84f5dd18 session=84f5dd18 count=0 mask=0000 savepoint=0x3f flags=[00]
----------------------------------------
SO: 0x7ec4cc80, type: 53, owner: 0x84f5dd18, flag: INIT/-/-/0x00
LIBRARY OBJECT LOCK: lock=7ec4cc80 handle=7bf46e40 mode=N
call pin=(nil) session pin=(nil) hpc=0000 hlc=0000
htl=0x7ec4cd00[0x7e449348,0x80c35108] htb=0x80c35108 ssga=0x80c34ff0
user=84f5dd18 session=84f5dd18 count=1 flags=[0000] savepoint=0x0
LIBRARY OBJECT HANDLE: handle=7bf46e40 mutex=0x7bf46f70(0)
namespace=CRSR flags=RON/KGHP/PN0/[10010000]
kkkk-dddd-llll=0000-0001-0000 lock=N pin=X latch#=3 hpc=0004 hlc=0004
lwt=0x7bf46ee8[0x7bf46ee8,0x7bf46ee8] ltm=0x7bf46ef8[0x7bf46ef8,0x7bf46ef8]
pwt=0x7bf46eb0[0x7f03f8c0,0x7f03f8c0] ptm=0x7bf46ec0[0x7bf46ec0,0x7bf46ec0]
ref=0x7bf46f18[0x7bf7bfe0,0x7bf7bfe0] lnd=0x7bf46f30[0x7bf46f30,0x7bf46f30]
LIBRARY OBJECT: object=7bf29018
type=CRSR flags=EXS[0001] pflags=[0000] status=VALD load=0
READ ONLY DEPENDENCIES: count=1 size=16
DATA BLOCKS:
data# heap pointer status pins change whr
----- -------- -------- --------- ---- ------ ---
0 7bf20060 7bf28ba8 I/P/A/-/- 0 NONE 00
6 7bf77a20 7bf776f8 I/P/A/-/- 1 NONE 00
我们可以找到 上面这个child cursor 的 parent cursor :
SO: 0x7d03b620, type: 53, owner: 0x84f5b4a8, flag: INIT/-/-/0x00
LIBRARY OBJECT LOCK: lock=7d03b620 handle=7bf10088 mode=N
call pin=(nil) session pin=(nil) hpc=0000 hlc=0000
htl=0x7d03b6a0[0x7d034030,0x7c03c9f8] htb=0x7d034030 ssga=0x7e9f2168
user=84f5b4a8 session=84f5b4a8 count=1 flags=[0000] savepoint=0x1f7
LIBRARY OBJECT HANDLE: handle=7bf10088 mutex=0x7bf101b8(0)
name=select 1 from maclean where rownum=1
hash=324793c639b13d0954bd5421eaed6701 timestamp=03-08-2012 02:29:24
namespace=CRSR flags=RON/KGHP/TIM/KEP/PN0/SML/DBN/[12010044]
kkkk-dddd-llll=0001-0001-0001 lock=N pin=0 latch#=3 hpc=0004 hlc=0004
lwt=0x7bf10130[0x7bf10130,0x7bf10130] ltm=0x7bf10140[0x7bf10140,0x7bf10140]
pwt=0x7bf100f8[0x7bf100f8,0x7bf100f8] ptm=0x7bf10108[0x7bf10108,0x7bf10108]
ref=0x7bf10160[0x7bf10160,0x7bf10160] lnd=0x7bf10178[0x82f4f2f8,0x7bf4d608]
LIBRARY OBJECT: object=7bf7c8a8
type=CRSR flags=EXS[0001] pflags=[0000] status=VALD load=0
CHILDREN: size=16
child# table reference handle
------ -------- --------- --------
0 7bf7c370 7bf7bfe0 7bf46e40 => 只有一个child handle 7bf46e40
DATA BLOCKS:
data# heap pointer status pins change whr
----- -------- -------- --------- ---- ------ ---
0 7bf2a428 7bf7c9c0 I/P/A/-/- 0 NONE 00
即在session B parse SQL "select 1 from maclean where rownum=1" 的时候, 会生成一个child cursor 并 X mode pin住这个child cursor , 而session C 同时发起 一样的SQL语句 "select 1 from maclean where rownum=1" 时 需要 share 这个child cursor , 即以 S mode pin 这个child cursor , 但是session B 还没有完成 optimize 没有生成完整的child cursor , 需要等待 session A 释放 library cache lock才能 完成, 所以 session C 要等 session B build child cursor , 此时session C等" library cache pin" ;
如果 session C 执行的是不一样的SQL,那么 session C 不share 同一个child cursor , session C 会wait for library cache lock. |
|