Académique Documents
Professionnel Documents
Culture Documents
#.2
#.3
Enqueue Types
DDL Locks Data Dictionary
Row Cache Library Cache Locks
#.4
Statspack
Top 5 Timed Events Top 5 Timed Events ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ Avg %Total Avg %Total wait wait Call Call Event Waits Time (s) Event Waits Time (s) (ms) (ms) Time Time -------------------------- ------------ ----------- ------ ------------------------------- ------------ ----------- ------ -----Enqueue Enqueue CPU time CPU time db file sequential read db file sequential read control file sequential read control file sequential read log file switch completion log file switch completion 42 42 165 165 214 214 2 2 126 126 4 4 1 1 0 0 0 0 3000 3000 4 4 1 1 40 40 96.5 96.5 2.8 2.8 .4 .4 .1 .1 .1 .1
#.5
v$session_wait
SQL> select event, p1,p2,p3 from v$session_wait; SQL> select event, p1,p2,p3 from v$session_wait; EVENT EVENT enqueue enqueue P1 P1 1415053318 1415053318 P2 P2 589855 589855 P3 P3 1592 1592 ----------------- -------------- ---------- -------------------------- -------------- ---------- ----------
What can we do with this info? Note: v$session_wait is for current waits. Need ASH or some similar data source for historic analysis
Copyright 2006 Kyle Hailey
#.6
Enqueue : Args
P1 = Type | mode P2 = ID1 , depends on P1 P3 = ID2 , depends on P1
#.7
#.8
Type: 5458
Hex Decimal 54 = 84 58 = 88 ASCII = T = X
Mode: 0006
Lock = TX 6
Copyright 2006 Kyle Hailey
#.9
#.10
#.11
#.12
Modes
1 2 3 4 5 6 Null SS SX S SSX X Null Sub share Sub exclusive Share Share/sub exclusive Exclusive
#.13
Types
CF Control File HW High Water SQ - Sequence ST - Space Transaction TM - DML TS Temporary Segment / Table Space TX Transaction UL DBMS_LOCK UN User Named US Undo Segment
Looking at v$lock
select * from v$lock where type in ('TX', 'TM'); select * from v$lock where type in ('TX', 'TM');
#.14
SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK --- -- ---------- ---------- ----- ------- ----- ------- -- ---------- ---------- ----- ------- ----- ----151 TX 589855 1592 0 6 4049 0 151 TX 589855 1592 0 6 4049 0 135 TM 53737 0 3 0 4058 0 135 TM 53737 0 3 0 4058 0 151 TM 53737 0 3 0 4049 0 151 TM 53737 0 3 0 4049 0 135 TX 589855 1592 6 0 4058 1 135 TX 589855 1592 6 0 4058 1
TX TM
ID1 = RBS seg# | RBS slot # ID2 = rbs wrap # ID1 = object id ID2 = 0
Copyright 2006 Kyle Hailey
#.15
Lock = TM
ID1
= object id ID2 = 0
#.16
#.17
Enqueue Solutions
SQ Sequence Lock
logon/logoff problem
#.18
TX - mode 6
application problem
TX - mode 4
probably ITL problem find the object and SQL
HW High Water
Look at object and SQL use LMT, freelists, pre-allocate extents,
ST - Space Transaction
only one per database used for space allocations uet, fet Find object use LMT
UL - User Lock
find out what application is doing
Copyright 2006 Kyle Hailey
#.19
To tune enqueues we need one of the following to determine the type of enqueue
ASH
#.20
V$session
select sid, row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#, lockwait from v$session;
SID ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# LOCKWAIT --- ------------- -------------- --------------- ------------- -------141 53651 3 53980 0 143 -1 0 0 0 144 -1 0 0 0 149 -1 0 0 0 151 53737 4 428 0 410343AC
#.21
10g Lockwait not null is blocker Pre-10g Lockwait not null is the waiter
Copyright 2006 Kyle Hailey
#.22
Enqueue : TX 6 Example
Exclusive Row Level Lock User 1 SQL> delete from emp where empno = 7934; SQL> update emp set sal=2000 Where empno = 7934; User 2
#.23
Enqueue : TX 6 v$session_wait
SQL> select event, p1,p2,p3 from v$session_wait; SQL> select event, p1,p2,p3 from v$session_wait; EVENT EVENT enqueue enqueue P1 P1 1415053318 1415053318 P2 P2 589855 589855 P3 P3 1592 1592 ----------------- -------------- ---------- -------------------------- -------------- ---------- ----------
#.24
Enqueue : TX 6 v$lock
select * from v$lock where type in ('TX', 'TM'); select * from v$lock where type in ('TX', 'TM');
#.25
SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK --- -- ---------- ---------- ----- ------- ----- ------- -- ---------- ---------- ----- ------- ----- ----151 TX 589855 1592 0 6 4049 0 151 TX 589855 1592 0 6 4049 0 135 TM 53737 0 3 0 4058 0 135 TM 53737 0 3 0 4058 0 151 TM 53737 0 3 0 4049 0 151 TM 53737 0 3 0 4049 0 135 TX 589855 1592 6 0 4058 1 135 TX 589855 1592 6 0 4058 1
TX TM
ID1 = RBS seg# | RBS slot # ID2 = rbs wrap # ID1 = object id ID2 = 0
Copyright 2006 Kyle Hailey
#.26
Enqueue : TX 6 V$session
select sid, row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#, lockwait from v$session;
SID ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# LOCKWAIT --- ------------- -------------- --------------- ------------- -------141 53651 3 53980 0 143 -1 0 0 0 144 -1 0 0 0 149 -1 0 0 0 151 53737 4 428 0 410343AC
#.27
10g Lockwait not null is blocker Pre-10g Lockwait not null is the waiter
Copyright 2006 Kyle Hailey
#.28
Enqueue : TX 4
Index on p(id) User 1 SQL> insert into p values(3); SQL> insert into p values(3); User 2
Enqueue : TX 4
select sid, select sid, event, event, chr(bitand(P1,-16777216)/16777215)|| chr(bitand(P1,-16777216)/16777215)|| chr(bitand(P1,16711680)/65535) as "Type", chr(bitand(P1,16711680)/65535) as "Type", mod(p1,16) as "mode" mod(p1,16) as "mode" from v$session_wait from v$session_wait where event = 'enqueue; where event = 'enqueue; SID SID ----240 240 EVENT EVENT ------------enqueue enqueue Ty Ty --TX TX mode mode ------4 4 P2 P3 P2 P3 ------- ---------- ---2686995 433 2686995 433
#.29
#.30
Enqueue : TX 4
SQL> select sid, type, id1, id2, lmode , request from v$lock where type in ('TX', 'TM'); SID ---------139 146 146 139 139 139 146 TY ID1 ID2 LMODE REQUEST -- ---------- ---------- ---------- ---------TX 327689 1901 0 4 TM 55166 0 3 0 TM 55168 0 2 0 TM 55166 0 3 0 TM 55168 0 2 0 TX 720914 168 6 0 TX 327689 1901 6 0
#.31
Enqueue : TX 4 - difficult
Difficult uses modifying different data ITL Unique Key Bitmap Index Rare Read only Tablespace Free Lists Two phase commit
Copyright 2006 Kyle Hailey
#.32
Enqueue : TX 4 ITL
Data Block Data Block Header Header ITL Transaction 1 Info Transaction 2 Info
Data
#.33
Enqueue : TX 4 ITL
Data Block Data Block Header Header Transaction 1 Transaction 2 Row 3 Row 2 Data Row 1 Transaction 3
#.34
Enqueue : TX 4 ITL
SQL> select sid, type, id1, id2, lmode , request SQL> select sid, type, id1, id2, lmode , request from v$lock where type in ('TX', 'TM'); from v$lock where type in ('TX', 'TM'); SID TY ID1 ID2 LMODE REQUEST SID TY ID1 ID2 LMODE REQUEST ---------- -- ---------- ---------- ---------- ------------------- -- ---------- ---------- ---------- ---------148 TX 148 TX 135 TM 135 TM 151 TM 151 TM 148 TM 148 TM 135 TX 135 TX 151 TX 151 TX 65559 65559 54557 54557 54557 54557 54557 54557 524312 524312 65559 65559 1284 1284 0 0 0 0 0 0 1592 1592 1284 1284 0 0 3 3 3 3 3 3 6 6 6 6 4 4 0 0 0 0 0 0 0 0 0 0
#.35
User 2
#.36
Session 1: Insert into Child ID=1 Session 2: Delete from Parent ID=2 : would require a FTS of child still not atomic, solution lock child Enqueue TX 4
Copyright 2006 Kyle Hailey
#.37
PK
#.38
ID
Session 1: Insert into Child ID=1 Session 2: Delete from Parent ID=2 OK can Copyright 2006 Kyle Haileyin the child index verify quickly
#.39
Enqueue : TX 4 V$session
select sid, row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#, lockwait from v$session;
SID ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# LOCKWAIT ----- ------------- -------------- --------------- ------------- -------135 -1 0 0 0 40B4EE1C 137 -1 0 0 0 138 -1 0 0 0 139 -1 0 0 0 140 -1 0 0 0 141 53651 3 53980 0
10g Lockwait not null is blocker Pre-10g Lockwait not null is the waiter
Copyright 2006 Kyle Hailey
#.40
#.41
Enqueue : ST
Space Transaction Lock Used in Dictionary Managed Tables Solution
Got
#.42
Enqueue : HW
Table
Header
Data
Enqueue : HW
select sid, select sid, event, event, chr(bitand(P1,-16777216)/16777215)|| chr(bitand(P1,-16777216)/16777215)|| chr(bitand(P1,16711680)/65535) as "Type", chr(bitand(P1,16711680)/65535) as "Type", mod(p1,16) as "mode" mod(p1,16) as "mode" from v$session_wait from v$session_wait where event = 'enqueue; where event = 'enqueue; SID SID ----240 240 EVENT EVENT ------------enqueue enqueue Ty Ty --HW HW mode P2 P3 mode P2 P3 ---- ---- ---------- ---- ------6 4 16777715 6 4 16777715
#.43
#.44
Enqueue : HW
Use Freelists
Cause
Pre-Allocate Extents
Alter
Hidden Parameter
bump_highwater_mark_count
ASSM