WAITEVENT: "library cache pin" Reference Note (文档 ID 34579.1)

本文详细介绍了librarycachepin等待事件的定义、参数、等待时间、查找阻塞者的方法以及如何减少等待时间、解决已知错误的相关信息。重点探讨了在Oracle数据库中遇到此类等待事件时的诊断和解决策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

"library cache pin" Reference Note

This is a reference note for the wait event  "library cache pin" which includes the following subsections: See  Note:61998.1 for an introduction to Wait Events.

Definition:

  • Versions:7.0 - 11.1 Documentation: 11g 10.2
  • Library cache pins are used to manage library cache concurrency. Pinning an object causes the heaps to be loaded into memory (if not already loaded). PINS can be acquired in NULL, SHARE or EXCLUSIVE modes and can be considered like a special form of lock. A wait for a "library cache pin" implies some other session holds that PIN in an incompatible mode.

Individual Waits:

  Parameters:
  • Handle address
    Use  P1RAW rather than  P1
    This is the handle of the library cache object which the waiting session wants to acquire a pin on. 
    The actual object being waited on can be found using
      SELECT kglnaown "Owner", kglnaobj "Object"
        FROM x$kglob
       WHERE kglhdadr='&P1RAW'
      ;
  • Pin address
    Use  P2RAW rather than  P2
    This is the address of the PIN itself.
  • Encoded Mode & Namespace
    In Oracle 7.0 - 8.1.7 inclusive the value is  10 * Mode + Namespace
    In Oracle 9.0 - 11.1 inclusive the value is  100 * Mode + Namespace

    Where:

    Mode is the mode in which the pin is wanted. This is a number thus:
    • 2 - Share mode
    • 3 - Exclusive mode

    Namespace is just the namespace number of the namespace in the library cache in which the required object lives:
    • 0 SQL Area
    • 1 Table / Procedure / Function / Package Header
    • 2 Package Body
    • 3 Trigger
    • 4 Index
    • 5 Cluster
    • 6 Object
    • 7 Pipe
    • 13 Java Source
    • 14 Java Resource
    • 32 Java Data
  Wait Time:
The waiter waits up to 3 seconds (1 second if PMON) for the PIN to become available. If not available then the session waits again, incrementing  SEQ# in <<View:V$SESSION_WAIT>> .
  Finding Blockers:
The following SQL can be used to show the sessions which are holding and/or requesting pins on the object that given in  P1 in the wait:
  SELECT s.sid, kglpnmod "Mode", kglpnreq "Req"
    FROM x$kglpn p, v$session s
   WHERE p.kglpnuse=s.saddr
     AND kglpnhdl='&P1RAW'
  ;
An X request (3) will be blocked by any pins held S mode (2) on the object.
An S request (2) will be blocked by any X mode (3) pin held, or may queue behind some other X request.

Diagnosis of why there is a blocking scenario will usually need help from Oracle support. If you just want to clear the immediate issue then the SID information above should allow you to kill off any blocking sessions. Proper diagnosis will usually require you to collect 3 SYSTEMSTATE and/or HANGANALYZE dumps at 30 seconds intervals then submit these to Oracle support with full details of the sessions and objects involved. To take a SYSTEMSTATE or HANGANALYZE dump connect to the instance as a user withALTER SYSTEM privilege and issue the command:

  ALTER SESSION SET max_dump_file_size = UNLIMITED;
  ALTER SYSTEM SET EVENTS 'immediate trace name systemstate level 266';
This will produce a trace file under the DIAGNOSTIC_DEST in 11g, or in the USER_DUMP_DEST in earlier releases (or BACKGROUND_DUMP_DEST if connected to a shared server).
In a Parallel Server or RAC environments SYSTEMSTATE dumps should be taken 3 times on each node.

Systemwide Waits:

If "library cache pin" waits form a significant amount of the wait time then it is important to determine if this is one or two sessions waiting long periods of time or a more serious general contention issue among lots of processes.

Reducing Waits / Wait times:

What to do to reduce these waits depends heavily on what blocking scenario is occuring. A common problem scenario is the use of DYNAMIC SQL from within PLSQL procedure where the PLSQL code is recompiled and the DYNAMIC SQL calls something which depends on the calling procedure.

Known Bugs
You can restrict the list below to issues likely to affect one of the following versions by clicking the relevant button: 
                     


NBBugFixedDescription
 1385107811.2.0.3.BP07, 11.2.0.4, 12.1.0.1PQ hang for SQL using PLSQL function can deadlock (waits for a "library cache pin")
 1362498411.2.0.3.4, 11.2.0.3.BP10, 11.2.0.4, 12.1.0.1IMPDP or IMP hangs on compilation of PLSQL containing a pipelined function
 1241174611.2.0.3.BP16, 11.2.0.4, 12.1.0.1RAC waits for "library cache pin" do not time out (do not trigger ORA-4021)
 1013892911.2.0.3, 12.1.0.1ORA-600 [17069] in replication receiver / self deadlock on replication internal package
 932792911.2.0.2ORA-600 [kglLockOwnersListDelete] / DIRECTORY object waits using EXTERNAL tables
 661831211.1.0.7, 11.2.0.1Deadlock between ON COMMIT materialized view refresh and query rewrite (library cache pin V lock deadlock)
 647568811.1.0.7, 11.2.0.1Concurrent rewrite and on-commit refresh can deadlock (library cache pin <--> lock)
 664412210.2.0.5, 11.1.0.7ON COMMIT refresh deadlock (library cache pin V lock)
 560469810.2.0.4, 11.1.0.6Deadlock between 'library cache lock' and 'library cache pin' using replication
 722646310.2.0.5EXECUTE IMMEDIATE no releasing mutex or library cache pin
 37176199.2.0.6, 10.1.0.4, 10.2.0.1Deadlock/hang possible due to concurrent cursor loads referencing same INVALID trigger
 36051659.2.0.6, 10.1.0.4, 10.2.0.1Hang/deadlock between sessions concurrently loading a cursor with INVALID trigger
 337464010.1.0.3, 10.2.0.1Create local partitioned domain index can hang
 32537709.2.0.6, 10.1.0.3, 10.2.0.1ORA-4021 / "library cache pin" waits on RAC executing Java stored procedures
+29687099.2.0.5, 10.1.0.2High "library cache pin" waits possible
 33710039.2.0.6Logical standby apply hang (library cache pin waits)
 33529029.2.0.6Logical apply may hang (library cache pin)
  • '*' indicates that an alert exists for that issue.
  • '+' indicates a particularly notable issue / bug.
  • 'I' indicates an install issue / bug included for completeness.
  • 'P' indicates a port specific bug.
  • "OERI:xxxx" may be used as shorthand for ORA-600 [xxxx].

Related:

Tracing User sessions  Note:62160.1 
Shared Pool Tuning  Note:62143.1 

Important:

The above text makes reference to some  X$ views. These are only visible to the  SYS user and are not guaranteed to be available on all versions of Oracle. Customers are advised  NOT to have any application code or scripts which rely on any  X$ view.

 
 

相关内容

   
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值