观看PMON清理死进程的过程

7220阅读 0评论2013-01-29 tomsyan
分类:Oracle


PMON的一个关键功能就是在进程失败的时候清理死进程及其相关的资源。

我们来观看一下PMON清理死进程的过程,100246事件可以跟踪PMON的行为。



Event 10246 - Trace PMON Process
This event can be used to trace the actions of the PMON background process

This event can only be enabled in the init.ora file using

    event = "10246 trace name context forever, level 1"

The ALTER SYSTEM command does not appear to work for this event

There only appears to be one level for this event (levels 5 and 10 appear to generate the same output as level 1)




SQL> show parameter event

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
event                                string      10246 trace name context forever,level 1
xml_db_events                        string      enable




开启一个SESSION :

C:\Documents and Settings\htaix>sqlplus test/test@192.168.0.5/huateng

SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 1月 29 11:14:31 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> delete from x;

已删除12行。

SQL> select  sid,serial#,paddr from v$session where sid=userenv('sid');

       SID    SERIAL# PADDR
---------- ---------- --------
        39         10 2A83AC80

SQL> select spid from v$process where addr='2A83AC80';

SPID
------------------------
15428








然后在OS级别KILL掉相关的SERVER PROCESS:

SQL> !ps -ef | grep 15428
oracle   15428     1  0 01:03 ?        00:00:01 oraclehuateng (LOCAL=NO)
oracle   21234 13533  0 01:21 pts/0    00:00:00 /bin/bash -c ps -ef | grep 15428
oracle   21236 21234  0 01:21 pts/0    00:00:00 /bin/bash -c ps -ef | grep 15428

SQL> ! kill -9 15428


此时查询SESSION 会报ORA-03113错误:

SQL> select  sid,serial#,paddr from v$session where sid=userenv('sid');
select  sid,serial#,paddr from v$session where sid=userenv('sid')
*
第 1 行出现错误:
ORA-03113: 通信通道的文件结束



过一段时间后,将会在PMON TRACE文件中发现PMON清理死进程的过程:


*** 2013-01-25 01:22:21.372
marked process 0x2a83ac80 pid=31 serial=4 ospid = 15428 dead  <-- OS PID =15428 标记为死进程
  client details:
    O/S info: user: htaix, term: HT002, ospid: 9532:3440
    machine: WORKGROUP\HT002 program: sqlplus.exe
    application name: SQL*Plus, hash value=3669949024


*** 2013-01-25 01:22:21.401
deleting process 0x2a83ac80 pid=31 serial=4 priority=0 <-- 开始清理死进程
deleting session 0x2aac6f9c sid=39 serial=10           <--清理 SESSION
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
ksuprog() called at ktur.c:3039
Audit postponed pending cleanup for session 0x2aac6f9c
deleting session 0x2aac6f9c sid=39 serial=11
Audit postponed pending cleanup for session 0x2aac6f9c
deletion of process 2a83ac80 pid=31 seq=4 prog=TRUE unsuccessful


*** 2013-01-25 01:22:21.447
found process 0x2a83ac80 pid=31 serial=4 ospid = 15428 dead


*** 2013-01-25 01:22:21.468
deleting process 0x2a83ac80 pid=31 serial=4 priority=0
deleting session 0x2aac6f9c sid=39 serial=12
deletion of process 2a83ac80 pid=31 seq=4 successful   <--成功清理完毕死进程
上一篇:11G的跟踪的增强--可以跟踪具体的SQL
下一篇:使用并发 I/O 改进 DB2 数据库性能