11g等待事件之library cache: mutex X

作者: dbafree 日期: 2012 年 07 月 01 日发表评论 (0)查看评论
 

library cache: mutex X替代了之前的library cache latch,主要作用是在hash bucket中定位handle时使用。(比如SQL硬解析时,需要往hash bucket中新增一个cursor时,需要library cache latch)。如下图所示:

文档上面的解释如下:
The library cache mutex is acquired for similar purposes that the library cache latches were acquired in prior versions of Oracle. In 10g, mutexes were introduced for certain operations in the library cache. Starting with 11g, the library cache latches were replaced by mutexes, hence this new wait event.
Mutexes are a lighter-weight and more granular concurrency mechanism than latches. Mutexes take advantage of CPU architectures that offer the compare and swap instructions (or similar). The reason for obtaining a mutex in the first place, is to ensure that certain operations are properly managed for concurrency. E.g., if one session is changing a data structure in memory, then another session must wait to acquire the mutex before it can make a similar change – this prevents unintended changes that would lead to corruptions or crashes if not serialized.
This wait event is present whenever a library cache mutex is held in exclusive mode by a session and other sessions need to wait for it to be released. There are many different operations in the library cache that will require a mutex, so its important to recognize which “location” (in Oracle’s code) is involved in the wait. “Location” is useful to Oracle Support engineers for diagnosing the cause for this wait event.
Individual Waits:

Parameters:
P1 = “idn” = Unique Mutex Identifier
P2 = “value”
P3 = “where” = location in code (internal identifier) where mutex is being waited for
@The meaning of the code for “where” can be found by looking in kgl0.h for entries with the prefix “”kglml_XXX”. For example, if P3=2, then it corresponds to “kglml_kglget2″. You can then search source code for this symbol to see where the mutex is acquired.

测试一个硬解析的场景如下:

conn scott/tiger

create table testlib1 (id number) ;
create table testlib2 (id number) ;
create table testlib3 (id number) ;
create table testlib4 (id number) ;
create table testlib5 (id number) ;
create table testlib6 (id number) ;
create table testlib7 (id number) ;
create table testlib8 (id number) ;
create table testlib9 (id number) ;
create table testlib10 (id number) ;
create table testlib11 (id number) ;
create table testlib12 (id number) ;
create table testlib13 (id number) ;
create table testlib14 (id number) ;
create table testlib15 (id number) ;
create table testlib16 (id number) ;
create table testlib17 (id number) ;
create table testlib18 (id number) ;
create table testlib19 (id number) ;
create table testlib20 (id number) ; vi test4.sh #!/bin/ksh
i="$1"
while true
do
echo $i
sqlplus scott/tiger << EOF
select * from testlib$i where id = $RANDOM;
exit
EOF
done alter system flush shared_pool;
exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (); nohup sh test4.sh 1 &
nohup sh test4.sh 2 &
nohup sh test4.sh 3 &
nohup sh test4.sh 4 &
nohup sh test4.sh 5 &
nohup sh test4.sh 6 &
nohup sh test4.sh 7 &
nohup sh test4.sh 8 &
nohup sh test4.sh 9 &
nohup sh test4.sh 10 &
nohup sh test4.sh 11 &
nohup sh test4.sh 12 &
nohup sh test4.sh 13 &
nohup sh test4.sh 14 &
nohup sh test4.sh 15 &
nohup sh test4.sh 16 &
nohup sh test4.sh 17 &
nohup sh test4.sh 18 &
nohup sh test4.sh 19 &
nohup sh test4.sh 20 & exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();

生成awr report,查看等待事件:

Top 5 Timed Foreground Events
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Avg
wait % DB
Event Waits Time(s) (ms) time Wait Class
------------------------------ ------------ ----------- ------ ------ ----------
DB CPU 104 111.9
library cache: mutex X 1,920 3 1 2.9 Concurrenc
latch: shared pool 237 1 5 1.2 Concurrenc
latch: row cache objects 146 1 5 .9 Concurrenc
cursor: pin S wait on X 42 1 13 .6 Concurrenc
^LHost CPU (CPUs: 16 Cores: 8 Sockets: 2)
~~~~~~~~ Load Average
Begin End %User %System %WIO %Idle
--------- --------- --------- --------- --------- ---------
1.12 6.89 25.0 18.5 2.7 56.1

我们的hard parse

Load Profile              Per Second    Per Transaction   Per Exec   Per Call
~~~~~~~~~~~~ --------------- --------------- ---------- ----------
DB Time(s): 2.8 4.0 0.00 0.00
DB CPU(s): 3.1 4.5 0.00 0.00
Redo size: 31,740.9 46,051.8
Logical reads: 3,625.8 5,260.6
Block changes: 83.5 121.1
Physical reads: 0.2 0.4
Physical writes: 0.2 0.2
User calls: 2,719.4 3,945.5
Parses: 1,856.1 2,693.0
Hard parses: 137.4 199.4
W/A MB processed: 0.8 1.2
Logons: 129.7 188.1
Executes: 1,830.6 2,656.0
Rollbacks: 0.2 0.3
Transactions: 0.7

查了下metalink,与"library cache: mutex X"等待相关的BUG大约有30多个,会在11G各个版本之间发生,所以碰到这个等待事件,可以先确认下是不是碰上BUG了。以下两个BUG,在网上好象大家经常碰到,给出metalink相关的描述:

Bug 5928271 - Excessive waits on "library cache: mutex X" [ID 5928271.8]

Versions >= 11.1.0.6 but BELOW 11.2
This fix alleviates some waits on "library cache: mutex X" when looking
up a library cache object.

Bug 9530750 High waits for 'library cache: mutex X' for cursor Build lock
Versions BELOW 12.1
High waits may be seen for "library cache: mutex X" for
a build lock mutex with a call stack including kksGetBuildLock.

Rediscovery Notes:
The mutex is for an object with a name like "$BUILD$.xxxxxxxx"

参考:
metalink相关文章
《Oracle Wait Interface A Practical Guide to Performance Diagnostics & Tuning》
《Oracle Core_ Essential Internals for DBAs and Developers - Jonathan Lewis》http://blog.tanelpoder.com/2008/08/03/library-cache-latches-gone-in-oracle-11g/

11g等待事件之library cache: mutex X的更多相关文章

  1. [20190402]Library Cache mutex.txt

    [20190402]Library Cache mutex.txt 1.环境:SCOTT@book> @ ver1PORT_STRING                    VERSION   ...

  2. library cache: mutex X

    我们先来看看 library cache: mutex X . 是个什么东西 The library cache mutex is acquired for similar purposes that ...

  3. Troubleshooting 'library cache: mutex X' Waits. (Doc ID 1357946.1)

    In this Document   Purpose   Troubleshooting Steps   What is a 'library cache: mutex X' wait?   What ...

  4. Oracle数据库大量library cache: mutex X及latch: shared pool问题排查一例

    业务系统数据库夯住,数据库内大量的library cache: mutex X及latch: shared pool等待,alert日志信息如下 Tue Sep :: WARNING: inbound ...

  5. Troubleshooting 'library cache: mutex X' Waits.

    What is a 'library cache: mutex X' wait? The mutex feature is a mechanism to control access to in me ...

  6. Oracle中常见的33个等待事件小结

    在Oracle 10g中的等待事件有872个,11g中等待事件1116个. 我们可以通过v$event_name 视图来查看等待事件的相关信息     一. 等待事件的相关知识 1.1 等待事件主要可 ...

  7. ORACLE 常见等待事件

    一. 等待事件的相关知识 1.1 等待事件主要可以分为两类,即空闲(IDLE)等待事件和非空闲(NON-IDLE)等待事件.1). 空闲等待事件指ORACLE正等待某种工作,在诊断和优化数据库的时候, ...

  8. 全面解析Oracle等待事件的分类、发现及优化

    一.等待事件由来 大家可能有些奇怪,为什么说等待事件,先谈到了指标体系.其实,正是因为指标体系的发展,才导致等待事件的引入.总结一下,Oracle的指标体系,大致经历了下面三个阶段: · 以命中率为主 ...

  9. Oracle等待事件之等待事件详解

    一. 等待事件的相关知识:1.1 等待事件主要可以分为两类:即空闲(IDLE)等待事件和非空闲(NON-IDLE)等待事件.1). 空闲等待事件指ORACLE正等待某种工作,在诊断和优化数据库的时候, ...

随机推荐

  1. <转>lua解析脚本过程中的关键数据结构介绍

    在这一篇文章中我先来介绍一下lua解析一个脚本文件时要用到的一些关键的数据结构,为将来的一系列代码分析打下一个良好的基础.在整个过程中,比较重要的几个源码文件分别是:llex.h,lparse.h.l ...

  2. libev与libevent区别

    摘自stackflow的回答,主要从架构上说明了二者的区别: As for design philosophy, libev was created to improve on some of the ...

  3. Nginx Rewrite正则表达式案例

    前两天简单整理了下Nginx的URL Rewrite基本指令,今天谈谈Nginx Rewrite的location正则表达式. 1.Nginx Rewrite 基本标记(flags) last 相当于 ...

  4. 简单解决XP共享连接数10限制(转)

    1.建立一个txt文件,在里面输入以下文字:net session /delete /y,并将其保存为clear session.bat文件.net session用于查看本机共享的会话详细情况,可以 ...

  5. ceph-mon 代码解读

    一.概述: ceph-mon代码必备知识:Paxos算法,参见此处 数据结构分析: monitor代码结构:    

  6. Android tesseract-orc之扫描身份证号码

    踩了不少坑,终于把这个扫描版的身份证识别做出来了,图片识别引擎用的是tesseract,在已经训练好样本的情况下,感觉识别率还是一般般~ 下面说一说大概几个坑. 一. 编译tesseract-orc ...

  7. golang学习笔记 ---TCMalloc

    图解 TCMalloc 前言 TCMalloc 是 Google 开发的内存分配器,在不少项目中都有使用,例如在 Golang 中就使用了类似的算法进行内存分配.它具有现代化内存分配器的基本特征:对抗 ...

  8. JQuery EasyUI combobox 省市两级联动

    表名:province  结构如下 CallIn.tpl 模板页 <select id="consult_province" name="consult_provi ...

  9. Android 自定义漂亮的圆形进度条

    公司有这样一个需求,实现这个圆弧进度条 所以,现在就将它抽取出来分享 如果需要是圆帽的就将,下面这句代码放开即可 mRingPaint.setStrokeCap(Paint.Cap.ROUND);// ...

  10. ARGB和PARGB

    原文链接: http://blog.csdn.net/lnwaycool/article/details/8610313 ARGB和PARGB是针对32位图像而言的,Windows下图像可以是1位.4 ...