Library Cache Lock的解决

记一次Library Cache: Lock故障处理 Library Cache: Lock在his系统出现的一次case 阅读详情
昨晚业务系统导入资料并重建索引时一个会话突然停滞不前,用TOAD一看,一直在等待Library Cache Lock。TOAD、OEM中都看不到此锁,会话每三秒启动一次,但每次都是等待这个锁。显然,这和数据字典有关,应该是一个索引的数据字典中的记录被锁住了,导致无法重建。可是杀光了其他ACTIVE的会话,问题仍然没有得到解决,看来是某一个被杀死的会话持有该锁,而会话尚未回滚完全,进程仍然吊死着。现在的问题就是找这个会话了。
首先想到的文档就是 Oracle9i Database Reference了,找到附录A,说明如下:

This event controls the concurrency between clients of the library cache. It acquires a lock on the object handle so that either:

One client can prevent other clients from accessing the same object

The client can maintain a dependency for a long time (for example, no other client can change the object)

This lock is also obtained to locate an object in the library cache.

Wait Time: 3 seconds (1 second for PMON)

Parameters:

handle address

Address of the object being loaded

lock address

Address of the load lock being used. This is not the same thing as a latch or an enqueue, it is a State Object.

mode

Indicates the data pieces of the object which need to be loaded

namespace

See "namespace"


几乎等于什么都没说,不过lock address应该会有点用处。
转而上网搜索解决方案,终于找到一篇metalink上的文档:
Doc ID:
Note:122793.1
Subject:  HOW TO FIND THE SESSION HOLDING A LIBRARY CACHE LOCK
Type:  BULLETIN
Status:  PUBLISHED
 Content Type:  TEXT/PLAIN
Creation Date:  23-OCT-2000
Last Revision Date:  17-JUL-2002

PURPOSE
-------
 
 In some situations it may happen your session is 'hanging' and is awaiting for 
 a 'Library cache lock'. This document describes how to find the session that 
 in fact has the lock you are waiting for.
 
 
SCOPE & APPLICATION
-------------------
 
Support analysts, dba's, ..
 
 
HOW TO FIND THE SESSION HOLDING A A LIBRARY CACHE LOCK
------------------------------------------------------
 
 Common situations:
 
 * a DML operation that is hanging because the table which is accessed is currently 
   undergoing changes (ALTER TABLE). This may take quite a long time depending on 
   the size of the table and the type of the modification 
   (e.g. ALTER TABLE x MODIFY (col1 CHAR(200) on thousands of records). 
 
* The compilation of package will hang on Library Cache Lock and Library Cache Pin 
  if some users are executing any Procedure/Function defined in the same package. 
 
 In the first situation the V$LOCK view will show that the session doing the 
 'ALTER TABLE' has an exclusive DML enqueue lock on the table object (LMODE=6, 
 TYPE=TM and ID1 is the OBJECT_ID of the table). The waiting session however does 
 not show up in V$LOCK yet so in an environment with a lot of concurrent sessions 
 the V$LOCK information is insufficient to track down the culprit blocking your 
 operation.
 
METHOD 1: SYSTEMSTATE ANALYSIS
------------------------------
 
 One way of finding the session blocking you is to analyze the system state dump.
 Using the systemstate event one can create a tracefile containing detailed 
 information on every Oracle process. This information includes all the resources
 held & requested by a specific process.
 
 Whilst an operation is hanging, open a new session and launch the following
 statement:
 
 ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME SYSTEMSTATE LEVEL 8';
 
 Oracle will now create a systemstate tracefile in your USER_DUMP_DEST directory.
 Get the PID (ProcessID) of the 'hanging' session from the V$PROCESS by matching 
 PADDR from V$SESSION with ADDR from V$PROCESS:
 
 SELECT PID FROM V$PROCESS WHERE ADDR=
        (SELECT PADDR FROM V$SESSION WHERE SID=sid_of_hanging_session);
 
 The systemstate dump contains a separate section with information for each 
 process. Open the tracefile and do a search for 'PROCESS pid_from_select_stmt'.
 In the process section look up the wait event by doing a search on 'waiting for'.
 
 Example output:
 
 PROCESS 8:
   ----------------------------------------
   SO: 50050b08, type: 1, owner: 0, flag: INIT/-/-/0x00
   (process) Oracle pid=8, calls cur/top: 5007bf6c/5007bf6c, flag: (0) -
             int error: 0, call error: 0, sess error: 0, txn error 0
   (post info) last post received: 82 0 4
               last post received-location: kslpsr
               last process to post me: 5004ff08 1 2
               last post sent: 0 0 13
               last post sent-location: ksasnd
               last process posted by me: 5004ff08 1 2
     (latch info) wait_event=0 bits=0
     Process Group: DEFAULT, pseudo proc: 50058ac4
     O/S info: user: daemon, term: pts/1, ospid: 15161
     OSD pid info: 15161
     ----------------------------------------
     SO: 5005f294, type: 3, owner: 50050b08, flag: INIT/-/-/0x00
     (session) trans: 0, creator: 50050b08, flag: (41) USR/- BSY/-/-/-/-/-
               DID: 0001-0008-00000002, short-term DID: 0000-0000-00000000
               txn branch: 0
               oct: 6, prv: 0, user: 41/LC
     O/S info: user: daemon, term: pts/1, ospid: 15160, machine: goblin.forgotten.realms
               program: sqlplus@goblin.forgotten.realms (TNS V1-V3)
     application name: SQL*Plus, hash value=3669949024
     waiting for 'library cache lock' blocking sess=0x0 seq=253 wait_time=0
!>>              handle address=5023ef9c, lock address=5019cad4, 10*mode+namespace=15
 
 Using the 'handle address' you can look up the process that is keeping a lock
 on your resource by doing a search on the address within the same tracefile.
 
 Example output: 
 
 PROCESS 9:
   ----------------------------------------
   SO: 50050e08, type: 1, owner: 0, flag: INIT/-/-/0x00
   (process) Oracle pid=9, calls cur/top: 5007bbac/5007bbfc, flag: (0) -
             int error: 0, call error: 0, sess error: 0, txn error 0
 
   <cut> ....
  
        ----------------------------------------
         SO: 5019d5e4, type: 34, owner: 5015f65c, flag: INIT/-/-/0x00
!>>      LIBRARY OBJECT PIN: pin=5019d5e4 handle=5023ef9c mode=X lock=0
         user=5005fad4 session=5005fad4 count=1 mask=0511 savepoint=118218 flags=[00]
  
 From the output we can see that the Oracle process with PID 9 has an exclusive
 lock on the object we are trying to access. Using V$PROCESS and V$SESSION we can
 retrieve the sid,user,terminal,program,... for this process. The actual statement
 that was launched by this session is also listed in the tracefile (statements and
 other library cache objects are preceded by 'name=').
 
 
METHOD 2: EXAMINE THE X$KGLLK TABLE
-----------------------------------
 
 The X$KGLLK table (accessible only as SYS/INTERNAL) contains all the 
 library object locks (both held & requested) for all sessions and
 is more complete than the V$LOCK view although the column names don't
 always reveal their meaning.
 
 You can examine the locks requested (and held) by the waiting session 
 by looking up the session address (SADDR) in V$SESSION and doing the 
 following select:
 
 select * from x$kgllk where KGLLKSES = 'saddr_from_v$session'
 
 This will show you all the library locks held by this session where
 KGLNAOBJ contains the first 80 characters of the name of the object.
 The value in KGLLKHDL corresponds with the 'handle address' of the
 object in METHOD 1.
 
 You will see that at least one lock for the session has KGLLKREQ > 0 
 which means this is a REQUEST for a lock (thus, the session is waiting). 
 If we now match the KGLLKHDL with the handles of other sessions in 
 X$KGLLK that should give us the address of the blocking session since
 KGLLKREQ=0 for this session, meaning it HAS the lock.
 
 SELECT * FROM X$KGLLK LOCK_A 
 WHERE KGLLKREQ = 0
   AND EXISTS (SELECT LOCK_B.KGLLKHDL FROM X$KGLLK LOCK_B
               WHERE KGLLKSES = 'saddr_from_v$session' /* BLOCKED SESSION */
               AND LOCK_A.KGLLKHDL = LOCK_B.KGLLKHDL
               AND KGLLKREQ > 0);
 
 If we look a bit further we can then again match KGLLKSES with SADDR 
 in v$session to find further information on the blocking session:
 
 SELECT SID,USERNAME,TERMINAL,PROGRAM FROM V$SESSION
 WHERE SADDR in 
  (SELECT KGLLKSES FROM X$KGLLK LOCK_A 
   WHERE KGLLKREQ = 0
     AND EXISTS (SELECT LOCK_B.KGLLKHDL FROM X$KGLLK LOCK_B
                 WHERE KGLLKSES = 'saddr_from_v$session' /* BLOCKED SESSION */
                 AND LOCK_A.KGLLKHDL = LOCK_B.KGLLKHDL
                 AND KGLLKREQ > 0)
  );

 
 In the same way we can also find all the blocked sessions:
 
 SELECT SID,USERNAME,TERMINAL,PROGRAM FROM V$SESSION
 WHERE SADDR in 
  (SELECT KGLLKSES FROM X$KGLLK LOCK_A 
   WHERE KGLLKREQ > 0
     AND EXISTS (SELECT LOCK_B.KGLLKHDL FROM X$KGLLK LOCK_B
                 WHERE KGLLKSES = 'saddr_from_v$session' /* BLOCKING SESSION */
                 AND LOCK_A.KGLLKHDL = LOCK_B.KGLLKHDL
                 AND KGLLKREQ = 0)
  );
 
 
RELATED DOCUMENTS
-----------------
 
[NOTE:1020008.6] SCRIPT FULLY DECODED LOCKING SCRIPT 
[NOTE:1054939.6] COMPILATION OF PACKAGE IS HANGING ON LIBRARY CACHE LOCK 
.
开头说了半天废话,后面给出了两个解决方案,进行事件跟踪或者查询X$KGLLK表,还是后者容易一点。搜寻半天,终于问到sysdna登录的方法(权限低,没密码)。第一次用X$表,用sysdba手还有点发抖(那可是正式的业务系统),敲入命令发现运行了很久才反应,找出一个SID了,仔细一看,居然是一个后台维护终端,程序是TOAD,状态INACTIVE。询问相关人员,从未ALTER该表,看来是TOAD看表结构或者数据的时候出了问题,kill掉终于正常,索引很快建完。只是INACTIVE的会话居然也持有锁,真是奇怪。工具太好了,也是双刃剑啊。

oracle 11g 多次业务用户被锁定 library cache lock导致数据hang住问题解决 现象:生产库业务用户多次被锁定,锁定后伴有library cache lock问题 应急措施: 1、查询library cache lock等待事件的blocking_session,考虑这些blocking_session对应的sid为业务机器连到数据库等待验证的错误密码的session,通过查询v$session查询业务机器是哪台,让开发人员排查程序; 2、通过kill -9杀掉操作系统 阅读详情

相关推荐

Library Cache Lock的7种常见成因与解决方案:一份Oracle DBA必知的避坑指南

本文深入解析Oracle数据库中的Library Cache Lock等待事件,提供7种常见成因的诊断与解决方案。从硬解析风暴到共享池容量危机,再到DDL操作和编译冲突,帮助DBA有效预防和解决Library Cache Lock问题,提升数据库性能。

weixin_29290259的博客 545

分析库缓存锁问题

另外一种是找到了匹配的父游标但未找到匹配的子游标,此时Oracle也会从头开始解析该目标SQL,新生成一个子游标,并把这个子游标挂在对应的父游标下。通过AWR,ASH报告,定位到SQL,找到代码,发现调用这个SQL特别频繁,而且数据量巨大,虽然通过SQL的执行计划看到SQL都走了索引,代码中看到SQL语句有一部分不是通过?软解析是指Oracle在执行目标SQL时,在Library Cache中找到了匹配的父游标和子游标,并将存储在子游标中的解析树和执行计划直接拿过来重用而无须从头开始解析的过程。

MRX001的博客 1235

银河麒麟V10离线安装VLC播放器:依赖处理与3.0.9.2版本实操指南

在国产化操作系统日益普及的背景下,软件安装方式成为政企内网用户关注的重点。离线安装作为一种不依赖公网源的部署手段,常用于解决内网环境下的软件获取问题。其核心在于理解Linux包管理机制,如dpkg与apt对依赖关系的处理逻辑。掌握这一原理,不仅能应对多媒体软件的部署,也能提升系统维护效率。VLC作为跨平台多媒体播放器,凭借强大的解码能力与协议支持,广泛应用于本地视频播放、RTSP拉流及监控大屏等场景。本文从离线安装的通用概念出发,结合银河麒麟V10桌面版的实际环境,详细梳理了VLC 3.0.9.2离线包的获

weixin_32247165的博客 408

Library cache lock/pin详解

Library cache lock/pin 一、概述 ---本文是网络资料加metalink 等整理得来 一个实例中的library cache包括了不同类型对象的描述,如:游标,索引,表,视图,过程,等等. 这些对象不能在他们被使用的时候改变,他们在被使用的时候会被一种library locks and pins的机制锁住. 一个会话中,需要使用一个对象,会在该对象上先得到一个libra

xiaofan23z的专栏 9692

嵌入式Linux Qt/QML开发实战:从Buildroot配置到应用部署

本文详细介绍了嵌入式Linux Qt/QML开发全流程,从Buildroot系统配置、交叉编译工具链搭建到应用部署与调试。以RK3506开发板为例,提供实战指南,帮助开发者高效完成嵌入式应用开发,解决常见环境配置与性能优化问题。

m2n3o4p5的博客 232

Comsol有限元网格剖分实战:从基础操作到高效仿真技巧

本文系统介绍了COMSOL有限元网格剖分的核心实战技巧。从基础的物理场控制与用户控制网格选择,到三角形、四边形、四面体等网格单元类型的适用场景,再到扫掠网格、边界层网格与复制网格等高效剖分方法,最后讲解了网格质量评估与几何预处理的关键步骤。旨在帮助用户掌握从自动到手动、从基础到高效的网格剖分艺术,实现仿真精度与计算效率的最佳平衡。

j7k8l的博客 383

Toad for Oracle查看锁表和解锁被锁住的表

发现自己还真是会忘事,明明看过一遍,如何查看锁表和解锁表,而且同事虎哥也教过,结果还是忘记。 索性记下来吧。这篇博文真的很水,还有本来就进行的很慢的学习计划又莫名推迟,书放在家里,工作今天还是蛮快。下午到现在也算是浪费了。 不瞎叨逼叨了。正题上来。 1:Database->Monitor->Session Browser 会出现下图界面,点击locks会出现被锁的表 2:在上图界

lindiwo的博客 1万+

别再手动测接口了!用Pytest+Requests+Allure搭建你的第一个自动化框架(附完整源码)

本文详细介绍了如何使用Pytest+Requests+Allure搭建Python接口自动化测试框架,涵盖环境准备、核心组件封装、测试用例设计、报告生成及CI/CD集成等关键步骤。通过实战案例和完整源码,帮助开发者快速构建高效的接口自动化测试解决方案,提升测试效率和质量。

weixin_42546508的博客 324

oracle11g之v$libcache_locks处理library cache lock及library cache pin

/****oracle11g之v$libcache_locks解决library cache lock及library cache pin的等待者及持锁者*******/ /******持锁会话*************/SQ...

313

系统安装、qt配置、安装pcie驱动

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 安装Linux系统指定:ununtu20.04并配置相关软件环境 前言 提示:这里可以添加本文要记录的大概内容: ununtu20.04、Qt 5.9.0、pcie驱动 提示:以下是本篇文章正文内容,下面案例可供参考 一、安装系统 制作系统盘(win10),在开机时按相应键进入BIOS,(华硕需要先改配置启动->CSM->开启->第一个选项选第一个或第二个),等待即可 进入后按照https://www.sysgeek.

weixin_44832804的博客 2212

手把手教你驱动6脚三位一体数码管:从引脚分析到C语言扫描代码实战

本文详细解析了如何逆向工程并驱动6脚三位一体数码管的全过程,从引脚分析到C语言扫描代码实战。通过系统化的测试和优化,作者总结出一套高效的驱动架构和调试方法,适用于工业设备中的非标准数码管应用。

weixin_42632434的博客 216

library cache lock 的解决案例

 下午,业务人员报告,执行任何和zzss03201281cs_no表有关的操作都会hang住,包括desc zzss03201281cs_no,也会hang在那里第一感觉是锁了,于是,我看看锁SQL> select * from v$lock where block=1;no rows selectedSQL> SQL> select * from gv$lock where bl

lunar的小铺 2572

构建AI Agent驱动的智能健康管理系统

数据碎片化:健康数据分散在不同的设备和平台中,难以统一管理和分析。个性化不足:健康管理方案通常是通用的,难以根据个人的健康状况实时调整。用户参与度低:用户难以获得及时、个性化的健康建议,导致健康管理效果不佳。AI Agent是一个能够感知环境、采取行动以实现目标的智能实体。根据智能体的智能水平,可以分为简单反应式智能体和复杂适应式智能体。实时监测健康数据。获取个性化的健康建议。收到健康风险预警。

AI天才研究院 753

Oracle Library Cache Lock 解决思路

Oracle Library Cache Lock 解决思路 标签: librarycacheoraclesessionobjectnull http://blog.csdn.net/tianlesoftware/article/details/7956996 2012-09-07 23:26 21566人阅读 评论(3) 收藏 举报 分类:

u010719917的专栏 577

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Library cache lock等待事件及解决

今天在性能测试环境上建索引很慢,发现是长时间等待Library cache lock。记得以前遇到过类似现象,当时是频繁插入导致表上的触发器不能被删除,观察到的也是library cache lock。所以这次让测试人员把应用停...

ctpaknc9526的博客 1111

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Oracle Library Cache Lock 解决思路

一.  Library Cache Lock    Library cacheHandle 里保存了lock 和 pin 的信息。而且在Library cache handle 和child cursor 上都有lock 和pin。它们称为library cache lock和library cache pin。 Library cachelock/pin是用来控制对librarycache ob

David Dai -- Focus on Oracle 5万+

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

library cache lock解决方法

今天上午,运维告知在创建一个表的时候hang住。出现问题前操作是,在通过dblink来迁移表的时候,由于时间等待太长,所以ctl+c终止掉该操作。后续在进行创建该表的时候就一直hang在那里。 SQL&gt...

537

彻底搞清楚library cache lock的成因和解决方法

问题描述:接到应用人员的报告,说是在任何对表CSNOZ629926699966的操作都会hang,包括desc CSNOZ629926699966,例如:[@more@]ora9i@cs_dc02:/ora9i > sql...

csdn6538954的博客 505

定位Library Cache pin,Library Cache lock等待的解决方法

这个星期一我去客户巡检时,客户告知我们派综系统数据库在前面几个月 日志中有时会出现很多Waited too long for library cache load lock错误 因为当时不在现场,所以无法确定是由什么引...

cucanqi9387的博客 115

Library cache lock 故障解决一例

今天收到同事电话,说是数据库中一张名为acct_balance进行操作是奇慢,第一反映是不是扫行计划有问题,结果我错了,现将过程记录下来。 用pl/sql连上数据库情况:1、对acct_balance表的查询很慢,正常少于0.1s完成,现在要60s完成;2、使用explain plan对语句进行分析,过析比正常情况下慢很多。 下面为处理过程:1、从v$session_wait中查找有问题的wa...

weixin_30532837的博客 170

[Oracle]--Library cache lock 故障解决一例 oracle10g

今天收到同事电话,说是数据库中一张名为acct_balance进行操作是奇慢,第一反映是不是扫行计划有问题,结果我错了,现将过程记录下来。 用pl/sql连上数据库情况:1、对acct_balance表的查询很慢,正常少于0.1s完成,现在要60s完成;2、使用explain plan对语句进行分析,过析比正常情况下慢很多。 下面为处理过程: 1、从v$session_wait中查找有问题的

N 885

oracle library cache lock,彻底搞清楚library cache lock的成因和解决方法

问题描述:接到应用人员的报告,说是在任何对表CSNOZ629926699966的操作都会hang,包括desc CSNOZ629926699966,例如:> sqlplusSQL*Plus: Release 9.2.0.4.0 - Production on Mon Jan 10 10:11:06 2005Copyright (c) 1982, 2002, Oracle Corporatio...

weixin_39629352的博客 1325

彻底搞清楚library cache lock的成因和解决方法(三)

前面我们已经知道碰到library cache lock导致进程hang时,如何解决。那么如何避免这类问题的发生呢?这篇文章主要介绍了library cache lock的成因以及如何避免。当我们在执行一些DML,DDL,甚至desc tablename等等操作的时候,会话就hang住了,还有一种情况,当我们使用create or replace procedure/function等

lunar的小铺 2551
上一篇: 路在何方
下一篇: 广东省外文书店
ern
ern
博客等级 码龄24年 25粉丝 115原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址