ITPub博客

首页 > 数据库 > Oracle > 一个library cache pin&&library cache lock故障排除经过

一个library cache pin&&library cache lock故障排除经过

原创 Oracle 作者:abstractcyj 时间:2017-10-18 23:23:25 0 删除 编辑
某个客户, 突然发生前端零售业务卡顿的情况。因为当时在处理其他客户的事宜, 所以当时没有进行monitor。由另外一位同事进行处理, 直接紧急重启了应用。
问题解决。但是业务不得已中断。
事后调查原因, 从卡顿的时间段来看发现大量的library cache pin等待事件,并且伴有library cache lock。

另外,同事也保存了阻塞相关的会话信息
create table block_sess1018 as
select *  from v$session where blocking_session is not null
结合
select * from dba_hist_active_sess_history h where h.sample_time > to_date('20171018 15:25:00', 'yyyymmdd hh24:mi:ss')
and  h.sample_time < to_date('20171018 16:00:00', 'yyyymmdd hh24:mi:ss') and event like 'library cache%'

library cache pin几个参数的意思:

p1=handle address
p2=pin address
p3=namespace&&encoded mode

对于p1raw可以对应于x$kglob中的KGLHDADR字段x$kglpn中的KGLPNHDL字段,x$kgllk中的KGLLKHDL字段,后边有sql关联。

dba_hist_active_sess_history中的P1可以转换成16进制之后,再去v$object_dependency通过to_address定位到pin的对象



以及参考:
http://www.pro-oracle.com/2014/10/oracle-database-resolving-library-cache.html

SQL> select  s.sid, s.saddr, sw.p1raw
     from v$session_wait sw, v$session s
     where sw.sid = s.sid and sw.event='library cache pin';

       SID SADDR            P1RAW
---------- ---------------- ----------------
        53 0000000077204A80 000000006DBC5BE8  

Now using the P1RAW and SADDR values find the the address of the user session that is holding the lock

SQL> select b.KGLLKUSE from dba_kgllock w , dba_kgllock b
     where w.KGLLKHDL  = b.KGLLKHDL
     and   w.KGLLKREQ  > 0 and b.KGLLKMOD > 0
     and   w.KGLLKTYPE = b.KGLLKTYPE
     and   w.KGLLKUSE  = '0000000077204A80' -- SADDR
     and   w.KGLLKHDL  = '000000006DBC5BE8' -- P1RAW

 select to_owner, to_name from v$object_dependency 
     where to_address = '000000016B500270';

select * from dba_ddl_locks where owner = 'HR';

找到了library cache pin的对象。

再进一步发现(通过logminer挖掘日志),故障开始前,有开发的同事对一个基础表进行了DDL操作,引发了其后一连串的编译的动作(有很多对象依赖于此表)。
很多对象,比如触发器(产品的逻辑很多是用触发器完成), 过程,函数,视图等依赖于此表。
由于此时正值业务高峰,所以出现了大面积的卡顿。

以下是DDL时间顺序




执行的DDL语句:











来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8520577/viewspace-2146138/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
曾从事java方向开发多年。近年已经转入数据库方向。主要擅长SQL优化,Oracle数据库问题诊断,Oracle备份与恢复等。服务于医药物流,医院等行业

注册时间:2010-01-26

  • 博文量
    602
  • 访问量
    1091585