Oracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention Troubleshooting
Troubleshooting in Oracle
Tanel Põder
http://blog.tanelpoder.com
If you like this session...
...then you're probably an Oracle geek like me ;)
Oh... and I do seminars with much more stuff like this ;-)
And I also fix these kinds of problems as a consultant
http://blog.tanelpoder.com/seminar/
[email protected]
Latch is a lock
period.
SQL Trace
you need to convert the P1/address number to hex:
2. Quantify for which latch that session is waiting for the most
...and whether the wait time is significant enough
V$MUTEX_SLEEP_HISTORY
Shows last individual occurrences of mutex sleeps
Based on a circular buffer, has most detail
@mutexprof script
Systemstate dumps
http://el-caro.blogspot.com/2007/10/identifying-mutex-holder.html
cursor: mutex X
We try to get a mutex on Parent cursor or V$SQLSTAT bucket in
exclusive mode.
Someone is already holding the mutex in incompatible mode
...Either there's someone already holding the mutex in X mode
...Or there may be multiple holders in S mode
Used when:
• Loading new child cursor under parent, Modifying V$SQLSTATS bucket,
Updating bind capture data
cursor: pin X
We try to pin a cursor in exclusive mode, but someone already has
pinned it in a non-compatible mode
Either one session has pinned it in X mode or multiple sessions in S
mode
PARAMETER1 - idn:
cursor:* wait events
• idn = hash value of the library cache object under protection
Find SQL from AWR by SQL_ID (hash_value is the lower half of SQLID):
SELECT sql_text FROM dba_hist_sqlstat
WHERE tpt.sqlid_to_sqlhash( sql_id ) = &idn;
PARAMETER2 - value:
low bytes of word (2 or 4 bytes) - number of mutex shared
references
high bytes of word (2 or 4 bytes) - SID of exclusive holder
PARAMETER 3 - where:
where = maps to x$mutex_sleep.location_id
Useful for understanding from which kernel function the mutex get
operation was done. Used for advanced diagnostics.