Can kill session really KIII the process?

Source: Internet
Author: User


Session1 Confirm Sid
SYS @ prod > select userenv (' Sid ') from dual;

USERENV (' SID ')
--------------
144

Session2 Confirm Sid
SYS @ prod > select userenv (' Sid ') from dual;

USERENV (' SID ')
--------------
145

Session1 querying what connections the current database has
SYS @ Prod > select p.spid,p.pid,p.username,ss.sid,ss.serial# from v$process p,v$session SS where P.addr=ss.paddr and S S.username is not null;

SPID PID USERNAME SID serial#
------------ ---------- --------------- ---------- ----------
12244 Oracle 144 279
12269 Oracle 145 100


Operating system level view above two processes
[Email protected] ~]# Ps-ef |grep 12244
Oracle 12244 12243 0 18:32? 00:00:00 Oracleprod (description= (Local=yes) (address= (PROTOCOL=BEQ)))
Root 12298 12272 0 18:34 pts/4 00:00:00 grep 12244
[Email protected] ~]# Ps-ef |grep 12269
Oracle 12269 12268 0 18:32? 00:00:00 Oracleprod (description= (Local=yes) (address= (PROTOCOL=BEQ)))
Root 12300 12272 0 18:34 pts/4 00:00:00 grep 12269

Login Session1 Kill Session2
SYS @ PROD > alter system kill session ' 145,100 ';

System altered.


Querying the status of 2 sessions again, you can see that Session2 still exists, but session status becomes killed
SYS @ Prod > select p.spid,p.pid,p.username,ss.sid,ss.serial#,ss.status from v$process p,v$session SS where P.ADDR (+) = Ss.paddr and ss.username are NOT null;

SPID PID USERNAME SID serial# STATUS
-----------------------------------------------------------------
12244 Oracle 144 279 Active
145 killed

operating system level view process status
[[email protected] ~]# ps-ef |grep 12244oracle 12244 12243 0 18:32? 00:00:00 Oracleprod (description= (Local=yes) (address= (PROTOCOL=BEQ)))
Root 12372 12272 0 19:00 pts/4 00:00:00 grep 12244
[[email protected] ~]# ps-ef |grep 12269
Oracle 12269 12268 0 18:32? 00:00:00 Oracleprod (DESCRIPTION= ( Local=yes) (address= (PROTOCOL=BEQ)))
Root 12379 12272 0 19:01 pts/4 00:00:00 grep 12269

Query the process details
SYS @ Pro d > select p.spid,p.pid,p.username,ss.sid,ss.serial# from v$process p,v$session SS where p.spid=12269;

SPID PID USERNAME SID serial#
------------ ---------- --------------- ---------- ----------
12269 Oracle 143 159
12269 Oracle 144 279
12269 Oracle 145 100
12269 Oracle 155 1
12269 Oracle 156 1
12269 Oracle 160 1
12269 Oracle 161 1
12269 Oracle 162 1
12269 Oracle 163 1
12269 Oracle 164 1
12269 Oracle 165 1
12269 Oracle 166 1
12269 Oracle 167 1
12269 Oracle 168 1
12269 Oracle 169 1
12269 Oracle 170 1


Kill session
SYS @ PROD > alter system kill session ' 145,100 ';

System altered.

SYS @ Prod > select p.spid,p.pid,p.username,ss.sid,ss.serial# from v$process p,v$session SS where p.spid=12269;

SPID PID USERNAME SID serial#
------------ ---------- --------------- ---------- ----------
12269 Oracle 143 174
12269 Oracle 144 279
12269 Oracle 155 1
12269 Oracle 156 1
12269 Oracle 160 1
12269 Oracle 161 1
12269 Oracle 162 1
12269 Oracle 163 1
12269 Oracle 164 1
12269 Oracle 165 1
12269 Oracle 166 1
12269 Oracle 167 1
12269 Oracle 168 1
12269 Oracle 169 1
12269 Oracle 170 1

Operating system level kill process
[Email protected] ~]# kill-9 12269

Conclusion: the SPID corresponding to the session is queried, and then kill the SPID from the operating system level to really kill the process.

The following is Eygle's post, do reference
Http://www.eygle.com/faq/Kill_Session.htm

Can kill session really KIII the process?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.