Oracle 10g Performance: chapter 09 enqueues

52
#.1 Enqueue Waits : Locks Enqueue Waits : Locks Kyle Hailey http://perfvision.com/ftp/ emea2010 [email protected]

description

 

Transcript of Oracle 10g Performance: chapter 09 enqueues

Page 1: Oracle 10g Performance: chapter 09 enqueues

#.1

Enqueue Waits : LocksEnqueue Waits : Locks

Kyle Hailey

http://perfvision.com/ftp/emea2010

[email protected]

Page 2: Oracle 10g Performance: chapter 09 enqueues

#.2Copyright 2006 Kyle Hailey

Locks Covered in this SectionLocks Covered in this Section

Part I : Intro Lock Name(type) and Mode Finding waiter and blocker Finding Object

Part II : User TM – table modification TX – Transaction locks UL – user lock

Part III : Internal CI – Cross Instance HW – High Water RO – Reusable Object

Page 3: Oracle 10g Performance: chapter 09 enqueues

#.3Copyright 2006 Kyle Hailey

Part I : IntroPart I : Intro

To Solve we need:

1.1.WaiterWaiter2.2.BlockerBlocker3.3.Lock TypeLock Type

type type modemode

4.4.Object blocking onObject blocking on

Missing : blocking SQL Possibly with log miner

Page 4: Oracle 10g Performance: chapter 09 enqueues

#.4Copyright 2006 Kyle Hailey

Solving – Data SourcesSolving – Data Sources

V$active_session_history

or

In “real time” can also usev$lock v$session (v$session_wait) dba_blockers dba_waiters ?/rdbms/admin/utllockt.sqlhttp://www.evdbt.com/enqwaits.sql

Page 5: Oracle 10g Performance: chapter 09 enqueues

#.5Copyright 2006 Kyle Hailey

v$active_session_historyv$active_session_history

Waiter SESSION_ID SESSION_SERIAL# USER_ID

Object CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK#

SQL Waiting

SQL_IDBlocker

BLOCKING_SESSION BLOCKING_SESSION_STATUS BLOCKING_SESSION_SERIAL#

Lock Type and ModeEvent = Type (name)P1 = Type | Mode

Fields in ASH for lock analysis and solution:

Missing: SQL Blocking not reliably possible, Maybe by dumping REDO

Page 6: Oracle 10g Performance: chapter 09 enqueues

#.6

Lock Name and ModeLock Name and ModeSelect parameter1 from v$event_name where name=‘enqueue’;

Copyright 2006 Kyle Hailey

Parameter1---------- Name|mode

P1 P1RAW---------- --------1415053318 54580006

Select p1, p1raw from v$session where event like 'enq%';

Mode: 0006Name: 5458

Hex Decimal ASCII54 = 84 = “T”58 = 88 = “X”

Lock = TX 6

Page 7: Oracle 10g Performance: chapter 09 enqueues

#.7

Type and ModeType and Mode

SELECT

chr(bitand(p1,-16777216)/16777215)|| chr(bitand(p1, 16711680)/65535) Type, mod(p1,16) lmodefrom v$session_wait where event=‘enqueue’;

TY LMODE-- ----------TX 6

SELECT

chr(bitand(p1,-16777216)/16777215)|| chr(bitand(p1, 16711680)/65535) Type, mod(p1,16) lmodefrom v$session_wait where event=‘enqueue’;

TY LMODE-- ----------TX 6

Page 8: Oracle 10g Performance: chapter 09 enqueues

#.8Copyright 2006 Kyle Hailey

Lock Names (types)Lock Names (types)

9i One Wait : “enqueue”

10g 208 enqueue waitsSpecific to each type of enqueue

enq: HW - contention enq: HW - contention ConfigurationConfigurationenq: SQ - contention enq: SQ - contention ConfigurationConfigurationenq: SS - contention enq: SS - contention ConfigurationConfigurationenq: ST - contention enq: ST - contention

ConfigurationConfigurationenq: TM - contention enq: TM - contention Application Application enq: TW - contention enq: TW - contention

AdministrativeAdministrativeenq: TX - allocate ITL entry enq: TX - allocate ITL entry

ConfigurationConfigurationenq: TX - index contention enq: TX - index contention ConcurrencyConcurrencyenq: TX - row lock contention enq: TX - row lock contention ApplicationApplicationenq: TX – contention enq: TX – contention ApplicationApplication

Page 9: Oracle 10g Performance: chapter 09 enqueues

#.9Copyright 2006 Kyle Hailey

Lock ModesLock Modes

# Type Name

--- ------- ---------------------------

1 Null Null

2 SS Sub share

3 SX Sub exclusive

4 S Share

5 SSX Share/sub exclusive

6 X Exclusive

Page 10: Oracle 10g Performance: chapter 09 enqueues

#.10Copyright 2006 Kyle Hailey

P1 = name | modeP1 = name | mode

P1 (parameter1) same for all locksselect distinct parameter1 from v$event_name select distinct parameter1 from v$event_name

where name like 'enq:%'where name like 'enq:%'

selectselect event, event, mod(p1,16) as "mode"mod(p1,16) as "mode" from v$active_session_historyfrom v$active_session_history where event like 'enq:%‘;where event like 'enq:%‘;

EVENT modeEVENT mode

----------------------------- --------------------------------- ----

enq: TX - allocate ITL entry 4enq: TX - allocate ITL entry 4enq: TX - row lock contention 6enq: TX - row lock contention 6enq: TX - row lock contention 4enq: TX - row lock contention 4

PARAMETER1PARAMETER1

--------------------

name|modename|mode

Page 11: Oracle 10g Performance: chapter 09 enqueues

#.11Copyright 2006 Kyle Hailey

OEM 10g OEM 10g

if P1 = 1415053318

then mode = 6Then it is a data block row lock

Page 12: Oracle 10g Performance: chapter 09 enqueues

#.12

Querying ASH Querying ASH

Copyright 2006 Kyle Hailey

select substr(event,0,20) lock_name, ash.session_id waiter, mod(ash.p1,16) lmode, ash.p2 p2, ash.p3 p3, o.object_name object, o.object_type otype, CURRENT_FILE# filen, CURRENT_BLOCK# blockn, ash.SQL_ID waiting_sql, BLOCKING_SESSION blocker --,ash.xidfrom v$active_session_history ash, all_objects owhere event like 'enq: %' and o.object_id (+)= ash.CURRENT_OBJ#/

Page 13: Oracle 10g Performance: chapter 09 enqueues

#.13

Part II : User LocksPart II : User Locks

TX – Transaction LockMode 6: Modifying same rowMode 4: several reasons

TM – Table ModificationMode 4: Unindexed Foreign Key

UL – User Lock

Copyright 2006 Kyle Hailey

Page 14: Oracle 10g Performance: chapter 09 enqueues

#.14Copyright 2006 Kyle Hailey

TX LockTX Lock

update toto set name = ‘SMITH’ where id = 1;

update toto set name = ‘SMITH’ where id = 1;

Undo Undo SegmentSegment

Session aSession a

Data Block Data Block HeaderHeader

Transaction 1Transaction 1

Data Block Data Block HeaderHeader

Row 1Row 1

Table TotoTable Toto

Undo Undo SegmentSegmentHeaderHeader

Session BSession B

update toto set name = ‘ADAMS’ where id = 1;

update toto set name = ‘ADAMS’ where id = 1;

Wait for TxWait for TxTo commitTo commit

Delete from toto where id = 2;

Delete from toto where id = 2;Delete from toto where id = 9;

Delete from toto where id = 9;

Page 15: Oracle 10g Performance: chapter 09 enqueues

#.15Copyright 2006 Kyle Hailey

Transaction Locks (TX)Transaction Locks (TX)

TX = Transaction = Wait on UNDO Mode 6 (exclusive)

modification of a row lockMode 4 (share)

Index block spiltUnique Index Key enforcementForeign key enforcement ITL space waitsBitmap chunk conflictsAlter tablespace … read only;Free Lists slot waitsPossible with two phase commit

Page 16: Oracle 10g Performance: chapter 09 enqueues

#.16Copyright 2006 Kyle Hailey

Transaction Locks (TX)Transaction Locks (TX)

Mode 4, new Events:

1.enq: TX - allocate ITL entry Wait on an ITL slot

2.enq: TX - index contention Index block split

3.enq: TX - row lock contention1. Mode 6 – classic row lock2. Mode 4 - pk violation, fk violation, bitmap chunk

wait4.enq: TX – contention

Wait for a data file extension, Alter tbs read only

Page 17: Oracle 10g Performance: chapter 09 enqueues

#.17Copyright 2006 Kyle Hailey

enq: TX - row lock contentionenq: TX - row lock contention

User 1

SQL> delete from toto where id = 1;

User 2

SQL> delete from toto where id =1;

Mode 6, row in data block

TableTableValueValueIDID

foofoo11

Page 18: Oracle 10g Performance: chapter 09 enqueues

#.18Copyright 2006 Kyle Hailey

enq: TX - row lock contentionenq: TX - row lock contention

if P1 = 1415053318

then mode = 6Then it is a data block row lock

Page 19: Oracle 10g Performance: chapter 09 enqueues

#.19Copyright 2006 Kyle Hailey

TX – Mode 4TX – Mode 4

if P1 = 1415053316

then mode = 4Not same data but conflicts

Page 20: Oracle 10g Performance: chapter 09 enqueues

#.20

enq: TX - row lock contentionenq: TX - row lock contention

Mode 4, happens for 3 reasons

1. Unique key contention

2. Foreign Key contention

3. Bitmap index contention

(others?)

Copyright 2006 Kyle Hailey

Page 21: Oracle 10g Performance: chapter 09 enqueues

#.21Copyright 2006 Kyle Hailey

1.1. enq: TX - row lock contentionenq: TX - row lock contention

User 1

create table p(n number);

create unique index p_i on p(n);insert into p values(2);

User 2

insert into p values(2);

Mode 4 , unique index

TableTable

IDID ValueValueIDID

PKPK

2 ? 2 ? 2 ? 2 ? 22

Page 22: Oracle 10g Performance: chapter 09 enqueues

#.22Copyright 2006 Kyle Hailey

2.2. enq: TX - row lock contentionenq: TX - row lock contention

User 1create table parent ( id number primary key); create table child ( id number references parent, name varchar2(20)); insert into parent values (2);

User 2

insert into child values (2,88);

Mode 4, foreign key

ParentParent ChildChildIDID IDID NameNameValueValueIDID

PKPK

2 ? 2 ? 2 ? 2 ? 2 2

Page 23: Oracle 10g Performance: chapter 09 enqueues

#.23Copyright 2006 Kyle Hailey

3.3. enq: TX - row lock contentionenq: TX - row lock contention

Mode 4 Bitmaps are compressed Changes to the same bitmap cause locks

ValueValue Start Start RowidRowid

EndEndRowidRowid

Bitmap Bitmap

11 000.000.0000000.000.0000

000.000.000000.000.000

01010000111000011100001100 01010000111000011100001100 22

000.000.0000000.000.0000

000.000.000000.000.000

01010000111000011100001100 01010000111000011100001100

Page 24: Oracle 10g Performance: chapter 09 enqueues

#.24Copyright 2006 Kyle Hailey

3.3. enq: TX - row lock contentionenq: TX - row lock contention

update t1 set update t1 set n1 = 2n1 = 2 where n2 = 13;where n2 = 13;

update t1 set update t1 set n1 = 2n1 = 2 where n2 = 13;where n2 = 13;

Session 2Session 2

Different rows but Different rows but same key value same key value

create table t1 (create table t1 (n1n1 number(4),number(4),n2n2 number(4));number(4));

insert into t1insert into t1 select 1, rownumselect 1, rownum from all_objectsfrom all_objects where rownum <= 400;where rownum <= 400;commit;commit;create bitmap index i1 on t1(n1);create bitmap index i1 on t1(n1);

create table t1 (create table t1 (n1n1 number(4),number(4),n2n2 number(4));number(4));

insert into t1insert into t1 select 1, rownumselect 1, rownum from all_objectsfrom all_objects where rownum <= 400;where rownum <= 400;commit;commit;create bitmap index i1 on t1(n1);create bitmap index i1 on t1(n1);

update t1 set update t1 set n1 = 2n1 = 2 where n2 = 12;where n2 = 12;

update t1 set update t1 set n1 = 2n1 = 2 where n2 = 12;where n2 = 12;

Session 1Session 1

Page 25: Oracle 10g Performance: chapter 09 enqueues

#.25Copyright 2006 Kyle Hailey

3.3. enq: TX - row lock contentionenq: TX - row lock contention

Bitmaps are compressed Changes to the same bitmap chunk cause

locksValueValue Start Start

RowidRowidEndEndRowidRowid

Bitmap Bitmap

11 200.0200.0

204.7204.7

01010000111000011100001100 01010000111000011100001100 11

205.0205.0 210.3210.3

01010000111000011100001100 01010000111000011100001100 22

200.0200.0 205.6205.6

01010000111000011100001100 01010000111000011100001100

blockblock rowrow

Page 26: Oracle 10g Performance: chapter 09 enqueues

#.26Copyright 2006 Kyle Hailey

ValueValue Start Start RowidRowid

EndEndRowidRowid

Bitmap Bitmap

11 200.0200.0

204.7204.7

01010000111000011100001100 01010000111000011100001100 22

205.0205.0 210.3210.3

01010000111000011100001100 01010000111000011100001100 33

200.0200.0 205.6205.6

01010000111000011100001100 01010000111000011100001100

3.3. enq: TX - row lock contentionenq: TX - row lock contention

Session 1Session 1 Session 2Session 2

Update id=12 Update id=12 set value 2set value 2

Update id=13Update id=13set value 2set value 2

Page 27: Oracle 10g Performance: chapter 09 enqueues

#.27

Summary: TX 4 from ASHSummary: TX 4 from ASH

uniq index

ST EVENT SID LM P2 P3 OBJ OTYPE FN BLOCKN SQL_ID BSID

----- ---------------------- --- --- ------ ---- ----- ----- --- ------ --

10:39 enq: TX - row lock c 141 4 655406 6672 -1 0 0 bjvx94vnxtxgv 158

10:39 enq: TX - row lock c 141 4 655406 6672 -1 0 0 bjvx94vnxtxgv 158

10:39 enq: TX - row lock c 141 4 655406 6672 -1 0 0 bjvx94vnxtxgv 158

10:39 enq: TX - row lock c 141 4 655406 6672 -1 0 0 bjvx94vnxtxgv 158

FK (10.2.0.3)

ST EVENT SID LM P2 P3 OBJ OTYPE FN BLOCKN SQL_ID BSID

----- ---------------------- --- --- ------ ---- ----- ----- --- ------ --

10:41 enq: TX - row lock c 144 4 179681 7074 CHILD TABLE 1 60954 ahm7c9rupbz9r 1

10:41 enq: TX - row lock c 144 4 179681 7074 CHILD TABLE 1 60954 ahm7c9rupbz9r 1

10:41 enq: TX - row lock c 144 4 179681 7074 CHILD TABLE 1 60954 ahm7c9rupbz9r 1

bitmap

ST EVENT SID LM P2 P3 OBJ OTYPE FN BLOCKN SQL_ID BSID

----- ---------------------- --- --- ------ ---- ----- ----- --- ------ --

10:41 enq: TX - row lock c 143 4 966081 4598 I1 INDEX 0 0 azav296xxqcjx 144

10:41 enq: TX - row lock c 143 4 966081 4598 I1 INDEX 0 0 azav296xxqcjx 144

10:41 enq: TX - row lock c 143 4 966081 4598 I1 INDEX 0 0 azav296xxqcjx 144

10:41 enq: TX - row lock c 143 4 966081 4598 I1 INDEX 0 0 azav296xxqcjx 144

Copyright 2006 Kyle Hailey

Page 28: Oracle 10g Performance: chapter 09 enqueues

#.28Copyright 2006 Kyle Hailey

enq: TX - allocate ITL entryenq: TX - allocate ITL entry

Data Block Data Block HeaderHeader

ITLITL

DataData

Data Block Data Block HeaderHeader

Transaction 1 InfoTransaction 1 Info

Transaction 2 InfoTransaction 2 Info

Page 29: Oracle 10g Performance: chapter 09 enqueues

#.29Copyright 2006 Kyle Hailey

enq: TX - allocate ITL entryenq: TX - allocate ITL entry

Data Block Data Block HeaderHeader

Transaction 1Transaction 1

DataData

Data Block Data Block HeaderHeader

Transaction 2Transaction 2

Row 1Row 1Row 2Row 2Row 3Row 3

Transaction 3Transaction 3

Page 30: Oracle 10g Performance: chapter 09 enqueues

#.30Copyright 2006 Kyle Hailey

enq: TX - allocate ITL entryenq: TX - allocate ITL entry

create table itl ( id number, data varchar2(20) ) pctfree 0 initrans 1 ; insert into itl select rownum,'a' from all_objects where rownum < 2000; commit;

session 1: update itl set data=data where id=1; session 2: update itl set data=data where id=2; session 3: update itl set data=data where id=3; session 4: update itl set data=data where id=4; session 5: update itl set data=data where id=5;

create table itl ( id number, data varchar2(20) ) pctfree 0 initrans 1 ; insert into itl select rownum,'a' from all_objects where rownum < 2000; commit;

session 1: update itl set data=data where id=1; session 2: update itl set data=data where id=2; session 3: update itl set data=data where id=3; session 4: update itl set data=data where id=4; session 5: update itl set data=data where id=5;

Page 31: Oracle 10g Performance: chapter 09 enqueues

#.31Copyright 2006 Kyle Hailey

enq: TX - contentionenq: TX - contention

1. Altering tablespace read only with open transactionExample Session 1 – start transaction, don’t commit Session 2 – alter tablespace read only

2. Data File Extension – waiter waiting for another session to extend file

3. Index Block Split – waiter waiting for another session to split the block

Page 32: Oracle 10g Performance: chapter 09 enqueues

#.32Copyright 2006 Kyle Hailey

TX Further InvestigationTX Further Investigation

EVENT SQL_ID OBJ FILE# BLOCK#EVENT SQL_ID OBJ FILE# BLOCK#

------------------------------ ------------- --------- --- ------------------------------------ ------------- --------- --- ------

enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586enq: TX - row lock contention bjvx94vnxtxgv 53363 FOO 1 123586enq: TX - row lock contention bjvx94vnxtxgv 53363 FOO 1 123586enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586enq: TX - row lock contention bjvx94vnxtxgv 53363 FOO 1 123586enq: TX - row lock contention bjvx94vnxtxgv 53363 FOO 1 123586enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586

select event, sql_id,select event, sql_id, CURRENT_OBJ# || ' ' || name objCURRENT_OBJ# || ' ' || name obj ,CURRENT_FILE# file#,CURRENT_FILE# file# ,CURRENT_BLOCK# block#,CURRENT_BLOCK# block# from v$active_session_history ash,from v$active_session_history ash, obj$ oobj$ o wherewhere event like 'enq: TX%'event like 'enq: TX%' and o.obj# (+)= ash.current_obj#and o.obj# (+)= ash.current_obj# order by sample_timeorder by sample_time

Page 33: Oracle 10g Performance: chapter 09 enqueues

#.33Copyright 2006 Kyle Hailey

TX Further InvestigationTX Further Investigation

V$active_session_history :V$active_session_history : BLOCKING_SESSIONBLOCKING_SESSION BLOCKING_SESSION_STATUSBLOCKING_SESSION_STATUS BLOCKING_SESSION_SERIAL#BLOCKING_SESSION_SERIAL#

Who is the blocker:Who is the blocker:

No Guarentee of finding blocker SQL No Guarentee of finding blocker SQL

Page 34: Oracle 10g Performance: chapter 09 enqueues

#.34Copyright 2006 Kyle Hailey

enq: TM - contentionenq: TM - contention

TX locks have a corresponding TM lock TM locks the structure from change

LOCK Parmeter1 Parmeter2(ID1) Parameter3(ID2)------- --------- ------------- --------------- enq: TM name|mode object # table/partition

LOCK Parmeter1 Parmeter2(ID1) Parameter3(ID2)------- --------- ------------- --------------- enq: TM name|mode object # table/partition

Parameter1 = object id

Page 35: Oracle 10g Performance: chapter 09 enqueues

#.35Copyright 2006 Kyle Hailey

enq: TM - contentionenq: TM - contention

User 1create table parent ( id number primary key); create table child ( id number references parent, name varchar2(20)); insert into parent values (1); insert into parent values (2); commit;

delete from parent where id=2;

User 2

insert into child values (1,2);

Exclusive Row Level Lock

Page 36: Oracle 10g Performance: chapter 09 enqueues

#.36Copyright 2006 Kyle Hailey

enq: TM - contentionenq: TM - contention

ParentParent ChildChild

IDID IDID NameNameValueValueIDID

PKPK

Delete from Parent where ID=2 :Delete from Parent where ID=2 :

11 11 11

Insert into Child ID=1Insert into Child ID=1

Enqueue TM 4 Enqueue TM 4

Session 2 doesn’t know the value Session 1 insertedSession 2 doesn’t know the value Session 1 insertedSession 2 only knows there is an outstanding changeSession 2 only knows there is an outstanding change

XX XX

Session 1Session 1

Session 2Session 2

22 22

Page 37: Oracle 10g Performance: chapter 09 enqueues

#.37Copyright 2006 Kyle Hailey

enq: TM – contention Solutionenq: TM – contention Solution

ParentParent ChildChild

IDID IDID NameNameValueValueIDID

PKPK

Session 1: Insert into Child ID=1Session 1: Insert into Child ID=1

Session 2: Delete from Parent ID=2Session 2: Delete from Parent ID=2OK – can verify quickly in the child indexOK – can verify quickly in the child index

IDID

IndexIndex

Foreign KeyForeign Key

112211

Page 38: Oracle 10g Performance: chapter 09 enqueues

#.38Copyright 2006 Kyle Hailey

TM Further InvestigationTM Further Investigation

EVENT SQL_ID mode OBJEVENT SQL_ID mode OBJ

------------------------------ ------------- ---- --------------------------------------------- ------------- ---- ---------------

enq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILDenq: TM - contention 8zw36yw3fq4yy 4 53372 CHILD

selectselect event,event, sql_id,sql_id, mod(p1,16) as "mode",mod(p1,16) as "mode", p2|| ' ' || o.name objp2|| ' ' || o.name obj from v$active_session_history ash,from v$active_session_history ash, obj$ oobj$ o wherewhere event like 'enq: TM%'event like 'enq: TM%' and o.obj# (+)= ash.p2and o.obj# (+)= ash.p2 order by sample_time;order by sample_time;

Page 39: Oracle 10g Performance: chapter 09 enqueues

#.39Copyright 2006 Kyle Hailey

UL LocksUL Locks

User-defined Locksdbms_lock

Wait Event Parameter2Parameter3

enq: UL - contention id 0

dbms_lock.allocate_unique(v_lockname, v_lockhandle);dbms_lock.allocate_unique(v_lockname, v_lockhandle);dbms_lock.request(v_lockhandle, p_ltype);dbms_lock.request(v_lockhandle, p_ltype);dbms_lock.release(v_lockhandle);dbms_lock.release(v_lockhandle);

Page 40: Oracle 10g Performance: chapter 09 enqueues

#.40Copyright 2006 Kyle Hailey

Internal LocksInternal Locks

CI – Cross Instance HW – High Water KO – fast object checkpoint RO – Reuse Object SQ – Sequence Lock ST – Space Transaction

Page 41: Oracle 10g Performance: chapter 09 enqueues

#.41Copyright 2006 Kyle Hailey

enq: CI - contention enq: CI - contention

Cross Instance not OPS lock. invoke actions in background processes

checkpoints log switches instance is shut down

Page 42: Oracle 10g Performance: chapter 09 enqueues

#.42Copyright 2006 Kyle Hailey

CI – Cross InstanceCI – Cross Instance

Id2 Meaning (parameter3)1 Pass in Parameters2 Invoke the call in background process3 Foreground has not returned yet4 Used to allocate the CI call5 Used to queue up interested clients

Id2 Meaning (parameter3)1 Pass in Parameters2 Invoke the call in background process3 Foreground has not returned yet4 Used to allocate the CI call5 Used to queue up interested clients

Id1 Meaning (parameter2)0 Flush buffers for reuse as new class1 LGWR checkpointing and Hot Backup2 DBWR synchronization of SGA with control file3 Log file add/drop/rename notification4 Write buffer for CR read5 Test Call6 Invalidate KCK cache in all instances7 Alter rollback segment optimal8 Signal Query Servers/coordinator9 Create Remote Parallel Query Server10 Set Global Partitions11 Stop Disk Writes12 Drop Sort Segments13 Release unused space from Sort Segments14 Instance Recovery for Parallel operation Group15 Validate parallel slave Lock Value16 Check Transaction State Objects

Id1 Meaning (parameter2)0 Flush buffers for reuse as new class1 LGWR checkpointing and Hot Backup2 DBWR synchronization of SGA with control file3 Log file add/drop/rename notification4 Write buffer for CR read5 Test Call6 Invalidate KCK cache in all instances7 Alter rollback segment optimal8 Signal Query Servers/coordinator9 Create Remote Parallel Query Server10 Set Global Partitions11 Stop Disk Writes12 Drop Sort Segments13 Release unused space from Sort Segments14 Instance Recovery for Parallel operation Group15 Validate parallel slave Lock Value16 Check Transaction State Objects

Page 43: Oracle 10g Performance: chapter 09 enqueues

#.43Copyright 2006 Kyle Hailey

CI LocksCI Locks

selectselect substr(sql_text,0,20) sql_text,substr(sql_text,0,20) sql_text, p2,p3,p2,p3, CURRENT_OBJ# || ' ' || name objCURRENT_OBJ# || ' ' || name obj ,CURRENT_FILE# file#,CURRENT_FILE# file# ,CURRENT_BLOCK# block#,CURRENT_BLOCK# block# from v$active_session_history ash,from v$active_session_history ash, obj$ o,obj$ o, v$sqltext sqlv$sqltext sql wherewhere event like 'enq: CI%'event like 'enq: CI%' and o.obj# (+)= ash.current_obj#and o.obj# (+)= ash.current_obj# and sql.sql_id (+)= ash.sql_idand sql.sql_id (+)= ash.sql_id order by sample_time;order by sample_time;

SQL_TEXT P2 P3 OBJ FILE# BLOCK#SQL_TEXT P2 P3 OBJ FILE# BLOCK#

-------------------- ----- ------- ------------ ------ --------------------------- ----- ------- ------------ ------ -------

INSERT INTO TOTO1 VA 1 5 54225 TOTO1 6 682721INSERT INTO TOTO1 VA 1 5 54225 TOTO1 6 682721

Page 44: Oracle 10g Performance: chapter 09 enqueues

#.44Copyright 2006 Kyle Hailey

CI LocksCI Locks

SQL_TEXT P2 P3---------------------------------------- --- --alter table XXXXX drop partition YYYYY 1 5

P2 = 1 " LGWR checkpointing and Hot Backup "

P3 = 5. "Used to queue up interested clients"

SQL_TEXT P2 P3---------------------------------------- --- --alter table XXXXX drop partition YYYYY 1 5

P2 = 1 " LGWR checkpointing and Hot Backup "

P3 = 5. "Used to queue up interested clients"

If p2=1 and p3=5, then contention on blocks beingIf p2=1 and p3=5, then contention on blocks being

checkpointed, try raising fast_start_mttr_targetcheckpointed, try raising fast_start_mttr_target

alter system set fast_start_mttr_target=600 scope=both;alter system set fast_start_mttr_target=600 scope=both;

Page 45: Oracle 10g Performance: chapter 09 enqueues

#.45Copyright 2006 Kyle Hailey

enq: HW - contentionenq: HW - contention

DataData

EmptyEmptyHigh Water MarkHigh Water Mark

HeaderHeader

TableTable

Wait Event Parameter2 Parameter3enq: HW - contention table space # block

Session 1Session 1

Session 2Session 2

Session 3Session 3

Page 46: Oracle 10g Performance: chapter 09 enqueues

#.46Copyright 2006 Kyle Hailey

HWHW

Use Freelists Cause a jump in High Water Mark by freelists *

_bump_highwater_mark_count

Hidden Parameter _bump_highwater_mark_count alter session set "_bump_highwater_mark_count"=100;

Not supported

ASSM Automatic segment space management

Page 47: Oracle 10g Performance: chapter 09 enqueues

#.47Copyright 2006 Kyle Hailey

HW Further InvestigationHW Further Investigation

EVENT SQL_ID OBJ FILE# BLOCK#EVENT SQL_ID OBJ FILE# BLOCK#

-------------------- ------------- ----------- ----- -------------------------- ------------- ----------- ----- ------

enq: HW - contention 49ch3jfkncnsp 53410 T1_I1 13 29734enq: HW - contention 49ch3jfkncnsp 53410 T1_I1 13 29734

selectselect event,event, sql_id,sql_id, CURRENT_OBJ# || ' ' || name objCURRENT_OBJ# || ' ' || name obj ,CURRENT_FILE# file#,CURRENT_FILE# file# ,CURRENT_BLOCK# block#,CURRENT_BLOCK# block# from v$active_session_history ash,from v$active_session_history ash, obj$ oobj$ o wherewhere event like 'enq: HW%'event like 'enq: HW%' and o.obj# (+)= ash.current_obj#and o.obj# (+)= ash.current_obj#

order by sample_timeorder by sample_time;;

Page 48: Oracle 10g Performance: chapter 09 enqueues

#.48Copyright 2006 Kyle Hailey

enq: KO - fast object checkpointenq: KO - fast object checkpoint

Used when checking the cache for blocks from a table for PQO direct read

Page 49: Oracle 10g Performance: chapter 09 enqueues

#.49

enq: RO - fast object reuseenq: RO - fast object reuse

Drop or Truncate a tableWait for DBWR to clean cache

SolutionTune DBWR using smaller MTTRUse GTTTruncate/drop less often

Page 50: Oracle 10g Performance: chapter 09 enqueues

#.50Copyright 2006 Kyle Hailey

Other ResourcesOther Resources

@?/rdbms/admin/utllockt@?/rdbms/admin/utllockt

WAITING_SESSION LOCK_TYPE MODE_REQUESTED MODE_HELD LOCK_ID1 LOCK_ID2WAITING_SESSION LOCK_TYPE MODE_REQUESTED MODE_HELD LOCK_ID1 LOCK_ID2

--------------- ----------- -------------- --------- --------- ----------------------- ----------- -------------- --------- --------- --------

144 None144 None

139 Transaction Share Exclusive 131113 7507139 Transaction Share Exclusive 131113 7507

Page 51: Oracle 10g Performance: chapter 09 enqueues

#.51Copyright 2006 Kyle Hailey

Blocking SessionsBlocking Sessions

Page 52: Oracle 10g Performance: chapter 09 enqueues

#.52Copyright 2006 Kyle Hailey

Summary : Internal LocksSummary : Internal Locks

CI – Cross Instance HW – High Water

Look at object and SQL use ASSM, freelists, pre-allocate extents

KO – fast object checkpoint PQO

RO – reusable object Reduce cache, tune DBWR, use GTT

SQ – Sequence Lock logon/logoff problem

ST - Space Transaction only one per database used for space allocations uet, fet Find object use LMT