暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle Mutex 等待事件

eygle 2017-08-30
509


welcome to enmoedu



1

Oracle Mutex 等待事件之: cursor pin S

pin S 等待事件说明,当一个会话(session)试图去更新一个共享的 Mutex Pin,同时已经有其他会话正在更新(updating)同一个 Shared Mutex Pin。注意,Pin S 的Mutex位于子游标上,是动态创建的,无法从等待事件中获得,但是可以在竞争出现的情况下,通过观察 x$mutex_sleep_history 来获得。

文档说明如下:



2

Oracle Mutex 等待事件之: cursor pin X

在 Oracle 官方文档,关于 cursor pin X 等待事件的说明是:

A session waits on this event when it is requesting an exclusive mutex pin for a cursor object and it must wait because the resource is busy. The mutex pin for a cursor object can be busy either because a session is already holding it exclusive, or there are one or more sessions which are holding shared mutex pin(s). The exclusive waiter must wait until all holders of the pin for that cursor object have released it, before it can be granted. Wait Time:Microseconds

翻译过来就是:

当一个会话对一个 cursor 对象请求 排他模式的 Mutex pin 时,因为该对象已有 X 或者 S 模式的 Mutex pin 存在,所以必须处于等待。直至所有 X 或 S 模式的 pin 被释放后,才能够获得 X pin。

cursor pin X 等待有三个参数,第一个参数就是 cursor 的 hash value。


文档说明如下:


需要对 Cursor 执行 Pin X 的操作包括:


会话在某些串行化操作时需要获得 X 模式的 Pin,例如构建一个子游标;

在Cursor 上执行排他操作,如 dbms_shared_pool.purge, keep/unkeep 等;

一个或多个进程正在reference 该Mutex (shared mutex pin)



3

Oracle Mutex 等待事件之: cursor: mutex S

Cursor: Mutex S 等待事件是指,一个会话以共享模式请求一个Mutex,而其他会话以排他模式正在持有Cursor 上的 Mutex。



从文档说明可以看到,此处的Mutex是位于 Cursor 对象上的固有 Mutex,也就是针对 Parent Cursor 的。这个等待的第一个参数会披露出 SQL 的 Hash Value。



4

Oracle Mutex 等待事件之: cursor mutex X

Cursor Mutex X 是当会话对某个 Cursor 请求排他模式锁,但是该Cursor 上已经有 S 或 X 模式的锁定,因而产生的等待。



需要持有 Cursor Mutex X 的操作主要有:

在父游标下创建新的子游标,但是这类操作在11.2之后被 Build Lock 替代,不再需要;

捕获SQL中的绑定变量;

更新、生成 SQL 统计信息,主要是 V$SQLSTATS 的内容;

Cursor Mutex X 主要指对于父游标的操作;

Building a new cursor under a parent

Although this operation is cheaper, building many cursors under a parent cursor is not recommended.

Capture SQL bind data

Build or Update statistics blocks

Mutex is in the parent cursor.

以下是在生产环境中观察到的实际现象,注意在获取 cursor:mutex X 的过程中,调用的底层函数是kkscsAddChildNode 这是增加子游标的操作,需要进一步的获取排他Mutex ,使用的函数是 kgxExclusive :

关于Mutex 的使用一直在变化之中。


作者简介:

盖国强

Oracle ACE总监,中国十大杰出数据库工程师之一(2006),ITPUB论坛Oracle管理版版主,ITPUB论坛超级版主,《程序员》杂志特邀专家顾问。盖国强是国内第一位Oracle ACE及Oracle ACE总监,作为Oracle技术的推广者,在2010年创建了国内第一个Oracle用户组ACOUG(ALL China Oracle User Group),并迅速成为国际Oracle用户组的重要成员。


最后修改时间:2020-05-07 23:55:31
文章转载自eygle,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论