Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
99 views

SRS Library Cache Locks Report: Service Response Guide

This document discusses library cache locks in Oracle databases. It contains the following key points: 1. The library cache contains objects like tables, indexes, and PL/SQL packages required to parse and execute SQL statements. Library cache locks protect these object definitions during parsing and execution. 2. There are three types of library cache waits: load lock, which loads an object; lock, which controls concurrency between clients; and pin, which manages concurrency by loading object heaps into memory. 3. Potential causes of library cache lock contention include gathering schema statistics, database events, materialized view compiles, purge jobs, and explicit DDL. Scripts and queries are provided to detect the cause.

Uploaded by

shaikali1980
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views

SRS Library Cache Locks Report: Service Response Guide

This document discusses library cache locks in Oracle databases. It contains the following key points: 1. The library cache contains objects like tables, indexes, and PL/SQL packages required to parse and execute SQL statements. Library cache locks protect these object definitions during parsing and execution. 2. There are three types of library cache waits: load lock, which loads an object; lock, which controls concurrency between clients; and pin, which manages concurrency by loading object heaps into memory. 3. Potential causes of library cache lock contention include gathering schema statistics, database events, materialized view compiles, purge jobs, and explicit DDL. Scripts and queries are provided to detect the cause.

Uploaded by

shaikali1980
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

..

..
..
..
..

Service Response Guide

SRS Library Cache


. . . . . . . . . .
Locks Report

Library Cache Locks

OHSMON
Prepared by Akhlaq Qureshi Reference Note :417122.1

Library Cache Locks


Shared pool contains two types of structures which are as follows

Static structures which are allocated at the startup and


Dynamic structures which are allocated at runtime, Library cache forms a part
of dynamic structures. 

Library Cache Contains objects of various types required to parse and execute SQL
statements which includes tables, indexes, Pl/Sql packages and cursors. Library cache
pins and the associated row cache enqueue locks protect object definitions for the
duration of parse and execute calls.

Description

When a database object (table, view, procedure, function, package, package body, trigger,
index, cluster, synonym) is referenced during parsing or compiling of a SQL
(DML/DDL) or PL/SQL statement, the process parsing or compiling the statement
acquires the library cache lock in the correct mode. In Oracle8 the lock is held only until
the parse or compilation completes (for the duration of the parse call).

The three Oracle wait events for Library Cache are:

 Library Cache load lock


 Library Cache lock
 Library Cache Pin
Library cache load lock

The session tries to find the load lock for the database object so that it can load the object.
The load lock is always obtained in Exclusive mode, so that no other process can load the
same object. If the load lock is busy the session will wait on this event until the lock
becomes available.
Library cache lock
This event controls the concurrency between clients of the library cache. Library cache
locks are heavily used, in particular by applications using PL/SQL or Advanced

2
..
..
..
.
Queuing.  In ..many applications executing SQL units such as cursors, triggers, packages -
a good example of which is the Oracle E-Business Suite - a lot of time may be spent
waiting for library cache locks, mainly on tables and procedures, e.g. a package or
procedure has to be recompiled. For instance, recompiling a package body will acquire
several LB locks in share mode, but an LC lock in exclusive mode; recompiling the
whole package will also acquire LB locks in exclusive mode. Share mode library cache
locks are needed mainly during parse calls, to protect the objects on which the cursor
being parsed depends.
Library cache pin

This event manages library cache concurrency. Pinning an object causes the heaps to be
loaded into memory. If a client wants to modify or examine the object, the client must
acquire a pin after the lock.

Cause

Few possible causes are:

 "Gather Schema Statistics" concurrent request causing "library cache load" and
"library cache pin" events
 Database EVENT 10235 level>2 can cause contention/waits for the Library
Cache (which is used to get a dump of the system stack for debugging
 When a materialized view is compiled causing a DDL for the underlying object
 Purge obsolete workflow runtime data
 Explicit DDL on the database objects by concurrent requests

Methods and SQL scripts to detect above causes:

Step 1:  L1 Run the libcache.pl Script to gather initial diagnostics.
Perl libcache.pl
Step 2 : L1 Refer the queries listed in appendix A in case the script doesn’t work
Step 3 : L1 Decides or takes the call based upon the result of the above two steps else
XFR the Tar to L2.
Step 4 : L2  Use the below queries for further analysis. The output of these queries can
be combined with traditional session details, sqltext, and wait event queries if required
for further analysis.
Run the Identifying the Waiting and the Holding sessions.
i)
select /*+ ordered */ w1.sid waiting_session,

3
h1.sid holding_session,
w.kgllktype lock_or_pin,
w.kgllkhdl address,
decode(h.kgllkmod, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive',
'Unknown') mode_held,
decode(w.kgllkreq, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive',
'Unknown') mode_requested
from sys.dba_kgllock w, sys.dba_kgllock h, v$session w1, v$session h1
where
(((h.kgllkmod != 0) and (h.kgllkmod != 1)
and ((h.kgllkreq = 0) or (h.kgllkreq = 1)))
and
(((w.kgllkmod = 0) or (w.kgllkmod= 1))
and ((w.kgllkreq != 0) and (w.kgllkreq != 1))))
and w.kgllktype = h.kgllktype
and w.kgllkhdl = h.kgllkhdl
and w.kgllkuse = w1.saddr
and h.kgllkuse = h1.saddr
/

WAITING_SESSION HOLDING_SESSION LOCK ADDRESS MODE_HELD MODE_REQU


--------------- --------------- ---- -------- --------- --------- 
              270                                211                Lock   68FB7DCC     Exclusive              Share
              265                                211                Lock   68FB7DCC     Exclusive              Share
              255                                211                Lock   68FB7DCC     Exclusive              Share   

select sid Holder ,KGLPNUSE Sesion , KGLPNMOD Held, KGLPNREQ Req


from x$kglpn , v$session
where KGLPNHDL in (select p1raw from v$session_wait
where wait_time=0 and event like '%library cache%')
and KGLPNMOD <> 0
and v$session.saddr=x$kglpn.kglpnuse ;

         
Finding the Details about the Holding session.
ii)
col kgllkmod heading "lockmode"
col kgllkreq heading "reqmode"
col kglnaobj heading "objname"
select ses.sid, ses.serial#,lck.* from x$kgllk lck , v$session ses
where kgllkhdl in
(select kgllkhdl from x$kgllk where kgllkreq >0)
and lck.KGLLKUSE = ses.saddr

4
..
..
..
..
.
Order by lck.KGLNAOBJ
/
Sample output of the above query:
SID SERIAL# ADDR INDX INST_ID KGLLKADR KGLLKUSE KGLLKSES
---------- ---------- -------- ---------- ---------- -------- -------- --------
KGLLKSNM KGLLKHDL KGLLKPNC KGLLKPNS KGLLKCNT lockmode reqmode
---------- -------- -------- -------- ---------- ---------- ----------
KGLLKFLG KGLLKSPN KGLLKHTB KGLNAHSH KGLHDPAR KGLHDNSP
---------- ---------- -------- ---------- -------- ----------
USER_NAME
------------------------------
objname
------------------------------------------------------------
211 4481         0CA118F0 67778 1 7F104E18 57CC0128 57CC0128
211 68FB7DCC 00 00 0 0 3
0 722124 6CDDDF58 803564214 68FB7DCC 10

SID SERIAL# ADDR INDX INST_ID KGLLKADR KGLLKUSE KGLLKSES


---------- ---------- -------- ---------- ---------- -------- -------- --------
KGLLKSNM KGLLKHDL KGLLKPNC KGLLKPNS KGLLKCNT lockmode reqmode
---------- -------- -------- -------- ---------- ---------- ----------
KGLLKFLG KGLLKSPN KGLLKHTB KGLNAHSH KGLHDPAR KGLHDNSP
---------- ---------- -------- ---------- -------- ----------
USER_NAME
------------------------------
objname
------------------------------------------------------------
APPS
FND_CP_GSM_IPC_AQ

 
We thus have the SID, SERIAL# and the Instance number along with the object name
which is being locked.
Depending upon the criticality of the object in use we can take the decision either by
asking for the CRT or involving the L3.
Alter system kill session '211,4481';
The above query would give us all the required information in resolving the Library
Cache Lock.

Some more information to troubleshoot in case of holders belonging to any of these


components.

For materialized view,

select object_name,timestamp,last_ddl_time from dba_objects


where object_type='MATERIALIZED VIEW'
and to_date(last_ddl_time, ‘dd-mon-rr’) = to_date(sysdate,’dd-mon-rr’);

For Gather Schema Statistics,

5
Login into Oracle Applications as SYSADMIN user  click on the Responsibility 
select System Administrator  Requests  Views  select Specific Requests  in
the “Name” column enter “%Gather%”  click on Find button.

For Database event 10235,

In SQLPLUS, login as sysdba and type “show parameter event” for the EVENT
10235. If the event is not required, comment the “EVENT 10235” entry in init<SID>.ora
file.

For Purge obsolete workflow runtime data,

Login into Oracle Applications as SYSADMIN user  click on the Responsibility 


select System Administrator  Requests  Views  select Specific Requests  in the
“Name” column enter “%Purge%”  click on Find button.

For Explicit DDL,

Login into Oracle Applications as SYSADMIN user  click on the Responsibility 


select System Administrator  Requests  Views  select Specific Requests  in the
“Name” column enter “%Compile%”  click on Find button.

Repeat the above Explicit DDL search by replacing “%Compile%” with the following
ones: “%Create%”, “%Alter%”, and “%Drop%”

From the tar statistics the alert is believed to exist for about 10 – 15 minutes and tar being
auto closed.

Note: Entry on the alert log file -- "WAITING FOR ROWCACHE ENQUEUE
LOCK!!!" has shown signs to cause disruption to application response.

Queries to be used when libcache.pl scripts doesn’t work

Appendix A
1. Script shows the Library cache resource types

PROMPT waited for over the life of the instance


set linesize 152
column average_wait format 9999990.00

6
..
..
..
..
select
. substr(e.event, 1, 40) event,
e.time_waited,
e.time_waited / decode(
e.event,
'latch free', e.total_waits,
decode(e.total_waits - e.total_timeouts,0, 1,e.total_waits - e.total_timeouts)
) average_wait
from sys.v$system_event e,
sys.v$instance i
where e.event like 'library cache%';

2. Script shows sessions waiting for a Library Cache Locks


select sid Waiter, p1raw,
substr(rawtohex(p1),1,30) Handle,
substr(rawtohex(p2),1,30) Pin_addr
from v$session_wait where wait_time=0 and event like 'library cache%';

3. Script shows Objects locked by Library Cache based on sessions detected above

select to_char(SESSION_ID,'999') sid ,


substr(LOCK_TYPE,1,30) Type,
substr(lock_id1,1,23) Object_Name,
substr(mode_held,1,4) HELD, substr(mode_requested,1,4) REQ,
lock_id2 Lock_addr
from dba_lock_internal
where
mode_requested<>'None'
and mode_requested<>mode_held
and session_id in ( select sid
from v$session_wait where wait_time=0
and event like 'library cache%') ;

4. Script shows Library Cache holders that sessions are waiting for

select sid Holder ,KGLPNUSE Sesion , KGLPNMOD Held, KGLPNREQ Req


from x$kglpn , v$session
where KGLPNHDL in (select p1raw from v$session_wait
where wait_time=0 and event like 'library cache%')
and KGLPNMOD <> 0
and v$session.saddr=x$kglpn.kglpnuse ;

5. Script shows What are the holders waiting for?

select sid,substr(event,1,30),wait_time
from v$session_wait
where sid in (select sid from x$kglpn , v$session
where KGLPNHDL in (select p1raw from v$session_wait
where wait_time=0 and event like 'library cache%')
and KGLPNMOD <> 0
and v$session.saddr=x$kglpn.kglpnuse );

7
-- end --

You might also like