oracle kill quickly and thoroughly clean up session


Today, the development of feedback that the implementation of a program update when hang lived, looked at what is a small table, just over 3000 lines of data. The first reaction is a lock, to all the session kill of this example, performed live update or hang separately select quickly performed under conditions where the latter. So I think it should be there on the 2-node lock, then execute the query:

select * from gv$lock where id1=383105;

SQL> select * from gv$lock where id1=383105; 

INST_ID        ADDR     KADDR      SID       TYPE     ID1       ID2       LMODE      REQUEST        CTIME      BLOCK       
-------------- -------- ---------- --------- -------- --------- --------- ---------- -------------- ---------- ---------- 
 2      0000000110AF61B0 0000000110AF6210      1333 TM          383105         0          3              0       6819          2

Sure enough, there is a session on node 2 holds lock.

2 is connected to the node, execute the query:

SQL> select sid,serial#,osuser from v$session where sid=1333; 

SID       SERIAL#        OSUSER                          
--------- -------------- ------------------------------ 
     1333          22559 6005821                        

alter system kill session '1333,22559'; 

After killing the session, then check and found that there are 1333 session:

SQL> select sid,serial#,osuser from v$session where sid=1333; 

SID       SERIAL#        OSUSER                          
--------- -------------- ------------------------------ 
     1333          22559 6005821 

So I think from the system level kill, but not the query spid 1333 through the following sqlj_0065.gif

select p.pid,p.spid,s.sid,s.serial# from v$process p,v$session s where s.paddr=p.addr and s.sid=1333;

查询后发现, 当在Oracle中kill session以后, Oracle只是简单的把相关session的paddr 指向同一个虚拟地址.此时v$process和v$session失去关联,进程就此中断。 然后Oracle就等待PMON去清除这些Session.所以通常等待一个被标记为Killed的Session退出需要花费很长的时间. 如果此时被Kill的process,重新尝试执行任务,那么马上会收到进程中断的提示,process退出,此时Oracle会立即启动PMON 来清除该session.这被作为一次异常中断处理. 

根据以下sql找到之前的paddr:

select p.addr from v$process p where pid <> 1 
minus 
select s.paddr from v$session s;
 

07000107C8C050F8 
07000107DCC19D88

根据v$process的addr找到spid:

select * from v$process where addr in ('07000107C8C050F8','07000107DCC19D88'); 

然后找到系统进程号,杀掉就好了。由于部分过程没有保留下执行结果,就只有记录下sql了。

oracle@cq2:] ps -ef|grep 8847870 
  oracle  8847870        1   3   Aug 06      - 734:23 ora_pz99_CQRPT2 
  oracle 10420652 13107576   0 11:11:01  pts/1  0:00 grep 8847870 
[oracle@cq2:] ps -ef|grep 14221746 
  oracle 12583324 13107576   0 11:11:22  pts/1  0:00 grep 14221746 
  oracle 14221746        1   0 08:16:07      -  0:04 oracleCQRPT2 (LOCAL=NO) 
[oracle@cq2:] kill -9 14221746 
[oracle@cq2:] ps -ef|grep 14221746 
  oracle 12583046 13107576   0 11:12:11  pts/1  0:00 grep 14221746

郑州不孕不育医院:http://wapyyk.39.net/zz3/zonghe/1d427.html

Guess you like

Origin blog.51cto.com/14510269/2437458