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

Oracle Mutex 等待事件之: cursor mutex X

原创 eygle 2017-07-05
1189

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



The session requests the mutex for a cursor object in exclusive mode, and it must wait because the resource is busy. The mutex is busy because either the mutex is being held in exclusive mode by another session or the mutex is being held shared by one or more sessions. The existing mutex holder(s) must release the mutex before the mutex can be granted exclusively.






















ParameterDescription

P1



Hash value of cursor



P2



Mutex value (top 2 bytes contain SID holding mutex in exclusive mode, and bottom two bytes usually hold the value 0)



P3



Mutex where (an internal code locator) OR'd with Mutex Sleeps




需要持有 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 :


SQL> select sid,event,p1,p2,p3 from v$session where username='EYGLE' and sid=135;
SID EVENT P1 P2 P3
---------- ---------------------------------- ---------- ---------- ----------
135 cursor: mutex X 978779761 1.6063E+12 1.4603E+11
SQL> oradebug short_stack;
ksedsts()+461<-ksdxfstk()+32<-ksdxcb()+1876<-sspuser()+112<-__sighandler()<-semtimedop()+10
<-skgpwwait()+160<-ksliwat()+1865<-kslwaitctx()+163<-ksfwaitctx()+14<-kgxWait()+650
<-kgxExclusive()+295<-kkscsAddChildNode()+337<-kkscscid_opt_eval()+1290<-kkscsCheckCriteria()+211
<-kkscsCheckCursor()+783<-kkscsSearchChildList()+1262<-kksfbc()+12105<-kkspsc0()+1173
<-kksParseCursor()+116<-opiosq0()+1588<-opipls()+11479<-opiodr()+916<-rpidrus()+211
<-skgmstack()+148<-rpiswu2()+638<-rpidrv()+1384<-psddr0()+473<-psdnal()+457<-pevm_EXIM()+308
<-pfrinstr_EXIM()+53<-pfrrun_no_tool()+63<-pfrrun()+627<-plsql_run()+649<-peicnt()+301
<-kkxexe()+525<-opiexe()+17785<-kpoal8()+2224<-opiodr()+916<-ttcpip()+2755<-opitsk()+1717
<-opiino()+966<-opiodr()+916<-opidrv()+570<-sou2o()+103<-opimai_real()+133
<-ssthrdmain()+252<-main()+201<-__libc_start_main()+253<-_start()+36
复制

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


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论