zoukankan      html  css  js  c++  java
  • library cache pin / lock

    编译过程或者package时候,只要去编译,就会有library cache pin 等待,说明有session在访问这个对象,查v$access :

    select b.sql_text text,a.sid sid ,a.serial# sria#,a.username username, c.type type,a.machine machine
    from v$session a ,v$sqltext b ,v$access c
    where c.object=upper('&1')
      and c.type in ('TABLE','PACKAGE','PROCEDURE')
      and a.sid=c.sid
      and b.address = a.sql_address
      and b.hash_value = a.sql_hash_value
    order by a.sid,a.serial#,b.piece;

    或者在v$session里查看该进程的final_blocking_session和final_blocking_instance定位锁住该进程的会话查看其在做什么,是否正常

    select a.sid,a.final_blocking_session,a.final_blocking_instance,a.event from v$session a where a.sid = <your_sid>;

    查看数据库中需要关注的等待事件:

    select sw.seq#,sw.sid||','||s.serial# sids,s.username,sw.event,sw.P1,sw.p2,sw.p3,sw.wait_time "WAIT",
       sw.state,sw.seconds_in_wait sec,s.status,to_char(s.logon_time,'dd/hh24:mi:ss') logon_time
       from v$session s,v$session_wait sw
       where
       sw.sid =s.sid
       and s.username is not null
       and sw.event not like '%SQL*Net%'
       and sw.event not like 'PX Deq%'
       and sw.event not like 'rdbms ipc message'
       order by sw.event,s.username ;

    如果系统中有大量library cache 等待,需要查出pin和lock的holder,然后杀掉.

    a.查找pin holder 并kill:
     
    select 'alter system kill session '''||a.sid||','||a.serial#||''';'
    from v$session a,x$kglpn b
    where a.saddr=b.kglpnuse  and b.KGLPNMOD<>0 and b.kglpnhdl in  (  select p1raw  from  v$session_wait  where event ='library cache pin');
    
    b.查找lock holder 并kill
     
    select 'alter system kill session '''||a.sid||','||a.serial#||''';'
     from v$session a, X$KGLLK b where  b.kgllkmod>0  and
     b.KGLLKHDL in  (  select p1raw  from  v$session_wait  where event ='library cache lock')
     and a.sid=b.KGLLKSNM   ;
    Priestess©版权所有,禁止转载
  • 相关阅读:
    最容易懂的红黑树
    Chapter 9 (排序)
    【WC2013】糖果公园
    【Luogu1903】数颜色
    【笔记】Sigmoid函数
    【笔记】费马小定理、数论欧拉定理
    【笔记】单层感知机
    2020ICPC.小米 网络选拔赛第一场
    【Luogu3366】模板:最小生成树
    Codeforces Raif Round 1
  • 原文地址:https://www.cnblogs.com/priestess-zhao/p/8267824.html
Copyright © 2011-2022 走看看