APPENDIX ■ DUMPING AND DEBUGGING
232
SQL> oradebug setorapid 6
Windows thread id: 1052, image: ORACLE.EXE (LGWR)
SQL> oradebug suspend
Statement processed.
SQL> -- get some other session to do a little work and commit
SQL> -- it will hang on the commit, waiting on log file sync.
SQL> oradebug resume
Statement processed.
SQL>
Suspending lgwr is particularly risky. Don’t forget that there may be some recursive SQL going on
that will make sessions hang; for example, if you have database auditing enabled with audit connect,
any ordinary end-user sessions trying to connect or disconnect will hang because their connection will
try to commit after inserting or updating a row in sys.aud$.
One particular use I made of the suspend mechanism was to demonstrate that one of my long-held
assumptions (that pmon detected local instance deadlocks) was wrong. I had actually made this
observation in the original manuscript, and one of my reviewers pointed out that I was wrong—so I
suspended pmon, set up a deadlock situation, and waited for the ORA-00060 “Deadlock detected” error;
sure enough, even with pmon suspended, the deadlock was still trapped and reported within the (fairly
standard) 3 seconds.
Dumps
You can use oradebug to dump memory structures to trace files. When I do this I usually connect as sys
and then attach oradebug to my own process to generate the dumps. Once you’re in oradebug, there is a
command to show the trace file name, but it seems to work only after the first use of the trace file;
however, you can modify the trace file name by setting the tracefile_identifier, and this counts as a
first use:
SQL> oradebug setmypid
Statement processed.
SQL> oradebug tracefile_name
Statement processed.
SQL> alter session set tracefile_identifier = xxx;
Session altered.
SQL> oradebug tracefile_name
c:\oracle\admin\d10g\udump\d10g_ora_2256_xxx.trc
SQL>
If you want to see a list of all the available dumps, the command is oradebug dumplist. Many dump
commands take two parameters—the name of the dump and the level at which to dump. The dump
level then tends to follow two patterns: one is simply the higher the level the more that gets dumped; the
other is a bitmap approach, where different powers of 2 result in different dumps. Table A-1 lists the dump
commands I used in the course of writing this book. The effects are not consistent across versions; this
table covers 10g+.
评论