Advanced Oracle Troubleshooting
Advanced Oracle Troubleshooting
No magic is needed,
systematic approach will do
Tanel Pder
http://www.tanelpoder.com
Introduction
About me:
Occupation:
Expertise:
Oracle experience:
Certification:
Professional affiliations:
Blog:
Seminar:
Tanel Poder
Introduction
About this presentation:
http://www.tanelpoder.com
Tanel Poder
Non-systematic troubleshooting
Check alert.log
Check for disk and tablespace free space
Check for locks
Check for xyz
"We did a healthcheck and everything looks OK!"
?????!
Tanel Poder
Semi-systematic troubleshooting
Quick check for usual suspects
System load, locks, etc
Tanel Poder
Systematic troubleshooting
Demo
Tanel Poder
Troubleshooting approaches
How do you solve problems?
a)
Change
something
Problem
fixed ?
Did it help?
b)
Understand
Sure?
Measure
Tanel Poder
Manage
change
Problem
fixed and
prevented
Non-Systematic approach!
Users
locks
Users
Users
Users
v$latch
vmstat
free memory
Tanel Poder
Users
Users
disk space
optimizer
statistics
Users
Users
Statspack
alert.log
Systematic approach!
Users
User X
Users
Users
Session
SID
Server
process
SPID
Tanel Poder
Users
Users
Users
Users
Users
Users
Systematic troubleshooting
Understand the "flow" of a server process
and how to measure it
then measure it
step by step
using right tool at right step
...fix the problem once you understand it
Tanel Poder
Entry point
Wait / CPU
profile
sample
v$session.sql_id
sql_hash_value
Cursor
execution
profile
sw.sql / se.sql
snapper.sql
Sesspack
u.sql
sql.sql
sqlt.sql
dbms_profiler
PL/SQL code
execution
profile
Performance
counter profile
snapper.sql
Sesspack
xms.sql
xmsh.sql
dbms_xplan
allstats last
SQL
rowsource
execution
profile
Kernel function
execution
profile
stack sampling
pstack
Tanel Poder
Tanel Poder
Tanel Poder
?
2. v$sesstat performance counters - hints, indicators
?
3. Process stack - truth about process execution
!!!
Tanel Poder
Tanel Poder
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
__kernel_vsyscall ()
semtimedop () from /lib/libc.so.6
sskgpwwait ()
skgpwwait ()
ksliwat ()
kslwaitctx. ()
kjusuc ()
ksipgetctx ()
ksqcmi ()
ksqgtlctx ()
ksqgelctx. ()
1) Metalink:
ktcwit1 ()
kdddgb ()
175982.1 ORA-600 Lookup Error Categories
kdddel ()
kaudel ()
453521.1 ORA-04031 KSFQ Buffers ksmlgpalloc
delrow ()
qerdlFetch ()
Search: <function> "executable entry point
delexe ()
opiexe ()
2) Oracle views
kpoal8 ()
opiodr ()
v$latch_misses (lm.sql)
ttcpip ()
opitsk ()
v$latchholder (latchprofx.sql)
opiino ()
opiodr ()
v$fixed_view_definition (d.sql, f.sql)
opidrv ()
sou2o ()
3) Internet search
opimai_real ()
ssthrdmain ()
main ()
Windows
windbg, procexp - but no symbolic function names in
oracle.exe :(
Oracle internal
oradebug short_stack
oradebug dump errorstack 1
alter session set events '942 trace name errorstack'
Tanel Poder
In 10g
the autotrace also uses dbms_xplan
set autotrace on
or select * from table(dbms_xplan.display_cursor())
In 11g
DBMS_SQLTUNE.REPORT_SQL_MONITOR
Other methods
Parse stages
Syntactic check
Syntax, keywords, sanity
Semantic check
Whether objects referenced exist, are accessible (by permissions) and
are usable
soft parse
View merging
Query transformation
Transitivity, etc (example: if a=1 and a=b then b=1)
Optimization
Query execution plan (QEP) generation
Loading SQL and execution plan in library cache
hard parse
le
b
ta
sc
cursor
row source
application
ta
an
w
ro
so
ce
r
u
DEPARTMENTS
http://www.tanelpoder.com
FI
LT
ER
HASH JOIN
ER
LT
FI
SELECT
Query
E.LAST_NAME,
D.DEPARTMENT_NAME
FROM
EMPLOYEES E,
DEPARTMENTS D
WHERE
E.DEPARTMENT_ID =
D.DEPARTMENT_ID
AND D.DEPARTMENT_NAME =
'Sales'
AND E.SALARY > 2000;
SELECT
processor
bl
e
r o ac
w ce
so s s
ur fu
ce l l
EMPLOYEES
w
ro
cursor
app.
row source
SELECT
processor
u
so
e
rc
HASH JOIN
ro
w
so
u
rc
e
EMPLOYEES
NL
JOIN
w
ro
u
so
e
rc
DEPARTMENTS
ro
w
so
u
rc
e
LOCATIONS
http://www.tanelpoder.com
Execution plan
structure
http://www.tanelpoder.com
Execution plan
structure
http://www.tanelpoder.com
Cascading rowsources
Rows "cascade" upwards to parent rowsources from children
Execution plan
structure
http://www.tanelpoder.com
SELECT
cursor
processor
app.
row source
------------------------------------------------------------------------| Id | Operation
| Name
|
------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
|* 1 |
FILTER
|
|
|
2 |
NESTED LOOPS OUTER
|
|
|* 3 |
HASH JOIN OUTER
|
|
|
4 |
NESTED LOOPS OUTER
|
|
|
5 |
NESTED LOOPS OUTER
|
|
|* 6 |
HASH JOIN
|
|
ce
ur
|
7 |
TABLE ACCESS FULL
| USER$
|
o
s
w
|
8 |
NESTED LOOPS
|
|
ro
|* 9 |
HASH JOIN
|
|
| 10 |
MERGE JOIN CARTESIAN
|
| USER$
|* 11 |
HASH JOIN
|
|
|* 12 |
FIXED TABLE FULL
| X$KSPPI
|
| 13 |
FIXED TABLE FULL
| X$KSPPCV
|
| 14 |
BUFFER SORT
|
|
| 15 |
TABLE ACCESS FULL
| TS$
|
|* 16 |
TABLE ACCESS FULL
| TAB$
|
|* 17 |
TABLE ACCESS BY INDEX ROWID | OBJ$
|
|* 18 |
INDEX UNIQUE SCAN
| I_OBJ1
|
| 19 |
TABLE ACCESS BY INDEX ROWID
| OBJ$
|
|* 20 |
INDEX UNIQUE SCAN
| I_OBJ1
|
| 21 |
TABLE ACCESS BY INDEX ROWID
| OBJ$
|
|* 22 |
INDEX UNIQUE SCAN
| I_OBJ1
|
| 23 |
TABLE ACCESS FULL
| USER$
|
S
R
| 24 |
TABLE ACCESS CLUSTER
| SEG$
|
|* 25 |
INDEX UNIQUE SCAN
| I_FILE#_BLOCK# |
HASH
| 26 |
NESTED LOOPS
|
|
JOIN
|* 27 |
INDEX RANGE SCAN
| I_OBJAUTH1
| S
|* 28 |
FIXED TABLE FULL
| X$KZSRO
|R
|* 29 |
FIXED TABLE FULL
| X$KZSPR
|
X$KSPPI
-------------------------------------------------------------------------
HASH
JOIN
ro
w
so
ur
ce
NL
JOIN
w
ro
ur
so
ce
RS
MERGE
CART.
JOIN
TAB$
RS
TS$
RS
X$KSPPCV
so
ur
ce
OBJ$
HASH
JOIN
S
R
ro
w
http://www.tanelpoder.com
SELECT
cursor
processor
app.
row source
------------------------------------------------------------------------| Id | Operation
| Name
|
------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
|* 1 |
FILTER
|
|
|
2 |
NESTED LOOPS OUTER
|
|
|* 3 |
HASH JOIN OUTER
|
|
|
4 |
NESTED LOOPS OUTER
|
|
|
5 |
NESTED LOOPS OUTER
|
|
|* 6 |
HASH JOIN
|
|
ce
ur
|
7 |
TABLE ACCESS FULL
| USER$
|
o
s
w
|
8 |
NESTED LOOPS
|
|
ro
|* 9 |
HASH JOIN
|
|
| 10 |
MERGE JOIN CARTESIAN
|
| USER$
|* 11 |
HASH JOIN
|
|
|* 12 |
FIXED TABLE FULL
| X$KSPPI
|
| 13 |
FIXED TABLE FULL
| X$KSPPCV
|
| 14 |
BUFFER SORT
|
|
| 15 |
TABLE ACCESS FULL
| TS$
|
|* 16 |
TABLE ACCESS FULL
| TAB$
|
|* 17 |
TABLE ACCESS BY INDEX ROWID | OBJ$
|
|* 18 |
INDEX UNIQUE SCAN
| I_OBJ1
|
| 19 |
TABLE ACCESS BY INDEX ROWID
| OBJ$
|
|* 20 |
INDEX UNIQUE SCAN
| I_OBJ1
|
| 21 |
TABLE ACCESS BY INDEX ROWID
| OBJ$
|
|* 22 |
INDEX UNIQUE SCAN
| I_OBJ1
|
| 23 |
TABLE ACCESS FULL
| USER$
|
S
R
| 24 |
TABLE ACCESS CLUSTER
| SEG$
|
|* 25 |
INDEX UNIQUE SCAN
| I_FILE#_BLOCK# |
HASH
| 26 |
NESTED LOOPS
|
|
JOIN
|* 27 |
INDEX RANGE SCAN
| I_OBJAUTH1
| S
|* 28 |
FIXED TABLE FULL
| X$KZSRO
|R
|* 29 |
FIXED TABLE FULL
| X$KZSPR
|
X$KSPPI
-------------------------------------------------------------------------
HASH
JOIN
ro
w
so
ur
ce
NL
JOIN
w
ro
ur
so
ce
RS
MERGE
CART.
JOIN
TAB$
RS
TS$
RS
X$KSPPCV
so
ur
ce
OBJ$
HASH
JOIN
S
R
ro
w
Tanel Poder
PLSQL_ENTRY_OBJECT_ID
PLSQL_ENTRY_SUBPROGRAM_ID
PLSQL_OBJECT_ID
PLSQL_SUBPROGRAM_ID
ostackprof
oradebug short_stack based stack profiler
latchprofx
session level latch holder profiling script
plain SQL!
includes info in which function in Oracle kernel the latch
get was invoked
Tanel Poder
Tanel Poder
Application
OCI
UPI
Oracle
Net/TTC
OS/TCP
TCP/IP
Net
OS/TCP
TCP/IP
Oracle
Net/TTC
OPI
kks
qer
kcb
ksf
skgf
OS
Time
OS / IO system calls
Tanel Poder
Application
OCI
$OH/rdbms/demo/ociucb.mk, OCITrace
UPI
Oracle
Net/TTC
OS/TCP
TCP/IP
OS/TCP
TCP/IP
Oracle
Net/TTC
OPI
Event 10051
kks
qer
kcb
ksf
skgf
OS / IO system calls
Net
OS
Tanel Poder
Tanel Poder
?
2. v$sesstat performance counters - hints, indicators
?
3. Process stack - truth about process execution
!!!
Tanel Poder
V$SESSION_WAIT
V$SESSION_EVENT, V$SESS_TIME_MODEL (10g+)
Snapper, Sesspack, Statspack session mode
V$SESSTAT
Tanel Poder
Tanel Poder
References
Metalink notes:
459694.1 - Procwatcher: Script to Monitor and Examine Oracle and CRS
Processes
175982.1 - ORA-600 Lookup Error Categories (explains function names)
Web:
http://blog.tanelpoder.com
http://www.juliandyke.com/Diagnostics/Diagnostics.html
Seminar:
If you like this stuff, you'll definitely like my seminar!
http://blog.tanelpoder.com/seminar/
Questions?
Further questions welcome at
http://blog.tanelpoder.com
Thank you!
Tanel Pder
tanel@tanelpoder.com
http://www.tanelpoder.com