Home > Database > Mysql Tutorial > 如何诊断cursorpinswaitonx系列一

如何诊断cursorpinswaitonx系列一

WBOY
Release: 2016-06-07 16:12:16
Original
1359 people have browsed it

首先明确一个事情:cursor pin s wait on x 是症状(结果),不是根本原因。 mutex related wait event cursor: pin S wait on X 一般原因: 》频繁硬解析(解析时间高. 找出解析时间高的原因很关键)----可能性最大 》high version counts 》bug 如何诊断?




首先明确一个事情:cursor pin s wait on x 是症状(结果),不是根本原因。
mutex related wait event "cursor: pin S wait on X"


一般原因:
》频繁硬解析(解析时间高. 找出解析时间高的原因很关键)----可能性最大
》high version counts
》bug


如何诊断?


1.AWR ADDM 报告


正常性能阶段的AWR ADDM 报告 (作为基线比对sql ,loadprofile 等)
非正常性能阶段的AWR ADDM 报告


SQL>@$ORACLE_HOME/rdbms/admin/awrrpt.sql
SQL>@$ORACLE_HOME/rdbms/admin/addmrpt.sql


2.system state dump


如果AWR 没有捕获到异常的sql ,使用 system state dump 可以捕获 holder ,waiter 进程
(a) Non-Rac
sqlplus "/ as sysdba"


oradebug setmypid
oradebug unlimit
oradebug dump systemstate 266
---wait 90 seconds---
oradebug dump systemstate 266
---wait 90 seconds---
oradebug dump systemstate 266
oradebug tracefile_name
quit


(b) RAC
$ sqlplus '/ as sysdba'
oradebug setmypid
oradebug unlimit
oradebug setinst all
oradebug -g all hanganalyze 4
oradebug -g all dump systemstate 267
oradebug tracefile_name
quit



3.errorstack
前提:已经确定 blocker 进程 ,使用 errorstack 可以捕获更多的信息


$ sqlplus
SQL> oradebug setospid
oradebug dump errorstack 3
>
oradebug dump errorstack 3
>
oradebug dump errorstack 3
exit




4.如何确定 blocker session?
使用 systemstate dump 对系统开销(disk space)太大,如果进程很多,则dump 会很大。
不是特别建议使用。可以采取方式:3
如何确定 blocker session?可以参考:
How to Determine the Blocking Session for Event: 'cursor: pin S wait on X' (文档 ID 786507.1)



根本原理:
The column P2RAW in v$session or v$session_wait gives the blocking session for wait event cursor: pin S wait on X.


10g:
--for 32bit
select p2raw,to_number(substr(to_char(rawtohex(p2raw)),1,4),'XXXX') sid
from v$session
where event = 'cursor: pin S wait on X';
P2RAW SID
---------------- ---
0000001F00000000 00


--for 64bit
select p2raw,to_number(substr(to_char(rawtohex(p2raw)),1,8),'XXXXXXXX') sid
from v$session
where event = 'cursor: pin S wait on X';


P2RAW SID
---------------- ---
0000001F00000000 31



-----根据上一步中的sid确定阻塞session:
SQL> select sid,serial#,SQL_ID,BLOCKING_SESSION,BLOCKING_SESSION_STATUS,EVENT
from v$session where SID=31;


-----11g 可以直接找到阻塞会话:
select sid,serial#,SQL_ID,BLOCKING_SESSION,BLOCKING_SESSION_STATUS,EVENT
from v$session where event ='cursor: pin S wait on X'


SID SERIAL# SQL_ID BLOCKING_SESSION BLOCKING_SESSION_STATUS EVENT
---- ------- ------------- ---------------- ----------------------- ----------
125 8190 lixora-lixora 135 VALID cursor: pin S wait on X



5.确定 waiter session
SELECT s.sid, t.sql_text
FROM v$session s, v$sql t
WHERE s.event LIKE '%cursor: pin S wait on X%'

AND t.sql_id = s.sql_id




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template