今天在群里和MECKEY讨论KILL SESSIONS的问题,结果群里出先了两派,一是我和大家都同意先试着KILL SESSION然后再KILL SPID,二是MECKEY坚持说应该先KILL SPID,然后再KILL SESSION,并且还真找出了一个英文文档,说是从METALINK上下的,下面就是这段资料,虽然这段资料和MECKEY的说法不完全一样,但也有参考价值,共同参考:
Solution Description:
====================

As part of its responsibilities, PMON cleans up old process connections -
connections where the parent process terminated abnormally, connections that
have been unintentionally interrupted (as with network failures), and
connections that Oracle has terminated due to an internal problem.

Remember, connection information is stored in the views V$SESSION and
V$PROCESS.  As part of this cleanup, PMON willonly rollback a certain number
of transactions for a given connection.  This number is determined by the
CLEANUP_ROLLBACK_ENTRIES parameter in the INIT.ORA file.  For example, if a
process goes rogue and generates, say, 1000 uncommitted updates to the
database, it will rollback CLEANUP_ROLLBACK_ENTRIES transactions each time its
periodic timer expires.  By default, this value is 20.

This means that it will rollback 20 updates each wake-up period.  At the rate
of 20 each time, and a wake-up period of 60 seconds (at 3 seconds, it cleans
up the connections latches and at 60 it cleans up the remaining stuff),  it
could take PMON as long as 50 minutes to rollback all of the entries.  
Meanwhile, all of the locks the remaining updates hold are still in effect,
preventing other users from updating those rows.

Since PMON has other database maintenance responsibilities, it takes even
longer to get through all 1000 of the updates.  So, to help PMON (not to
mention yourself) get through the updates as quickly as possible, you can add
this parameter to your INIT.ORA file.  As with anything, this must be handled
carefully.  By allowing PMON to rollback more updates each time around its
processing loop, it will take longer to get around to working on its other
responsibilities - i.e. processing other users requests.  So, there is a
performance consideration.

How does this relate to killing a session?  If you were to kill a process
(using alter system kill session) similar to theone in the above example,
Oracle will keep the connection information around until ALL of the updates
made through the connection have been cleaned up - i.e. until all outstanding
transactions performed by the rogue process has been cleaned up.  This is done
to maintain the relationship between the creator and the manipulated data (we
don't want to rollback the wrong information).  If Oracle can cleanup a
connection quicker, then the connection information can be removed from the
V$SESSION and V$PROCESS tables sooner.

PLEASE NOTE:
============

If you must kill a session and want the connection information to go away
(without bouncing your instance), the order of events is important.  Since
Oracle has a mechanism for dead connection detection and connection cleanup,
make this happen first - i.e. kill the users process first.  Then, wait for 3
to 4 minutes beyond the dead connection detection value and query V$SESSION
for the connection information.

If the information is still there,  query the V$LOCK table to see if the
connection has any outstanding locks (PMON hasn't finished cleaning up the
users information) with the following query: SELECT COUNT(*) FROM V$LOCK WHERE
SID='sid', where 'sid' is the sid identified in V$SESSION for the connection.  
This count will be WAY more than the number of actual updates (an insert
generates two locks -one DML andone for the transaction).

The point is if this is a nonzero value, PMON hasn't finished rolling back the
users updates.  If you perform this query again after a few minutes (PMON has
had at least a couple of iterations to clean up the users data), you should
see the count getting smaller.  If the value isn't getting smaller, the next
step is to user ALTER SYSTEM KILL SESSION to delete the connection at the
database level.  Perform the same steps again - query V$SESSION, then V$LOCK,
and see if progress is being made in removing the connection information.

If the count from V$LOCK is zero and the users connection information has not
gone away, then theonLY way this information will be removed is be taking the
instance down.

ANOTHER NOTE:

If the session is first killed with ALTER SYSTEM KILL SESSION and the
corresponding users process does not terminate normally, then the killed
session will continue to appear in V$SESSION during the life of the instance.  
The reason for this is that the session state object cannot be cleaned out
until the associated user process clears the pointer to it.  Since the session
abnormally aborted, this will not happen.
          
Reference documentation:

转载于:https://www.cnblogs.com/lhdz_bj/archive/2011/05/25/2056833.html

有关Kill Session问题的讨论(旧文初发)相关推荐

  1. 旧文新发----真情与技巧的交响

    真情与技巧的交响 ­--读二熊诗词有感 杨森翔 今年"五一"前,接到诗词学会寄来的<寒塘韵语>,顺手翻开,便读到五言律绝<飞鸿><秋草>< ...

  2. 侵略伤痕(旧文新发)

    这篇文章是我中学时候几篇作品的集合,最初发表在红袖添香,不知道这些年她经历了什么,今天在自己的博客,再次将这个文章发出来.只为祭奠,那逝去的青春,那些错过的人.那时候的爱情那样简单,爱的遮遮掩掩,被爱 ...

  3. 【旧文回顾】中国太阳能因制造业创新而繁荣

    [旧文回顾]中国太阳能因制造业创新而繁荣 能源     凯文•布利斯(KEVIN BULLIS)    2012-10-30 20:13:05 尚德电力的CTO认为,中国生产太阳能电池成功的秘密不是便 ...

  4. 共读记录|纪伯伦《论工作》(旧文)

    今天是七夕.其实关于七夕,除了"鹊桥相会"的传说之外,更重要的传统是"乞巧".只是在现代商业的宣传下,几乎任何节日都成了"情人节".乞巧,即 ...

  5. 【旧文重新排版】借 Go 语言 database/sql 包谈数据库驱动和连接池设计

    文 | jiayangchen 封面图片 | Unsplash 因为之前的文章感觉排版太差了,不容易阅读 接下来会把一些旧文重新排版再发一下 即使你不了解 Go 语言,阅读本文也不会有障碍 1. 什么 ...

  6. oracle查询正在执行的语句和kill session

    查询正在执行的SQL select SID,SERIAL#, OSUSER, PROGRAM, USERNAME, SCHEMANAME, B.Cpu_Time, STATUS, B.SQL_TEXT ...

  7. 【旧文新读】解释“闭包”需要几行代码?

    新读(2017年10月19日) 本文写于 2013年06月16日,今天做了一点修改,所谓修改,其实只是删去了几句不影响技术内容的话.关于闭包,我最近写了一篇新的文章,提到了静态作用域,相比本文,是对闭 ...

  8. orakill和alter system kill session的区别

    原文出处:http://blog.csdn.net/ouzhiyi_linux_oracle/archive/2009/04/16/4081739.aspx 一个用户进程偶尔会挂起或占用过多资源而拒绝 ...

  9. Oracle 彻底 kill session

    为什么80%的码农都做不了架构师?>>>    --*************************** -- Oracle 彻底 kill session --********* ...

最新文章

  1. java遍历文件目录
  2. saltstack之keepalived的安装配置
  3. Java 小程序 之将输入的数字转换为金额输出
  4. Beta冲刺Day4
  5. 18.2.28阿里前端实习生内推面补坑
  6. msfvenom 生成php木马,利用msfvenom生成木马程序
  7. Python-振动信号加入噪声-代码实现
  8. 云服务器ECS/EC2_转载
  9. SQL Server添加字段注释表注释comments,Oracle与Sql Server添加注释语法区别
  10. JAVA编程语言基础第六章
  11. 《计算机组成与设计(ARM版)》读书笔记-第二章指令1
  12. 全球上线!ABB中国涡轮增压器分拆 – 数据清理阶段完成
  13. Android 开发者转型 “FrameWork”必不可少
  14. ot permission denied while trying to connect to the Docker daemon socket at
  15. Win系统 - Windows下的沙盒运行模式,竟然这么有用?!
  16. Springmvc + Mybatis报错解决
  17. [陈鹏导师精益项目实战]华东区电机企业精益生产项目第五期启动
  18. linux常见的解压命令,linux常见解压命令
  19. 按键助手 多线程 源码
  20. 思科交换机基本配置实例讲解《一》

热门文章

  1. Shell脚本编程之(三)执行方式差异(source, sh script, ./script)
  2. python 加干扰线 图片生成_用Python一键生成炫酷九宫格图片,火了朋友圈
  3. 面向对象封装的web服务器
  4. Bzoj1176:MokiaCogs1752:[BOI2007]摩基亚Mokia
  5. BZOJ 3782 上学路线 ——动态规划 Lucas定理 中国剩余定理
  6. iOS核心动画详解swift版----基础动画
  7. 图像处理------简单脸谱检测算法
  8. asp调用数据库汉字显示乱码解决方案
  9. build_doxygen_报找不到iconv.....
  10. 开源.NET(C#、VB.NET、J#等)脚本执行引擎(利用CodeDOM)