In this Document
|
可以在什么位置找到原因诊断以及关于这些等待事件的更多信息? |
APPLIES TO:
Oracle Database - Enterprise Edition - Version 10.1.0.2 and later
Oracle Database - Standard Edition - Version 10.1.0.2 and later
Oracle Database - Personal Edition - Version 10.1.0.2 and later
Information in this document applies to any platform.
PURPOSE
本文章针对与CURSOR(游标)管理活动相关的等待事件提供了一些核心要点信息。
QUESTIONS AND ANSWERS
什么是 'cursor: ' 等待事件?
处理或访问cursor的任何操作都可能需要等待,才能访问在 shared pool 中支持这些操作的结构。在极限争用的情况下,这些等待事件就会成为一个显著瓶颈,继而束缚正常活动。从版本 10.2 开始,一些共享cursor操作开始由 Oracle 的 Mutex 功能实施,在 11g 中 Librarycache 和 rowcache 组件也通过 Mutex 实施。
最常见的等待事件是什么?
最常见的等待事件包括:
- cursor: mutex X
- cursor: mutex S
- cursor: pin X
- cursor: pin S
- cursor: pin S wait on X
- library cache: mutex X
- library cache: mutex S
请注意,所有这些等待事件都非常相似,并且可能都是在一个操作过程中产生的等待。eXclusive(排他)操作是需要更改特定结构的那些操作;Share(共享)操作可以在不更改的情况下进行,只是需要在更改过程中暂时锁定这些操作,以防止其被其他项更改。这点区别实际对于问题的诊断并没有太多关联,只是特定等待事件可能在特定问题中更为常见。
等待事件最常见的原因是什么?
基于这些事件的争用通常是另一个问题的症状表现 – 即问题是其它地方产生的,而不是 mutex 机制本身。如果需要解决 mutex 竞争这个问题表现,我们需要识别问题根本原因并加以处理。
Cursor 相关等待事件是 SQL 语句在 parse 时产生的,包括将cursor加载到 shared pool 中或在其中搜索那些cursor。出现这些问题可能的原因:
- shared pool 中 cursor 的版本数变得过多
- 过多的硬/软分析
- 过多的无效/重新加载
- 加载了大量的对象
- shared pool 大小不合适
- 资源的持有者被 OS 或者 Resource Manager 从 CPU 上移除
- 内存的操作系统管理(例如 Linux x86-64 上非常大的 SGA,而没有实施 Hugepage)
- 代码缺陷
如果 cursor 共享的很好,并且 child cursor 和版本数量较低,那么一般不会产生这种类型的争用。
如何避免这些等待事件?
通常,通过采用合理的cursor共享策略,正确使用绑定变量并确保没有大量版本,应该能够避免大多数这类性质的问题。有用的文章包括:
Note:62143.1 Understanding and Tuning the Shared Pool
Note:94036.1 Init.ora Parameter "CURSOR_SHARING" Reference Note
如果您发现自己有大量 cursor 版本,参阅以下文章可能会有所帮助:
Note:296377.1 Troubleshooting: High Version Count Issues
Note:438755.1 Formated V$SQL_SHARED_CURSOR Report by SQLID or Hash Value
可以在什么位置找到原因诊断以及关于这些等待事件的更多信息?
- 常见诊断
因为这些等待事件具有相似的原因,因此有些诊断信息对所有的等待都适用:
- cursor: mutex X
一个 cursor 正在被parse 并尝试以 eXclusive 模式获取 cursor mutex
- cursor: pin X
一个 cursor 正在被parse 并尝试以 eXclusive 模式获取cursor pin
- cursor: pin S wait on X
一个 cursor 正在被parse 并持有了 cursor pin,而且尝试在 eXclusive 模式下获取该 cursor pin。如果在 AWR的“Top Waits”部分看见 'cursor: pin S wait on X' 突出显示,如下所示:
则应该首先查看您在系统中具有的 cursor 版本数:
如果它们接近此处显示的异常高的数量,则根据优先级减少 cursor 版本。请参阅:
Document 296377.1 Troubleshooting: High Version Count Issues
如果不是这个原因导致的,您可以使用下列文章帮助排除问题:
Note:1349387.1 Troubleshooting 'cursor: pin S wait on X' waits
Note:1298015.1 WAITEVENT: "cursor: pin S wait on X" Reference Note
Note:786507.1 How to Determine the Blocking Session for Event: 'cursor: pin S wait on X'
Note:742599.1 High 'cursor: pin S wait on X' and/or 'library cache lock' Waits Generated by Frequent Shared Pool/Buffer Cache Resize Activity
Note:1268724.1 "Cursor: Pin S Wait On X" Contention Mutex Sleep Reason Primarily ' kkslce [KKSCHLPIN2]'
Note:402027.1 Bug:5653007; 5485914: SELF DEADLOCK PROCESS WAITS ON ''Cursor: Pin S Wait On X'' with SQL_TRACE enabled.
Note:9472669.8 Bug 9472669 - 'cursor: pin S wait on X' waits for invalid SQL over DB link
- library cache: mutex S
此处将执行 library cache 操作并尝试在 Share 模式下获取 library cache mutex
有用参考
Note:34579.1 WAITEVENT: "library cache pin" Reference Note
REFERENCES
NOTE:1298015.1 - WAITEVENT: "cursor: pin S wait on X" Reference Note
BUG:9591812 - INCORRECT WAIT EVENTS IN 11.2 ("CURSOR: MUTEX S" INSTEAD OF "CURSOR: MUTEX X")
NOTE:1268724.1 - "Cursor: Pin S Wait On X" Contention Mutex Sleep Reason Primarily ' kkslce [KKSCHLPIN2]'
NOTE:786507.1 - How to Determine the Blocking Session for Event: 'cursor: pin S wait on X'
NOTE:94036.1 - Init.ora Parameter "CURSOR_SHARING" Reference Note
NOTE:758674.1 - " Library Cache: Mutex X " On Koka Cursors (LOBs) Non-Shared :
NOTE:9472669.8 - Bug 9472669 - 'cursor: pin S wait on X' waits for invalid SQL over DB link
NOTE:727400.1 - WAITEVENT: "library cache: mutex X"
NOTE:742599.1 - High 'cursor: pin S wait on X' and/or 'library cache lock' Waits. Cause: Shared Pool/Buffer Cache Resize Activity
NOTE:748642.1 - How to Generate an AWR Report and Create Baselines
NOTE:62143.1 - Troubleshooting: Tuning the Shared Pool and Tuning Library Cache Latch Contention
NOTE:361468.1 - HugePages on Oracle Linux 64-bit
NOTE:1310764.1 - WAITEVENT: "cursor: pin S" Reference Note
NOTE:1349387.1 - Troubleshooting 'cursor: pin S wait on X' waits.
NOTE:1357946.1 - Troubleshooting 'library cache: mutex X' waits.
NOTE:1360119.1 - * FAQ: Database Performance Frequently Asked Questions
NOTE:1363422.1 - Automatic Workload Repository (AWR) Reports - Start Point
NOTE:175006.1 - Steps to generate HANGANALYZE trace files (9i and below)
NOTE:296377.1 - Troubleshooting: High Version Count Issues
NOTE:301137.1 - OSWatcher Black Box User Guide (Includes: [Video])
NOTE:438755.1 - High SQL Version Counts - Script to determine reason(s)
NOTE:452358.1 - How to Collect Diagnostics for Database Hanging Issues
NOTE:9530750.8 - Bug 9530750 - High waits for 'library cache: mutex X' for cursor Build lock
NOTE:9591812.8 - Bug 9591812 - Wrong wait events in 11.2 ("cursor: mutex S" instead of "cursor: mutex X")
NOTE:34579.1 - WAITEVENT: "library cache pin" Reference Note
NOTE:402027.1 - Bug:5653007; 5485914: SELF DEADLOCK PROCESS WAITS ON ''Cursor: Pin S Wait On X'' with SQL_TRACE enabled.
BUG:5653007 - SELF DEADLOCK PROCESS WAITS ON ''CURSOR: PIN S WAIT ON X''
NOTE:1364257.1 - How to Collect Errorstacks for use in Diagnosing Performance Issues.